trc202's Avatar
trc202 2
1 Asked
0 Answered
0 Best
0
No one has voted on this question yet :(
1 year, 7 months ago via answers.hackaday.com

Splitting hex in python

I'm working on using python to do basic control of a roomba however, i've ran into a hiccup. The roomba SCI specs call for the hex value sent to the motors be broken up into two parts eg from hex 01F4 to 01 F4 and then changed into 1 244. How would I go about doing this in python? If you would like a better look at the roomba sci specs they are here www.irobot.com/images/consumer/hacker/Roomba_SCI_Spec_Manual.pdf
Tip for best answer: M$1.00
Separate topics with commas, or by pressing return. Use the delete or backspace key to edit or remove existing topics.

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$

What is Your Answer?

0
0
0

1 Answer

1
tmxod's Avatar
tmxod | 1 year, 7 months ago
1
Python Docs to the rescue: http://docs.python.org/library/struct.html
you can call struct.unpack() struct.unpack_from() if taking from a string containing multiple commands with the format string "=cc", which will return both items as a tuple that contains both numbers separatedly... After that, it's a matter of casting as needed for your interface.

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$

Report Abuse

Post Reply Cancel

Learn something new with our FREE educational apps!

Private lessons in the comfort of your own home. Get back in shape or finally pick up a guitar with our great experts guiding you the whole way!
Learn Guitar
Learn Hip Hop
Learn Pilates