In my program, my Raspberry receives a call for a GSM module and for the serial receipt
RING
+CLIP: "633555999",161,"",0,"",0
every time it gives a tone (I've invented the number). What I need is that of all this string that sends me, separate the word RING to detect when they call me and then separate the phone number to send an SMS later. I leave my program:
import serial
import time
from curses import ascii
sSerie = serial.Serial('/dev/ttyS0',9600)
while True:
try:
llamando1 = sSerie.readline()
a,b= llamando1.split("+")
print a
if a == "RING":
num = sSerie.readline()
morralla, numero, morralla2 = num.split('"',2)
sSerie.write('ATH\r\n')
print 'numero que te ha llamado =' + str(numero)
except KeyboardInterrupt:
quit()
With this program I can not compare the variable a with the RING and I get this:
File "testllamada.py", line 8, in <module>
a,b = llamando1.split(" ")
ValueError: need more than 1 value to unpack
If I only put a
instead of a,b
if it separates me but with the print a
I get something similar to this:
[\n\r]
[RING\n\r]
[\n\r]
[( ,) CLIP: "633555999",161,"",0,"",0\n\r]
And I do not know how to take only the second line. If someone can help me, I will be very grateful.