443,660 Members | 1,100 Online
Need help? Post your question and get tips & solutions from a community of 443,660 IT Pros & Developers. It's quick & easy.

# serial port digit-by-digit

 P: 2 I was writing a program calculating angles. There is a horizontal and a vertical angle and when I want the serial port to read both, it can give the horizontal digit by digit and the vertical all at once. For example it gives something like: h2 h2.60 h2.6029 and it will occasionally give the vertical coordinates, but it works fine for just the verticals. I have tried both readline() and readlines() and they give similar results. I haven't seen anything like this discussed on the Internet so far Here is part of my code: Expand|Select|Wrap|Line Numbers #Calculate horizontal angle     theta=atan2(airplane.estimate.y,airplane.estimate.x+.01)     T=str(theta)     #Calculate vertical angle, accounting for possibility of singularity     c=sqrt((airplane.estimate.y)**2+(airplane.estimate.x)**2+.01)     phi=atan2(airplane.estimate.z,c)     P=str(phi)+"\n"     antenna.axis=vector(cos(theta),sin(theta),sin(phi))*300     #Send to serial port       ser.write("h")     ser.write(T)     ser.write("v")     ser.write(P)     ser.readline()     print ser.readline()     x=x+.01 It works the best with timeout=0, because the VPython works with timeout>0, but no coordinates show --Michael May 31 '07 #1