Read USB parameters of connected device

Moderators: odroid, mdrjr

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: 13
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: 2190
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: 13
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: 2190
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1


Return to Issues

Who is online

Users browsing this forum: No registered users and 3 guests