Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
libusb:C+中出现错误[op_open]getcap失败+;在Linux上 我在Linux上遇到了C++中的代码< > ListBubOnt/Eng> >(在RasBuriPi上运行,但使用ExigEL虚拟化到x86)。_C++_Linux_Raspberry Pi_Libusb - Fatal编程技术网

libusb:C+中出现错误[op_open]getcap失败+;在Linux上 我在Linux上遇到了C++中的代码< > ListBubOnt/Eng> >(在RasBuriPi上运行,但使用ExigEL虚拟化到x86)。

libusb:C+中出现错误[op_open]getcap失败+;在Linux上 我在Linux上遇到了C++中的代码< > ListBubOnt/Eng> >(在RasBuriPi上运行,但使用ExigEL虚拟化到x86)。,c++,linux,raspberry-pi,libusb,C++,Linux,Raspberry Pi,Libusb,我可以使用libusb\u get\u device\u list找到一个设备,但使用libusb\u open将设备转换为设备处理程序似乎会导致问题,即使它返回0(成功),但没有其他命令起作用。它给了我一个错误: libusb: error [op_open] getcap failed (22) 更新 稍微挖掘一下就发现以下命令正在产生错误(在libusb中): 其中,IOCTL\U USBFS\U GET\U功能是\U IOR('U',26,\uuuuu32)。挖掘发现来自ioctl的e

我可以使用
libusb\u get\u device\u list
找到一个设备,但使用
libusb\u open
将设备转换为设备处理程序似乎会导致问题,即使它返回0(成功),但没有其他命令起作用。它给了我一个错误:

libusb: error [op_open] getcap failed (22)
更新

稍微挖掘一下就发现以下命令正在产生错误(在libusb中):


其中,
IOCTL\U USBFS\U GET\U功能
\U IOR('U',26,\uuuuu32)
。挖掘发现来自
ioctl
error 22
是无效参数。我仍在尝试取消点击,但非常感谢您的帮助。

您的linux/libusb版本是什么?您可以发布完整的可运行示例吗?代码:使用g++-o test test.cpp-Wall-lusb-1.0构建,Linux是4.4.38-v7+Debian。libusb是1.0.19-1。希望这有帮助!编辑:第95行我的第一个想法是检查所使用的Linux内核版本是否支持
IOCTL\u USBFS\u GET\u功能
。根据linux-headers-4.4.38-v7+/include/uapi/linux/usbdevice_fs.h中的
usr/src/linux-headers-4.4.38-v7+-2_armhf.deb,支持ioctl。我能想到的关于
ioctl()
返回
EINVAL
(即-22)的第二个最常见原因是用户空间应用程序和Linux内核之间的32位/64位不匹配。这就很好地解释了。你有访问USB设备的权限吗?从根目录运行时调用是否成功?这将为您指明正确的方向,因为如果它在根目录下运行,您需要授予您的帐户访问USB端口的能力。hpriv->fd是否有效?
r = ioctl(hpriv->fd, IOCTL_USBFS_GET_CAPABILITIES, &hpriv->caps);