Modem AT commands from C
Home › Forums › MultiConnect OCG › Modem AT commands from C
- This topic has 5 replies, 2 voices, and was last updated 13 years ago by
Bryan Tran.
-
AuthorPosts
-
October 25, 2012 at 7:32 pm #2837
Jim Hansen
ParticipantI want to get the result of AT command in a C program.
I open /dev/ttyUSB3 or 5 (on an H4 radio) and sets the serial port to 230400, 8N1, send an AT command and read a response. I don’t get any errors, but I get no output or “nERRORnn” back.
Is there another way to get an AT command’s response? Microcom has some issue with stdout, I hear.
Or, how do I know the port settings to use the port directly?
October 25, 2012 at 8:12 pm #4324Bryan Tran
ModeratorHi Jim,
1. The correct port for the H4 is: /dev/ttyUSB3 and /dev/ttyUSB4.
2. As a test, would you please ssh into the CDP device and issue the following command:
microcom /dev/ttyUSB3 -s 115200[Enter]
AT[Enter]
Do you get any response ?
*Note: If you do not see what you are typing, try: ATE1[Enter]
If you do get response on the above command, then it likely there is something in your C program.
Regards,
BT
October 25, 2012 at 9:03 pm #4325Jim Hansen
ParticipantI did get a response:
“ERROR”
then another AT command and “OK”
I assume that something’s wrong with the code/port setup. I intermittently get “ERROR” or 0 bytes.
How do I know the correct settings for this port?
Is it documented?
I’m now using 115200 baud.
October 26, 2012 at 4:46 pm #4326Bryan Tran
ModeratorHi Jim,
Would you pls reboot your CDP and then ssh back into your CDP and type the following commands, post your output.
microcom /dev/ttyUSB3[Enter]
AT[Enter]
ATI[Enter]
AT+CSQ[Enter]
AT+CREG?[Enter]
AT+CPIN?[Enter]
I am not very sure why you would get an “Error” message response after typed in AT[enter].
The USB port will ignored the serial baud rate settings.
Regards,
BT
October 26, 2012 at 7:57 pm #4327Jim Hansen
ParticipantHi,
After reboot, get the expected output
OK
Manufacturer: Sierra Wireless, Incorporated
Model: MC8790V
Revision: K2_0_7_24BAP C:/WS/FW/K2_0_7_24BAP/MSM6290/SRC 2010/02/09 00:19:18
IMEI: 012376000067082
IMEI SV: 15
FSN: C681542057310
3GPP Release 5
+GCAP: +CGSM,+DS,+ES
OK
+CSQ: 1,99
OK
etc.
After I run my program, I do this again and the first time AT returns ERROR, then its ok.
If USB doesn’t need baud rate, are there other settings it does or doesn’t need? My code looks a lot like the termios part of
http://en.wikibooks.org/wiki/Serial_Programming/Serial_Linux
Jim
October 29, 2012 at 1:50 pm #4328Bryan Tran
ModeratorHi Jim,
Take a look at this sms-utils code and may by take out the serial port part http://git.multitech.net/cgi-bin/cgit.cgi.
Regards,
BT
-
AuthorPosts
- You must be logged in to reply to this topic.