After going back and reading everybody's suggestions, I finally
got a simple, efficient solution. As was pointed out to me in
several posts, I needed to use readline rather than read. That's
obvious to me now ... but isn't everything obvious once you
understand it :)
Anyway, I am posting my code
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 do the
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*
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 well.
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
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 016 240\r\n)
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) separated
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 issue.
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. Serial
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
those
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 issue.
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 the
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 grante
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 data. Serial
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
['39',
I want to thank everybody who tried to help me, and also to post
my solution, even though I dont think it is a very good one.
Many of you correctly guessed that there was an \r included
with the packet from the CUMcam, and you were correct. The
actual format of the packet is: M xxx xxx xxx
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
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
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 that is what has
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 xxx xxx xxx
Here is the
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 xxx
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
xxx xxx
22 matches
Mail list logo