AT ^ SYSINFO and C ++ Terminal Program

I wrote a program that consistently integrates a USB 3g modem. When I open the port and write the AT command

AT 

For the modem, I get a normal “OK” response and can read it using the sequential read function. In the terminal, when I write a command

 AT^SYSINFO 

I get the following answer:

 ^SYSINFO:#,#,#,#,#,# 

C # number. However, when I try to write the same command sequentially using my program, I read only this answer:

 AT^SYSINFO 

I then try to read another line of incoming data, but no data is coming in. Can anyone help me with this? The ^ SYSINFO message has information that I need to extract.

0
c ++ tty at-command
source share
1 answer

You MUST terminate the AT command line with \r and nothing else (unless you changed ATS3 but should not) 1 . To quote the V.250 specification :

 5.2.1 Command line general format A command line is made up of three elements: the prefix, the body, and the termination character. The command line prefix consists of the characters "AT" or "at", or, to repeat the execution of the previous command line, the characters "A/" or "a/". The body is made up of individual commands as specified later in this Recommendation. Space characters are ignored and may be used freely for formatting purposes, unless they are embedded in numeric or string constants (see 5.4.2.1 or 5.4.2.2). The termination character may not appear in the body. The DCE shall be capable of accepting at least 40 characters in the body. The termination character may be selected by a user option (parameter S3), the default being CR (ASCII value 13). 

DCE stands for modem.

(I removed the IA5 links in the above quote as this is only confusing)


1 Termination with \r\n will usually work, but this is only due to a 125 ms interrupt timeout delay, which makes the extra \n not cancel the command.

+1
source share

All Articles