Hi,
I have a NB-IoT modem (Siretta Zeta) connected via RS232 to a CR1000X.
In my program, I would like to log certain details of the mobile connection.
Here is the code I use to send AT-commands and log the reply:
If TimeIntoInterval (3,60,Min) AND modem_pwr = TRUE AND getsimastat = TRUE Then ppp = PPPClose Delay (1,10,sec) ppp = "closed" ATCOPS = "" ATCSQ = "" ATRFSTS = "" ATMONI = "" SerialOpen (MODEM_PORT,MODEM_BAUD,0,0,10000) SerialFlush(MODEM_PORT) SerialOut (MODEM_PORT, "AT+COPS?"+CR,0,0,100) SerialIn (ATCOPS,ComRS232,300,0,1000) SerialOut (MODEM_PORT, "AT+CSQ"+CR,0,0,100) SerialIn (ATCSQ,ComRS232,300,0,1000) SerialOut (MODEM_PORT, "AT#RFSTS"+CR,0,0,100) SerialIn (ATRFSTS,ComRS232,300,0,1000) SerialOut (MODEM_PORT, "AT#MONI"+CR,0,0,100) SerialIn (ATMONI,ComRS232,300,0,1000) SerialClose(MODEM_PORT) EndIf
I already experimented with different timeout settings and waiting for termination string, but the input strings tend to get mixed up, meaning the reply to the first SerialOut ends up partially in the second SerialIn or does not get recorded at all. In the terminal, when watching the RS232 port everything seems to be fine, so the issue must be related to how the input string gets recorded/processed in the buffer.
Here is how the strings look like:
ATCOPS
AT+COPS? +COPS: 0,0,"Siminn",
ATCSQ
9 OK AT+CSQ
ATRFSTS
+CSQ: 14,3 OK AT#RFSTS #RFSTS: "274 01",3691,-87,-78,-9.0,0068,00,,256,3,0,0A9CA01,"274012010240933","Siminn",2,8,720,3240,162 OK
ATMONI
AT#MONI #MONI: Siminn RSRP:-86 RSRQ:-9 TAC:0068 Id:0A9CA01 EARFCN:3691 PWR:-75dbm DRX:256 pci:0 QRxLevMin:0 OK
This seems mainly related to AT+COPS? and AT+CSQ. I haven't seen this happening with AT#RFSTS and AT#MONI, even when I shuffle the order of the commands.
Any ideas what might be causing this and how to fix it?