S
Setia Budi
Hi fellows,
I am facing difficulties in order to send USB commands to an RFID reader.
This is the command reference of the device: https://github.com/mti-rfid/RFID_Explorer
I am working with the MTI RU-824 model.
The manufacturer of the device only provide a driver for Windows (using .Net), but we need to run the device on Linux. That's why I need to write few lines of code in Python as a new "driver".
I am using PyUSB for accessing the device, and this is few lines of my code:
============================================================================
import usb.core
import usb.util
import sys
VENDOR_ID = 0x24e9
PRODUCT_ID = 0x0824
device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
if device is None:
sys.exit("Could not find Id System Barcode Reader.")
else:
print 'Device detected'
device.set_configuration()
cfg = device.get_active_configuration()
interface_number = cfg[(0, 0)].bInterfaceNumber
alternate_setting = usb.control.get_interface(device, interface_number)
usb_interface = usb.util.find_descriptor(
cfg, bInterfaceNumber=interface_number,
bAlternateSetting=alternate_setting
)
endpoint_out = usb.util.find_descriptor(
usb_interface,
# match the first OUT endpoint
custom_match=lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_OUT
)
endpoint_in = usb.util.find_descriptor(
usb_interface,
# match the first IN endpoint
custom_match=lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_IN
)
endpoint_out.write('0x01')
print endpoint_in.read(len('0x01'), 1000)
=============================================================================
My question is on the last 2 lines.
I am using endpoint_out to send a command and endpoint_in to read data from the reader. Am I correct?
The problem is, when I run the code, there is an error message like this:
usb.core.USBError: [Errno 110] Operation timed out
Anyone can give a clue?
Thank you.
I am facing difficulties in order to send USB commands to an RFID reader.
This is the command reference of the device: https://github.com/mti-rfid/RFID_Explorer
I am working with the MTI RU-824 model.
The manufacturer of the device only provide a driver for Windows (using .Net), but we need to run the device on Linux. That's why I need to write few lines of code in Python as a new "driver".
I am using PyUSB for accessing the device, and this is few lines of my code:
============================================================================
import usb.core
import usb.util
import sys
VENDOR_ID = 0x24e9
PRODUCT_ID = 0x0824
device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
if device is None:
sys.exit("Could not find Id System Barcode Reader.")
else:
print 'Device detected'
device.set_configuration()
cfg = device.get_active_configuration()
interface_number = cfg[(0, 0)].bInterfaceNumber
alternate_setting = usb.control.get_interface(device, interface_number)
usb_interface = usb.util.find_descriptor(
cfg, bInterfaceNumber=interface_number,
bAlternateSetting=alternate_setting
)
endpoint_out = usb.util.find_descriptor(
usb_interface,
# match the first OUT endpoint
custom_match=lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_OUT
)
endpoint_in = usb.util.find_descriptor(
usb_interface,
# match the first IN endpoint
custom_match=lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_IN
)
endpoint_out.write('0x01')
print endpoint_in.read(len('0x01'), 1000)
=============================================================================
My question is on the last 2 lines.
I am using endpoint_out to send a command and endpoint_in to read data from the reader. Am I correct?
The problem is, when I run the code, there is an error message like this:
usb.core.USBError: [Errno 110] Operation timed out
Anyone can give a clue?
Thank you.