Hi
I am just trying to analyze (parse) data from the serial port (I have
connected GPS receiver to the ttyS0, so I can read ASCII characters in
the CSV form on the serial port 1).
I am doing this just to understand how Python works (yes, you can call
me Python/Linux newbie :)
My environment is Fedora Core 4, Python 2.4.1
CSV alone (to read CSV data from the file) and py-serial alone (to
read data from the serial port) are working flawlessly.
Even I was trying to google through this group and through the
Internet, I am not able to read (and parse) CSV data directly from the
serial port.
data from my serial port (using py-serial) I am getting this way:
[color=blue][color=green][color=darkred]
>>> import serial
>>> s = serial.Serial(p ort=0,baudrate= 4800, timeout=20)
>>> s.readline()[/color][/color][/color]
'$GPRMC,101236. 331,A,5026.1018 ,N,01521.6653,E ,0.0,328.1,2308 05,,*09\r\n'
my next intention was to do something like this:
import csv
r = csv.reader(s.re adline())
for currentline in r:
if currentline[0] == '$GPRMC':
print currentline[2]
print currentline[4]
but it does not work
Thanks for your comments
Petr Jakes
I am just trying to analyze (parse) data from the serial port (I have
connected GPS receiver to the ttyS0, so I can read ASCII characters in
the CSV form on the serial port 1).
I am doing this just to understand how Python works (yes, you can call
me Python/Linux newbie :)
My environment is Fedora Core 4, Python 2.4.1
CSV alone (to read CSV data from the file) and py-serial alone (to
read data from the serial port) are working flawlessly.
Even I was trying to google through this group and through the
Internet, I am not able to read (and parse) CSV data directly from the
serial port.
data from my serial port (using py-serial) I am getting this way:
[color=blue][color=green][color=darkred]
>>> import serial
>>> s = serial.Serial(p ort=0,baudrate= 4800, timeout=20)
>>> s.readline()[/color][/color][/color]
'$GPRMC,101236. 331,A,5026.1018 ,N,01521.6653,E ,0.0,328.1,2308 05,,*09\r\n'
my next intention was to do something like this:
import csv
r = csv.reader(s.re adline())
for currentline in r:
if currentline[0] == '$GPRMC':
print currentline[2]
print currentline[4]
but it does not work
Thanks for your comments
Petr Jakes
Comment