I am using a module called pyUSB version 1.6 and am trying to communicate with a sensor.
I have set up the connection and can read from the ROM on the sensor. The sensor, when connected, has a master/slave relationship so I need to send a message to the sensor to receive the data I need.
Now, the write
function can only accept a string or read-only buffer. I need to send the USB device the hexadecimal bytes 0xFE
, 0x04
, 0x00
, 0x03
, 0x00
, 0x01
, 0xD5
, 0xC5
.
I'm unsure how to encode that as a string or read-only buffer.
Here is how one calls the write method. This is the sample code they provide.
# write bytes (serial mode)
print h.write('Hello world!\r\n")
How would I transfer the hexadecimal bytes?