Closed CrazyIvan359 closed 3 years ago
Thanks, merged in 69bd36e. In addition to a few minor modifications, I decided to drop the checks in the sysfs implementation. I think it's a bit too much to open and read the direction file on every call to write()
or poll()
to check that it's the right direction. Ideally, that state would be cached, like it is in the character device implementation. But the sysfs implementation has avoided caching to be robust to external modifications (e.g. if another process modifies the GPIO in /sys).
I decided to drop the checks in the sysfs implementation. I think it's a bit too much to open and read the direction file on every call
Yeah that's quite the performance hit if you are doing a lot of writes in a short time, I did not see that the sysfs class was doing that.
The cdev and sysfs interfaces will throw errors (
1: Operation not permitted
or22: Invalid argument
for me) when attempting to write to a pin opened as an input. This PR improves clarity by catching attempts to write to a pin opened for input and raises aGPIOError
with a clearer message. Similar checks also added to thepoll
andread_event
methods.Closes #43