Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers.
Welcome to JeVois Tech Zone, where you can ask questions and receive answers from other members of the community.

Reading Jevois data into Python over USB

0 votes

Hi,

I am trying to read data using Serial-over-USB with PyUSB. (I would also happily accept any other answer that gets me this data in Python).

For my tests, I'm using the AR demo, which gives output of the type "T2 x y", (i.e., "T2 432 -234"). I am trying to get this string into Python so I can manipulate it there.

Using screen and connecting directly to the Jevois, I do see output in that format.

However, when I connect using PyUSB, I get a long string of numbers. 

Example: [0, 0, 110, 192, 0, 128, 43, 0, 117, 192, 15, 65, 64, 31, 48, 206, 64, 245, 66, 192, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 117, 192, 15, 65, 0, 0, 0, 0, 164, 190, 66, 192, 112, 190, 66, 192, 136, 5, 7, 192, 88, 130, 36, 192, 0, 0, 0, 0, 248, 35, 5]

Specific questions:

  • how many bytes should I read?
  • how do I translate the bytes into a string that looks like "T2 432 -234"?
Thanks,
Miriam
asked May 31 in User questions by miriam (220 points)

2 Answers

0 votes
 
Best answer
Thanks for asking! We just posted a tutorial for that:

http://jevois.org/tutorials/UserParseSerial.html

This should provide you with a start which you can modify for your own use. Also see http://jevois.org/tutorials/UserColorTracking.html for Python code that sends commands to JeVois.
answered Jun 5 by JeVois (23,960 points)
selected Jun 5 by miriam
This is great, thanks! I have it mostly working!

The only small issue I'm having is that I can't get 'setpar serstyle Normal' to stick when I put it in initscript.config. The other things I put there do work.

setpar serout USB
setmapping2 YUYV 320 240 30.0 JeVois DemoArUco
streamon

I can run 'setpar serstyle Normal' in the serial terminal and that works.
0 votes
Simple answer - try using readline instead of read.

line = ser.readline()
answered Jun 5 by PeterQuinn (250 points)
...