简体   繁体   English

不允许进行python操作(graphtecprint)

[英]python operation not permitted (graphtecprint)

I'm running a python program. 我正在运行python程序。 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 IOError:[错误1]不允许操作
What could be causing this problem? 是什么导致此问题?

file system permissions? 文件系统权限?

what does ls -l /dev/bus/usb/007/005 say? ls -l / dev / bus / usb / 007/005怎么说?

does cat /dev/bus/usb/007/005 work or does it report the same error? cat / dev / bus / usb / 007/005是否正常工作,或者报告相同的错误?

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. 的第三个参数fcntl.ioctl ,如记录在这里 ,应为1024字节的字符串(不只是256),或者,更好的,一个可能甚至更大尺寸可写缓冲器 -底层对象可以是array.array字节。 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). 不幸的是,您需要事先知道结果将需要多少空间,但是您可以安全地用几KB的空间(ioctl似乎是“获取设备ID”代码,但是我不确定最大结果长度是多少)可能)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM