2

Is there any posibility to read from virtual serial ports without mentioned error?

I'm trying to reach data sent from symbol/zebra barcode scanner li4278. Device is working in simple com port emulation mode and it's under /dev/usb/hiddev0 as serial port.

I'm sure that emulation works fine because CuteCom can read from it, and also this simple pyton script works too:

defaultDevice = '/dev/usb/hiddev0'

inDev = open(defaultDevice, 'rb')

while True:
 inBytes = inDev.read(1)
 for x in inBytes:
  print(x)

But anytime I'm trying to read it using pyserial with such a minimal code like this:

with serial.Serial('/dev/usb/hiddev0', timeout=1) as ser:
    x = ser.read()
    print(x)

the same error occurs: termios.error: (22, 'Invalid argument'). It's like it can't read from virtual serial ports.

And no, setting args to rtscts=True, dsrdtr=True doesn't work.

I have the same '22, invalid argument' error.

Linux Mint 18, 64 bit, Python 3.7, pyserial 3.4.

Anyone knows what's the thing?

  • How about baud rate? Also try `read_all` instead of `read` – Michael May 10 '19 at 17:30
  • Thanks, but it doesn't even go to the read() line. It breaks on first line, when it's trying to access hidraw. Default b-rate is the same as my device's b-rate. But I solve it using dev = open('dev/hidraw0) / dev.read() and data can be read this way. Nevertheless it wold be nice to use pyserial instead of reading directly from hidraw. – Chaallimack May 13 '19 at 08:33

0 Answers0