我编写了一个用USB 3g调制解调器串行通信的程序。当我打开端口并写入AT命令
时AT
对于调制解调器,我得到正常的“OK”响应并可以使用串行读取功能读取它。在终端中,当我写命令
时AT^SYSINFO
我收到以下回复:
^SYSINFO:#,#,#,#,#,#
#是数字。但是,当我尝试使用我的程序连续编写相同的命令时,我只读了这个响应:
AT^SYSINFO
我尝试再读取另一行传入数据,但没有数据出现。 谁能帮我这个?我需要提取^ SYSINFO消息中的信息。
答案 0 :(得分:1)
你必须终止一个带有\r
的AT命令行,除非你修改了ATS3
,否则你不应该这样做。 1 。引用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表示调制解调器。
(我在上面的引文中删除了IA5引用,因为这只是令人困惑)
1
使用\r\n
终止通常会起作用,但这只是因为125ms中止超时延迟使额外\n
不中止命令。