libusb无法打开USB设备,权限是。 NetBeans / Ubuntu [英] libusb cannot open USB device, permission isse. NetBeans/Ubuntu

查看:4335
本文介绍了libusb无法打开USB设备,权限是。 NetBeans / Ubuntu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu 12.04上基于libusb-1.0在NetBeans中编写一个C / C ++应用程序。
我可以从USB设备获取基本信息(例如,接口描述),但我无法打开设备。
libusb_open函数给出错误:

I'm writing a C/C++ application in NetBeans based on libusb-1.0 on Ubuntu 12.04. I can get basic information from the USB device (for example, the interface description) but I am not able to open the device. The function libusb_open gives me the error:

libusb:error [op_open] libusb couldn't open USB device /dev/bus/usb/002/003: Permission denied.
libusb:error [op_open] libusb requires write access to USB device nodes.

我明白我需要更改权限,但我不知道如何基本Linux用户)。谢谢!

I understand that I need to change the permissions but I don't know how (I am a very basic Linux-user). Thank you!

推荐答案

你可以在root用户模式下运行你的应用程序并摆脱权限
问题。但是,您应该注意在
root用户中运行程序的后果,在完全理解基于UNIX的系统上的用户/组权限
之前不应该这样做。但是如果它是你的测试机,我想你可以做以下
(程序名./a.out):

Well you can run your application in root user mode and get rid with the permission issue. However you should be aware about the consequences of running the program in root user and should not be do until you fully understand the user/group permission on UNIX based system. However if it is your test machine, i think you can do the following(for program name ./a.out):


  1. 打开终端

  2. 转到您的程序可执行文件所在的目录(检查您的netbeans是否创建项目并输入cdcompletepath)。

  3. sudo ./a.out

  4. 现在命令提示符要求输入root密码

  1. Open the terminal
  2. Go to the directory where your program executable is present(check your netbeans creates the project and type cd "completepath).
  3. sudo ./a.out
  4. Now command prompt would ask to enter root password

但是,如果你想为特定的用户提供/改变读/写/执行的权限,你应该尝试了解 chmod 命令,您必须将权限更改为目录(/ dev / bus / usb / 002 /)和驻留在此目录下的任何特定文件,希望这些信息是有用的。

However if you want to provide/change the permission of read/write/execute for a particular user you should try to understand about chmod command. You would have to change the permission to directory(/dev/bus/usb/002/) and any particular file residing under this directory. Hope this information would be useful.

这篇关于libusb无法打开USB设备,权限是。 NetBeans / Ubuntu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆