I'm trying to send some data from Python 3.5 program on Windows 10 PC to TM4C microcontroller over USB and I'm using PyUSB for that.
The issue is whenever byte value exceeds 127 (0x7f) PyUSB is adds one extra byte before that byte and sometimes changes original value too. Here is the section of code I'm using to send data
def send_data(data): # data is list of integers
message = ''.join(chr(i) for i in data)
TivaC.epOut.write(message) #TiVaC is USB object
Some of the data packets are as follows:
sending ..0x66 0x12 0x0 0x0 0x0 0x6
Receiving 0x66 0x12 0x0 0x0 0x0 0x6
New Message
sending ..0x66 0x12 0x0 0x7f 0x0 0x6
Receiving 0x66 0x12 0x0 0x7f 0x0 0x6
New Message
sending ..0x66 0x12 0x0 0x80 0x0 0x6
Receiving 0x66 0x12 0x0 0xc2 0x80 0x0 0x6
Corrupt Packet
sending ..0x66 0x12 0x0 0xbf 0x0 0x6
Receiving 0x66 0x12 0x0 0xc2 0xbf 0x0 0x6
Corrupt Packet
sending ..0x66 0x12 0x0 0xc0 0x0 0x6
Receiving 0x66 0x12 0x0 0xc3 0x80 0x0 0x6
Corrupt Packet
sending ..0x66 0x12 0x1 0xf4 0x0 0x6
Receiving 0x66 0x12 0x1 0xc3 0xb4 0x0 0x6
Corrupt Packet
sending ..0x66 0x12 0x3 0xe8 0x0 0x6
Receiving 0x66 0x12 0x3 0xc3 0xa8 0x0 0x6
Corrupt Packet
The problem is only in the sending from PC to microcontroller. Microcontroller always sends all bytes correctly. I have checked it.