0

I have a code, which sending a message to usb device. It returns me the correct answer on Windows, but on ubuntu it gives wrong result. Why is that?

import hid
import time

try:
    print("Opening the device")

    h = hid.device()
    h.open(0x0483, 0x5750)  # TREZOR VendorID/ProductID

    print("Manufacturer: %s" % h.get_manufacturer_string())
    print("Product: %s" % h.get_product_string())
    print("Serial No: %s" % h.get_serial_number_string())

    print("Write the data")

    time.sleep(0.05)

    h.write(([1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))
    d = h.read(19)
    print(d)


except IOError as ex:
    print(ex)
    print("You probably don't have the hard-coded device.")
    print("Update the h.open() line in this script with the one")
    print("from the enumeration list output above and try again.")

print("Done") 

result on Windows:

Opening the device
Manufacturer: STMicroelectronics
Product: STM32 Custom Human interface
Serial No: 00000000001A
Write the data
[2, 1, 255, 0, 0, 1, 0, 0, 0, 0, 0, 2, 1, 2, 0, 1, 0, 0, 1]
Done

result on Ubuntu:

sudo python3 main.py

Opening the device
Manufacturer: STMicroelectronics
Product: STM32 Custom Human interface
Serial No: 00000000001A
Write the data
Read the data
[2, 1]
Done
qwerty
  • 1

0 Answers0