SKIP and bs2pe
Tumbler
Posts: 323
Hello,
I have some problems with parsing a response from a gprs modem.
this is the result when i send the command to my·modem:
SEROUT 0,Baud,[noparse][[/noparse]"AT+CPBR=2", 13] means: show·second phonebook entry
result: counter: char (ascii) see table below.
Now i'm trying to get the id (second place), the phonenumber (04 to 15) and the name (23 to 26) with this command:
SERIN 1,Baud,[noparse][[/noparse]WAIT("+CPBR:") , SKIP 1 , id , SKIP 2 , STR response\12, SKIP 7, STR name\4]
·············································· ·· |·············· |······································ ···· |
······································· ·ignore '32'······ ignore'44 and 34'············· ignore 7 bytes
And this seems not to work.
Any ideas why?
00 : ·· (32)·················
01 : 2 (50)
02 : ,· (44)
03 : "· (34)
04 : + (43)
05 : 3 (51)
06 : 2 (50)
07 : 4 (52)
08 : 9 (57)
09 : 8 (56)
10 : *·(number)
.
.
15 : * (number)
16 : " (34)
17 : , (44)
18 : 1 (49)
19 : 4 (52)
20 : 5 (53)
21 : , (44)
22 : " (34)
23 : I (73)
24 : l (108)
25 : s (115)
26 : e (101)
27 : " (34)
28 :· char(13)
29 :· char(10)
30 :· char(13)
31 :· char(10)
32 : O (79)
33 : K (80)
33 :·char(0)
I have some problems with parsing a response from a gprs modem.
this is the result when i send the command to my·modem:
SEROUT 0,Baud,[noparse][[/noparse]"AT+CPBR=2", 13] means: show·second phonebook entry
result: counter: char (ascii) see table below.
Now i'm trying to get the id (second place), the phonenumber (04 to 15) and the name (23 to 26) with this command:
SERIN 1,Baud,[noparse][[/noparse]WAIT("+CPBR:") , SKIP 1 , id , SKIP 2 , STR response\12, SKIP 7, STR name\4]
·············································· ·· |·············· |······································ ···· |
······································· ·ignore '32'······ ignore'44 and 34'············· ignore 7 bytes
And this seems not to work.
Any ideas why?
00 : ·· (32)·················
01 : 2 (50)
02 : ,· (44)
03 : "· (34)
04 : + (43)
05 : 3 (51)
06 : 2 (50)
07 : 4 (52)
08 : 9 (57)
09 : 8 (56)
10 : *·(number)
.
.
15 : * (number)
16 : " (34)
17 : , (44)
18 : 1 (49)
19 : 4 (52)
20 : 5 (53)
21 : , (44)
22 : " (34)
23 : I (73)
24 : l (108)
25 : s (115)
26 : e (101)
27 : " (34)
28 :· char(13)
29 :· char(10)
30 :· char(13)
31 :· char(10)
32 : O (79)
33 : K (80)
33 :·char(0)

Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I wa sworking in auto baud mode.
For some reason, the module switched to sleep mode. (dunno how that happend)
At 2400 baud, the module is working perfect with the stamp.
Here a sample, i'm sure it will help others too.
' {$STAMP BS2pe} ' {$PBASIC 2.5} Tx CON 0 Rx CON 1 id VAR Word MessageData VAR Byte(4) #SELECT $STAMP #CASE BS2, BS2E, BS2PE T1200 CON 813 T2400 CON 396 T4800 CON 188 T9600 CON 84 T19K2 CON 32 #CASE BS2SX, BS2P T1200 CON 2063 T2400 CON 1021 T4800 CON 500 T9600 CON 240 T19K2 CON 110 #CASE BS2PX T1200 CON 3313 T2400 CON 1646 T4800 CON 813 T9600 CON 396 T19K2 CON 188 #ENDSELECT Baud CON T2400 StartUp: DEBUG "STARTING UP...",CR PAUSE 1000 'set baudrate to 2400 SEROUT 0,Baud,[noparse][[/noparse]"AT+IPR=",34,"2400",34,13] GOSUB WaitOk PAUSE 300 'Select SMS message format (textmode) SEROUT 0,Baud,[noparse][[/noparse]"AT+CMGF=1",13] GOSUB WaitOk 'enable error result code with verbose (string) values SEROUT 0,Baud,[noparse][[/noparse]"AT+CMEE=2",13] GOSUB WaitOk 'echoes characters received from the TE. SEROUT 0,Baud,[noparse][[/noparse]"ATE1",13] GOSUB WaitOk 'Calling line identification presentation SEROUT 0,Baud,[noparse][[/noparse]"AT+CLIP=1",13] GOSUB WaitOk 'enable text mode SEROUT 0,Baud,[noparse][[/noparse]"AT&D0",13] GOSUB WaitOk ' First create some phonebook entries GOSUB CreatePBEntry Main: ' call the first phonebook entry ' get the id and name from the pb SEROUT 0,Baud,[noparse][[/noparse]"AT+CPBR=1",13] SERIN 1,Baud,[noparse][[/noparse]WAIT ("+CPBR:"), WAIT(32), id,WAIT(44,34), SKIP 19, STR MessageData\4\34, WAIT ("OK")] 'WAIT(32) => 32 is not the 'space' char: my response to get the pb entry = 32 bytes long ' DEBUG "Calling ",STR MessageData,CR 'DEBUG " ATD>",DEC id-48,";'",CR,CR SEROUT 0,Baud,[noparse][[/noparse]"ATD>",id,";",13] GOSUB WaitOk DEBUG " Ring... Ring...",CR PAUSE 25000 'and hangup the phone SEROUT 0,Baud,[noparse][[/noparse]"ATH",13] GOSUB WaitOk DEBUG "Call ended.",CR,cr END '-------------- Subroutines ------------------------------------------------ SendMessage: ' we are in text mode, so only 140 chars in message is allowed. ' in PDU mode, 160 chars SEROUT 0,Baud,[noparse][[/noparse]"AT+CMGS=", 34, "+32496******", 34, 13] SERIN 1,Baud,[noparse][[/noparse]WAIT ("> ")] SEROUT 0,Baud,[noparse][[/noparse]"Hello World! send sms with BS2!", 26] SERIN 1,Baud,[noparse][[/noparse]WAIT ("+CMGS:")] DEBUG "message send",CR RETURN CreatePBEntry: 'Delete all entries... SEROUT 0,Baud,[noparse][[/noparse]"AT+CPBW=1",13] GOSUB WaitOk pAUSE 300 SEROUT 0,Baud,[noparse][[/noparse]"AT+CPBW=2",13] GOSUB WaitOk PAUSE 300 'create new entry :CRIT for critical alarms, (4 chars long!) SEROUT 0,Baud,[noparse][[/noparse]"AT+CPBW=1,",34,"+32496******",34,",145,",34,"CRIT",34,13] GOSUB WaitOk PAUSE 300 'create new entry :WARN for warnings only (4 chars long!) SEROUT 0,Baud,[noparse][[/noparse]"AT+CPBW=2,",34,"+32498******",34,",145,",34,"WARN",34,13] GOSUB WaitOk PAUSE 300 return WaitOk: SERIN 1,Baud,[noparse][[/noparse]WAIT("OK")] RETURN