Re: [Tutor] Convert string to bytes

2014-12-31 Thread shweta kaushik
Hi Alan, Thank you.. I also did the same thing and its working... but i dint use this. I just did this and it is similar to what you said. >>> s = '0xFE, 0x01, 0x01, 0x22, 0xFE, 0x02' >>> packet = eval(s) (254, 1, 1, 34, 254, 2) >>> this is tuple, which my microcontroller is able to recognize an

Re: [Tutor] Convert string to bytes

2014-12-31 Thread Alan Gauld
On 31/12/14 18:03, shweta kaushik wrote: I also did the same thing and its working... but i dint use this. I just did this and it is similar to what you said. >>> s = '0xFE, 0x01, 0x01, 0x22, 0xFE, 0x02' >>> packet = eval(s) (254, 1, 1, 34, 254, 2) >>> this is tuple, which my microcontroller is

Re: [Tutor] Convert string to bytes

2014-12-31 Thread Alan Gauld
On 31/12/14 10:08, shweta kaushik wrote: I have one message packet in form of string s = '0xFE, 0x01, 0x01, 0x22, 0xFE, 0x02'. I have to send this data to MSP430 microcontroller, but it is not taking data if it is string. If I am passing this as hardcoded value s1 = 0xFE, 0x01, 0x01, 0x22, 0xFE,

Re: [Tutor] Convert string to bytes

2014-12-31 Thread WolfRage
I wrote a program to help me break out hex strings awhile ago. It was written to communicate with a Atmega 168. This is written for Python 3. Here is a snippet, see if this helps you. s4 = "28 40 7A 7C 05 00 00 34" hex_array = bytearray.fromhex(s4) print(s4) print(list(hex_array)) print(hex_arr