I'm running a python program. When it get's to these lines:
f = open("/dev/bus/usb/007/005", "r")
x = fcntl.ioctl(f.fileno(), 0x84005001, '\x00' * 256)
It fails saying:
IOError: [Errno 1] Operation not permitted
What could be causing this problem?
views:
82answers:
2
+1
A:
file system permissions?
what does ls -l /dev/bus/usb/007/005 say?
does cat /dev/bus/usb/007/005 work or does it report the same error?
plaisthos
2010-04-24 20:35:07
output of first is:`crw-rw-rw- 1 root lp 189, 772 24.04.2010 15:58 /dev/bus/usb/007/00`the cat command prints some weird chars to the terminal.
eyecreate
2010-04-24 20:42:09
Also, running as root outputs the same thing.
eyecreate
2010-04-24 20:48:25
then probably the ioctl is failing. I have no deeper knowledge of usb devices and ioctls.The ioctl you are trying to do could be - only allowed by root - wrong magic number - only works on files opened r/wSorry I can only guess
plaisthos
2010-04-24 20:50:02
A:
The third argument to fcntl.ioctl
, as documented here, should be either a 1024-byte string (not just 256), or, better, a possibly even-larger writeable buffer -- the underlying object could be an array.array of bytes. Unfortunately you need to know in advance how much space the result will need, but you can play it safe with a few KB (that ioctl seems to be the "get device id" code, but I'm not sure what the max result length could be).
Alex Martelli
2010-04-24 22:12:50