Re: Parsing data from pyserial, an (inefficient) solution

2006-12-04 Thread Grant Edwards
On 2006-12-04, Giovanni Bajo <[EMAIL PROTECTED]> wrote: [...] >> This should result in complete packets (from the "M" to a "\r") > > Oh well. readline(eol="\r") will do that much better. Yup. Using readline() has been suggested several times. It sure seems like the obvious solution to me as w

Re: Parsing data from pyserial

2006-12-04 Thread Grant Edwards
On 2006-12-04, John Machin <[EMAIL PROTECTED]> wrote: > Try reading previous posts. The OP reported that to be returned from > the cam, based on print forty_bytes, not print repr(forty_bytes). I > think everybody (including possibly even the OP) is willing to believe > that the cam is *generating*

Re: Parsing data from pyserial, an (inefficient) solution

2006-12-04 Thread Giovanni Bajo
Dennis Lee Bieber wrote: > >> The really sad thing is that I get a perfectly constructed >> packet from the reading variable, and that gets butchered when I >> try to slice it up to pick out individual elements. Since >> pyserial doesn’t do anything to rearrange the data, then the >> CMUcam must d

Re: Parsing data from pyserial

2006-12-03 Thread John Machin
Si Ballenger wrote: > On 3 Dec 2006 17:33:59 -0800, "John Machin" > <[EMAIL PROTECTED]> wrote: > > >In any case, I wouldn't call that "the appropriate data is being > >received" -- looks like chunks missing to me. > > Well, below is the posted expected return data format from the > cam and below t

Re: Parsing data from pyserial, an (inefficient) solution

2006-12-03 Thread John Machin
Lone Wolf wrote: Your code has a problem when the first character of reading is 'M': you will miss the full packet and pick up a fragment. The length test that you are doing to reject the fragment is a kludge. If the average length of a packet is say 25, then you are throwing away 4% of all packet

Re: Parsing data from pyserial

2006-12-03 Thread Si Ballenger
On 3 Dec 2006 17:33:59 -0800, "John Machin" <[EMAIL PROTECTED]> wrote: >In any case, I wouldn't call that "the appropriate data is being >received" -- looks like chunks missing to me. Well, below is the posted expected return data format from the cam and below that is what has been reported to be

Re: Parsing data from pyserial

2006-12-03 Thread John Machin
Si Ballenger wrote: > > Per what was posted (below), it appears that the the appropriate > data is being received. [snip] > > 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

Re: Parsing data from pyserial

2006-12-03 Thread Si Ballenger
On Sun, 03 Dec 2006 18:44:07 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2006-12-03, Si Ballenger <[EMAIL PROTECTED]> 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

Re: Parsing data from pyserial

2006-12-03 Thread Grant Edwards
On 2006-12-03, John Machin <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > >> When something odd seems to be happening with strings, always >> print `whatever` rather than whatever >> > >:-) > > Unholy perlism, Batman! OK, make that "print repr(whatever)". :) -- Grant Edwards

Re: Parsing data from pyserial

2006-12-03 Thread Fredrik Lundh
Si Ballenger wrote: > 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) why's that? if t

Re: Parsing data from pyserial

2006-12-03 Thread Grant Edwards
On 2006-12-03, Si Ballenger <[EMAIL PROTECTED]> 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 t

Re: Parsing data from pyserial

2006-12-03 Thread John Machin
Grant Edwards wrote: > When something odd seems to be happening with strings, always > print `whatever` rather than whatever > :-) Unholy perlism, Batman! For the benefit of gentle readers who are newish and might not have seen the ` character in Python code outside a string literal, or for tho

Re: Parsing data from pyserial

2006-12-03 Thread Si Ballenger
On Sun, 03 Dec 2006 16:52:33 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2006-12-03, Si Ballenger <[EMAIL PROTECTED]> 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.

Re: Parsing data from pyserial

2006-12-03 Thread Grant Edwards
On 2006-12-03, Si Ballenger <[EMAIL PROTECTED]> 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 is

Re: Parsing data from pyserial

2006-12-03 Thread Si Ballenger
On Sat, 2 Dec 2006 23:02:06 -0500, Lone Wolf <[EMAIL PROTECTED]> wrote: >I'm trying to get data through my serial port from a CMUcam. >This gizmo tracks a color and returns a packet of data. The >packet has nine data points (well, really eight since the first >point is just a packet header) separa

Re: Parsing data from pyserial

2006-12-03 Thread Grant Edwards
On 2006-12-03, Lone Wolf <[EMAIL PROTECTED]> wrote: > import serial > > ser=serial.Serial('com1',baudrate=115200, bytesize=8, > parity='N', stopbits=1,xonxoff=0, timeout=1) > > ser.write("PM 1") #This sets the CMUcam to poll mode > > for i in range(0,100,1): > ser.write("TC 016 240 100 240 0

Re: Parsing data from pyserial

2006-12-03 Thread Giovanni Bajo
Lone Wolf wrote: > reading = ser.read(40) Simply try ser.readline() here, or maybe ser.readline(eol="\r"). -- Giovanni Bajo -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing data from pyserial

2006-12-02 Thread Hendrik van Rooyen
"Lone Wolf" <[EMAIL PROTECTED]> wrote: > I'm trying to get data through my serial port from a CMUcam. > This gizmo tracks a color and returns a packet of data. The > packet has nine data points (well, really eight since the first > point is just a packet header) separated by spaces as follows: M >

Re: Parsing data from pyserial

2006-12-02 Thread John Machin
Lone Wolf wrote: > I'm trying to get data through my serial port from a CMUcam. > This gizmo tracks a color and returns a packet of data. The > packet has nine data points (well, really eight since the first > point is just a packet header) separated by spaces as follows: M > xxx xxx xxx xxx xxx xx