Read from serial port

mmrasheed at gmail.com mmrasheed at gmail.com
Wed Aug 13 21:11:59 EDT 2008


Hi,
I am newbie in python. I am working on Telit GM862 GPS/GPRS module
which has python interpreter built in. But it seems this problem is
pretty much related to general python structure.

I need a promt/terminal when the device is connected to PC. If user
enters a command by serial port and press "Enter" then the data is
read by the device and work on the command. This is similar to
readline() function. Unfortunately there is no readline() function for
GM862 device. The following functions are available for serial port
data receive-

SER.read() - reads whole string at a time from buffer
SER.receive(timeout) - reads  if there is any input in the buffer
andwait for the input upto timeout
SER.receivebyte(timeout) - reads  if there is any byte sent in the
buffer and wait for the input upto timeout

Now, is this possible to build a readline() using the functions above?
Can I redirect the terminal or serial port data to receive it as a
whole string when entered "\n"?

Please advise me how can I solve this problem.

Thanks a lot.



More information about the Python-list mailing list