Re: Parsing data from pyserial



On Sun, 03 Dec 2006 18:44:07 -0000, Grant Edwards
<grante@xxxxxxxx> wrote:

On 2006-12-03, Si Ballenger <shb*NO*SPAM*@comporium.net> wrote:

In my dealing with serial gizmos I have to put a delay between
the request sent to the gizmo and the reading of the serial input
buffer for returned data. Serial ports and gizmos need some time
to do their thing.

I doubt that's the issue. He's reading with a 1-second timeout
value.

I would think a time delay would be needed between the below two
lines in the code if he expects to get a useable data string back
from the gizmo for the command sent to it.

ser.write("TC 016 240 100 240 016 240\r\n")
reading = ser.read(40)

No. A delay isn't needed as long as the device responds within
1 second. The read() call will wait up to 1 second for the
first byte of the response.

Per what was posted (below), it appears that the the appropriate
data is being received. It may be possible that the cam may be
sending in a mode that is not in alignment with the binary
transmission mode of the serial port. As a test I'd jumper
between the Tx and Rx pin on the serial port and then send out
the "M" line being received, then see if it will parse as
expected.

Here is an example output:

M 37 79 3 4 59 124 86 25
['59', '123', '87', '25', 'M', '37', '79', '3', '4', '59',
'124', '86', '25', 'M
']
M 38 77 3 2 59 124 86 25
['39', '85', '26', 'M', '38', '77', '3', '2', '59', '124', '86',
'25', 'M', '38'
, '7']
.



Relevant Pages

  • Re: Serial port :bytesAvailable
    ... I am reading binary data from a serial port (it is actually ... have no problem reading data, I am reading data from an eye ... input buffer, for this I am using the bytesAvailable function. ...
    (comp.soft-sys.matlab)
  • Re: Serial Port interfacing
    ... > I am having a problem reading from a serial port, first of all I have now ... resorted to using the MSComm ActiveX control on my Windows Forms to provide ... me with the interface to my serial port. ... my Card reader up and I plug it in and I swipe my transponder card the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: writing serial port data to the gzip file
    ... Petr Jakes wrote: ... (expect reading from serial port is 100% not a problem) ... I was reading in the doc: ... already implements iterator. ...
    (comp.lang.python)
  • Re: Parsing data from pyserial
    ... the request sent to the gizmo and the reading of the serial input ... buffer for returned data. ... He's reading with a 1-second timeout ... from the gizmo for the command sent to it. ...
    (comp.lang.python)
  • Re: Pylab and pyserial plot in real time
    ... Basically the code was supposed to get the values from the serial port, ... more appropriate for the above mentioned task than pylab?? ... > What do you mean when you say it's in ASCII format? ... > problem is with the serial reading or with the plotting. ...
    (comp.lang.python)