I m working on code to send and receive messages from a GSM modem connected to my laptop via a serial port using python.
In my program I have created a serial object named phone.
Using phone I read and write into a list x which stores the AT commands,response and status report that I get during execution.
For example, consider the following to check the default operator of the Sim card in my GSM modem
AT+COPS? #AT command
+COPS: 0,0,"VOD" #Response
OK #Status
Now i need to parse information which i receive in x.
I was trying to use regex to parse the strings stored in x. However the problem is that it stores each character as a separate element in the list. So essentially there are no strings. How can i group characters which are present in the list into strings so i can apply regular expressions to parse my data and understand whats going on.
For the same command above, the data is stored in x as follows:
0 A
1 T
2 +
3 C
4 O
5 P
6 S
7 ?
8
9
10
11 +
12 C
13 O
14 P
15 S
16 :
17
18 0
19 ,
20 0
21 ,
22 "
23 V
24 O
25 D
26 "
27
28
29
30
31 O
32 K
33
34
Or is my approach just completely wrong?
Please help!