вторник, 26 октября 2010 г.

+CMGS Send message
+CMSS Send message from storage
+CMGW Write message to memory
+CMGD Delete message
+CMGC Send command
+CMMS More messages to send


To send SMS’s you need to put the device in “Text” mode. This is done by sending the following command:
AT+CMGF=1 # Puts the mode in text mode
To send an SMS do the following:
AT+CMGS=”+35386827XXXX”
> 3G Rocks!!!!
CTRL-Z
When you type in the line with the phone number the “>” will come up automatically. Type in your message and when you are finished type in CTRLZ (as in ctrl key and z at the same time).
Good so far? But how about incoming messages. Have no fear, DBTR is here!!!
AT+CMGL=”all” #To get a list of SMS’s type in :
AT+CMGR=0 #get an individual message
AT+CMGD=n #Delete a message where n is the number returned by the list above.
There are quite a few other commands that the Huawei understands. I’ll post them later.
To hangup just do CTRLA x.

-----------------

AT
OK
AT+CMGF=1
OK
AT+CMGW="+85291234567"
> A simple demo of SMS text messaging.
+CMGW: 1

OK
AT+CMSS=1
+CMSS: 20

OK


------------------------

Sending SMS

First of all, the simplest option is to put the device into text mode. This is done with the following command:
 
chat TIMEOUT 1 "" "AT+CMGF=1" "OK" > /dev/tts/USB2

The terminal on which you are running cat should come back wtih the result:

AT+CMGF=1
OK


If it doesn’t, then either you are not watching the correct device, or your USB dongle’s firmware does not support SMS.
The next step is to tell the modem what number to send the text message to. Note the escaped quotes in the following command. When nesting similar quotes in such a manner, we must tell the terminal to treat the inner quotes as plain text to avoid the command trying to process them as part of the command line. Replace the xxxxxxxxxxx with the telephone number you wish to send the SMS to.
 
chat TIMEOUT 1 "" "AT+CMGS=\"xxxxxxxxxxx\"" "OK" > /dev/tts/USB2

On your second terminal, you should see the response:

AT+CMGS="xxxxxxxxxxx"
>


This is a prompt to enter the SMS’s text in plaintext format. The command is simply:

chat TIMEOUT 1 "" "Message text goes here" "OK" > /dev/tts/USB2

To insert a new line of text, just repeat this command.
To finalise the message, normally you would press . To emulate this, we use the ^ character. This will cause the terminal to treat it as if you have pressed the CTRL key followed by the next character. The command reads as follows:

chat TIMEOUT 1 "" "^Z" "OK" > /dev/tts/USB2

After a couple of seconds, your watching terminal should respond with:
+CMGS: n
n will be a number corresponding to the number of sent messages from the device.
You should now have the text message arrive at the destination telephone number.
Simples.

Receiving SMS

First step, as with sending SMS, is to put the device into text mode. This is exactly the same command used before:

chat TIMEOUT 1 "" "AT+CMGF=1" "OK" > /dev/tts/USB2

As an optional step, you can list all of the SMS stored on the SIM like so:
chat TIMEOUT 1 "" "AT+CMGL" "OK" > /dev/tts/USB2
The only real requirement for reading SMS, however, is to choose the index number of the SMS you wish to read. This is done with this command:

chat TIMEOUT 1 "" "AT+CMGR=n" "OK" > /dev/tts/USB2

In order to delete a SMS, should you so wish, it is done via a very similar command:

chat TIMEOUT 1 "" "AT+CMGD=n" "OK" > /dev/tts/USB2

That’s all I’m gonna talk you through, but there are countless resources online for finding out what some other AT commands are, and it’s quite interesting just firing them at the device to see what the response is, and I encourage you to have a mess about… Be careful when messing around with the SIM PIN codes, though, and it’s not my fault if you lock yourself out of your kit!
Hope I’ve been of use!
As always… Any questions/mistakes I’ve made, just leave a comment.
n00b



понедельник, 18 октября 2010 г.

Команда nice

Команда nice запускает программу с изменённым приоритетом для планироващика задач. Слово «nice» в английском языке обозначает, в частности, «вежливый». По этимологии этой команды процесс с большим значением nice — более вежлив к другим процессам, позволяя им использовать больше процессорного времени, поскольку он сам имеет меньший приоритет (и, следовательно, большее «значение вежливости» — niceness value).

Наибольший приоритет (и наименьшее значение nice) — −20. 19, либо 20 — наименьший приоритет, но это, с другой стороны, самые вежливые процессы.

Чтобы посмотреть идентификатор и значение nice нужного процесса в системе, можно воспользоваться командой ps axl.

Пример использования команды nice — запуск ресурсоёмкой задачи в фоновом режиме, так, чтобы она выполнялась, но освобождала часть процессорного времени для других процессов, как только оно становятся им нужно. Таким образом можно, скажем, запустить кодирование OGG/MP3 с большим значением nice, чтобы оно происходило в фоновом режиме, используя не всё процессорное время, а то, что не используется другими процессами (с меньшим значением nice — то есть с большим приоритетом).

Чтобы запустить команду с определённым приоритетом, слева нужно добавить «nice -n значение_nice», либо «nice --adjustment значение_nice» (adjustment — настройка, регулировка).

То есть: nice -n значение_nice команда.

Если нужно изменить приоритет уже запущенного процесса, можно воспользоваться командой renice.

renice -n значение_nice id_процесса

Команда renice выводит старый и новый приоритет процесса.