Leostick ASCii codes

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
Post Reply
ron_jeff
Posts: 2
Joined: Fri May 03, 2013 3:49 am

Leostick ASCii codes

Post by ron_jeff » Fri May 03, 2013 3:58 am

Hi All

I had recently purchased a Leostick for use in one of my projects in which I am using python to send serial data to the leostick, primarily using ascii codes (ie: Python sends an int number as a char value and leostick recieves the byte as char and converts back to int). This wasnt working and I have figured out by printing out the ascii codes for the leostick and the ascii that they seem to use two different ascii code tables. I was of the understanding that ASCii was a universal standard.
Am I correct in my understanding, am I missing something?

Any help in helping me to understand this would be much appreciated.

Regards
Byron

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Leostick ASCii codes

Post by angusgr » Fri May 03, 2013 4:51 am

Hi Byron,

ASCII is a universal standard but there's lots of scope for things to get interpreted as something other than ASCII. :)

Are you using Python 2.x or Python 3.x?

By "int number as a char value", you mean as a string representing the number? ie In Python you're doing something like ser.write(str(i)), and then on the LeoStick side calling read() repeatedly and then using something like sscanf()?

If you post some code snippets then it may be easier to see what's going on.

Cheers,

- Angus

ron_jeff
Posts: 2
Joined: Fri May 03, 2013 3:49 am

Re: Leostick ASCii codes

Post by ron_jeff » Fri May 03, 2013 5:48 am

Thanks Angus

I am using Python 2.7. I am basing my project on this (http://teamprincipia.wordpress.com/2008 ... o-control/) and basically I am trying to pass an joystick angle as an int value, converting to char in python, sending it to leostick over serial and then having the leostick convert it back to int which from there I will set the angle of a servo.
I am not at home at the moment so I cannot post my actual code, which is really simple for debugging purposes. When I send the ascii representative of the int value in the arduino terminal, it works great, just not from python.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Leostick ASCii codes

Post by angusgr » Tue May 14, 2013 1:02 am

Hi Ron,

Please do post the sample Python code you mentioned if you're still having problems.

- Angus

Post Reply