TypeError when trying to open /dev/hidraw0 from python script
Question:
I’m trying to read some data from a USB HID device with some basic python code, on a Raspberry Pi, but keep getting the following error:
Traceback (most recent call last):
File "gnome1.py", line 2, in <module>
fd = open("/dev/hidraw0", os.O_RDWR|os.O_NONBLOCK)
TypeError: file() argument 2 must be string, not int
This is the Python code:
import os, sys
fd = open("/dev/hidraw0", os.O_RDWR|os.O_NONBLOCK)
os.write(fd, "QPIxBExACr")
os.read(fd, 512)
Can anyone help with this, please?
Answers:
fd = os.open(“/dev/hidraw0”, os.O_RDWR|os.O_NONBLOCK)
I’m trying to read some data from a USB HID device with some basic python code, on a Raspberry Pi, but keep getting the following error:
Traceback (most recent call last):
File "gnome1.py", line 2, in <module>
fd = open("/dev/hidraw0", os.O_RDWR|os.O_NONBLOCK)
TypeError: file() argument 2 must be string, not int
This is the Python code:
import os, sys
fd = open("/dev/hidraw0", os.O_RDWR|os.O_NONBLOCK)
os.write(fd, "QPIxBExACr")
os.read(fd, 512)
Can anyone help with this, please?
fd = os.open(“/dev/hidraw0”, os.O_RDWR|os.O_NONBLOCK)