Read USB parameters of connected device

Moderators: mdrjr, odroid

Read USB parameters of connected device

Unread postby RWAP » Sat Jun 09, 2018 10:21 pm

I use the following python script to get the device parameters for a connected USB printer on the Odroid C1+

Code: Select all
usbPrinterFile = '/dev/usb/lp0'
fd = open(usbPrinterFile)

# Calculation of IOCTL function 0x84005001 (to get device ID string):
# len = 1024
# IOCNR_GET_DEVICE_ID = 1
# LPIOC_GET_DEVICE_ID(len) = _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
# _IOC(), _IOC_READ as defined in /usr/include/asm/ioctl.h

buffer = '\x00' * 1024
iPNPstring = fcntl.ioctl(fd, 0x84005001, buffer)
fd.close()


On the Odroid C2, I get an error thown by the fcntl.ioctl call:
Code: Select all
IOError: [Errno 5] Input/output error


I have tried running the program as root, but that makes no difference.

I am using the Kardkernel on both, although not the same linux instance, so why does this cause an error on the C2, but not on the C1+
RWAP
 
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1

Re: Read USB parameters of connected device

Unread postby tobetter » Mon Jun 11, 2018 9:48 am

I am assuming two problems could cause the error. 1) USB driver for a printer is not installed so IOCTL call is failed with fd, E) driver is not able to handel the ioctl parameter 84005001.

Can you post what information is returned whenever your code works properly? Maybe there would be a way to get the same instead of calling ioctl.
tobetter
 
Posts: 2240
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Read USB parameters of connected device

Unread postby RWAP » Mon Jun 11, 2018 4:02 pm

Please remember that the same setup works fine on the C1 and C1+ - the same printer is used and installed.

On the C1/C1+ the ioctl call returns the device ID of the printer, such as "BTP-R580(U)". This is available through lsusb -v, but is difficult to extract properly.

It just seems peculiar that the same setup on the C2 does not work...
RWAP
 
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1

Re: Read USB parameters of connected device

Unread postby tobetter » Mon Jun 11, 2018 4:27 pm

Can you check /sys/class/printer/lp0 if you can find the information on your printer?

I guess the kernel driver for USBLP should be checked if the ioctl() is compatible with ARM32 and ARM64.
tobetter
 
Posts: 2240
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Read USB parameters of connected device

Unread postby RWAP » Sat Jun 30, 2018 5:35 am

OK - this is weird: Unfortunately the /sys/class/printer/lp0 file is missing on our system, although /dev/usb/lp0 is present

lsusb -v reports the correct information:

Code: Select all
Bus 001 Device 004: ID 04b8:0202 Seiko Epson Corp. Receipt Printer M129C/TM-T70
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x04b8 Seiko Epson Corp.
  idProduct          0x0202 Receipt Printer M129C/TM-T70
  bcdDevice            1.00
  iManufacturer           1 EPSON
  iProduct                2 TM-T20II
  iSerial                 3 544338590553630000
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol      2
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0003
  Self Powered
  Remote Wakeup Enabled

RWAP
 
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1


Return to Issues

Who is online

Users browsing this forum: No registered users and 0 guests