473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Parsing data from pyserial (final resolution)

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 on the (slim) chance that someone
new to python and interested in robotics might find it useful:

################################################## #######

# This program reads a serial port hookup up to a CMUcam1.
# It tracks the middle of a green object and provides a
confidence estimate

import serial

ser=serial.Serial('com1',baudrate=115200, bytesize=8,
parity='N', stopbits=1,xonxoff=0, timeout=1)

ser.write("TC 016 240 100 240 016 240\r\n") #This line orders
the CMUcam to track green

for i in range(0,100,1):
reading = ser.readline(eol="\r")
components = reading.split()
mx = int(components[1])
my = int(components[2])
confidence = int(components[8])
print mx, my, confidence
ser.close

################################################## ######

This code will read 5-6 frames per second, which should be
plenty for most vision processing applications.

Once again, I really want to thank those who took the time to
help me. The good news is that I learned something from all my
mistakes.

Happy Hunting

Wolf

________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
Dec 6 '06 #1
0 1520

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Cliff Roman | last post by:
I have a league for a game where we get exports after every session in HTML format It is broken down into 3 sections and each section has a Table with the results Right now I have to create 3...
9
by: Lisa | last post by:
I have a select statement that gives me the following results (for example) "test documentation/software product version document.doc" I need to parse the data to only grab everything between the...
6
by: supercomputer | last post by:
I am using this function to parse data I have stored in an array. This is what the array looks like: , , , , , , , , , , , , , , , , , , , , , , , ] This is the code to parse the array:
7
by: JMCN | last post by:
hello i'm trying to parse out some data from the below format. first of all, i import the text file into access97 table and the try to parse out.i have a code written but when i run it, it does...
5
by: LFM | last post by:
I have a table I'm importing from our SQL accounting database. The Employee Name is in one field. For the purpose of my needs, I need to extract the last name, first name and middle initial. ...
15
by: Lone Wolf | last post by:
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...
3
by: Lone Wolf | last post by:
I want to thank everybody who tried to help me, and also to post my solution, even though I don’t think it is a very good one. Many of you correctly guessed that there was an “\r” included with...
5
by: tennisfanatic | last post by:
Aloha! I have a data file (.dat) that has about 3000+ lines of data that has the format for the first few characters Position Field Name Length Description 01-14 Item # 9(14) ...
9
by: Jasper | last post by:
Hi, I have multiple data files which need parsing in realtime so high performance is *crucial*. I dont have a format definition, but from what I can see there is a hierarchy of data. Each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.