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?

Asked By: SilverNodashi

||

Answers:

fd = os.open(“/dev/hidraw0”, os.O_RDWR|os.O_NONBLOCK)

Answered By: nikitto
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.