import sys import SER def runCommand arg while try stdout from the gsm

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import sys
import SER
def runCommand(arg):
while 1:
try:
#stdout from the gsm module is redirected to serial port, to my console (terminal) in linux
print 'InputCommand'
tChar = -1
tStr = ''
while tChar != 13:
tChar = -1
#reads one byte from the serial port, that is, it reads byte that i type in the terminal
tChar = SER.readbyte()
if tChar not in (13,-1):
tStr = tStr + chr(tChar)
exec(tStr)
except SyntaxError:
print 'syntax error'