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
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$1 Answer
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 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