Can Pyserial work with hidden devices?

I am trying to access a USB device that appears in /dev/ as hidraw4 .

I have a communication interface specification (based on RS232 serial port), but I can’t even get a connection with pyserial to work:

The code:

 import serial ser = serial.Serial(port='/dev/hidraw4') 

Error:

 serial.serialutil.SerialException: Could not configure port: (22, 'Invalid argument') 

I really don't understand what is the difference between the hidraw and tty files I can find in /dev/ . Can Pyserial connect to such devices (and if not, is there a workaround)?

+5
source share
1 answer

After a lot of research, it seems that no , it is impossible to get Pyserial working with hidraw devices. I can recommend the following two ways to solve the problem:

  • Use pyusb
  • Write your own USB driver (kernel space) that processes the device, and write an API to communicate with the driver
0
source

Source: https://habr.com/ru/post/1214056/


All Articles