用MSCOMM控件向串口发送AT指令并得到GSM MODEM的返回信息

分享
奇怪的AT指令
计算机连了一个WAVECOM的GSM MODEM,拟用MSCOMM控件向串口发送AT指令并得到GSM MODEM的返回信息。
代码如下:

  LOCAL aVzifua as String

thisform.mycomm.portOpen=.T.
        thisform.mycomm.input
        thisform.mycomm.InBufferCount = 0  
*!*                thisform.mycomm.Output = [AT] + CHR(13)
        thisform.mycomm.Output = CREATEBINARY([AT] + CHR(13))
*!*                thisform.mycomm.Output = CREATEBINARY([AT]) + CHR(13)
                nVsj=SECONDS()+5

        DO  While  SECONDS() <=nVsj

            If thisform.mycomm.InBufferCount $amp;>amp;$nbsp;0
                aVzifua =thisform.mycomm.Input
            ENDIF


        ENDDO

thisform.text1.Value=aVzifua
thisform.mycomm.portOpen=.F.



运行后总是得不到返回信息。后来装了一个监视串口信息的serial monitor软件,发现这段代码总是要运行两次,端口才能返回“OK”,但我的文本框中两次都显示不出任何字符。

特请高手赐教:
1.为什么要运行两次才能“OK”?
2.如何得到返回信息

serial monitor给出的串口信息如下:

Read:
Port opened

Baud rate set to 9600

StopBits: 1 stop bit, Parity: No parity, WordLength: 8

Port closed

Port opened

Baud rate set to 9600

StopBits: 1 stop bit, Parity: No parity, WordLength: 8
0D        0A        4F        4B        0D        0A         ..OK..
Port closed

Write:
Port opened

Baud rate set to 9600

StopBits: 1 stop bit, Parity: No parity, WordLength: 8
41        54        0D         AT.
Port closed

Port opened

Baud rate set to 9600

StopBits: 1 stop bit, Parity: No parity, WordLength: 8
41        54        0D         AT.
Port closed
短信设备二次开发 2022-04-05 0 0

admin

  • 注册时间 : 2022-03-30 04:08:47
  • 邮箱地址 : admin@tenghengkeji.com
  • 此页面用于展示用户的基本上资料信息

回帖 ( 0 )