问题标签 [libusb-1.0]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
3438 浏览

android - libusb:无法在 Android 上获取配置描述符

connection.getFileDescriptor()我正在使用 libusb-compat 和 libusb-1.0调试在 Android 上打开设备(在 Android 代码和文件描述符中授予的权限),但出现错误:

我找不到 errno 13 libusb.h

带有我的调试输出(fprintf)的初始化代码(来自 libusb-compat)是:

更新:我越来越接近解决我的问题。我发现 op_get_config_descriptor (linux_usbfs.c) 使用设备路径来使用 open() 获取 fd,但它已经从 Android 连接接收到,应该使用。所以我不得不更改代码以将 fd 传递给 op_get_config_descriptor() 并将其重命名为 op_get_config_descriptor2():

现在的问题是找不到使用该 fd的USB设备(它通过 Unix 套接字传递给AVRDUDE,我检查它是否为正整数,所以我相信没关系): lseek(fd, DEVICE_DESC_LENGTH, SEEK_SET)返回负值

输出是:

我该如何解决这个问题?

0 投票
1 回答
1305 浏览

libusb - 如何检查内核驱动程序是否附加了 libusb-0.1?

在 libusb-1.0 中可以使用libusb_kernel_driver_active

如何使用 libusb-0.1 进行检查?

0 投票
0 回答
512 浏览

c++ - 支持 unicode 的 libusb c++ 字符串描述符

我想使用 libusb 来检索有关我的设备的信息。我可以读取每个描述符并打印这些描述符中关联的每个数字。但是我在弦上遇到了麻烦。如何使用 c++ 以一种好的方式管理字符串描述符?

我想实现一个像这样的简单功能:

它在内部检索与索引关联的字符串。设备句柄来自类的属性(函数是类成员)和静态分配 libusb_get_string_descriptor 的缓冲区,因为看到维度包含在 8 位字段中,长度必须最多为 256 个字符,不能是吗?

我怎样才能用这些东西来管理 unicode?有任何想法吗?使用 std::string 是否正确?

0 投票
0 回答
83 浏览

usb - 在 openSUSE-11.3 中修改内核空间函数

出于学习目的,我一直在研究 K-space USB 驱动程序。

据我研究了在 USB 驱动程序执行其例程期间包含的内核空间源文件,我发现announce_devices()该函数可以打印通过总线连接的所有 USB 设备的信息。

我插入了一个 USB 设备(一个BeagleBoard-xM,我在其中设置了产品 ID 和供应商 ID 以及其他描述符,并且所有这些都使用libusb代码在用户空间中进行了验证),启动了计算机。当我做 admesg时,我期待看到我的设备。但它没有出现。然后我运行libusb我编写的代码,它显示了设备。因此,我假设我的设备正在正常枚举。

问题 #1:如果 libusb 代码运行良好,那一定是我插入的模块出了问题,对吧?代码在下面共享。(这段代码被作为 Stack Overflow 问题的答案Programmatically getting the vendor ID, product ID of a USB device on a Linux platform I had back to write back to 1 月份,当时它运行良好)。那么我的司机工作正常吗?在实现上述代码后,我已经多次重建内核(对于许多动态模块)。

问题 #2:我可以修改 Kernel-Space 函数announce_devices()并在我的机器上重建内核并进行验证吗?

PS:已经制作了必要的夹杂物。

浏览了几乎所有必要的头文件后,我知道我应该(我上次也是)能够通过一个结构访问USBstruct usb_device{}设备的供应商 ID、产品 ID 和制造商详细信息:它有一个 member struct usb_device_descriptor{}。这个嵌套结构有idVendor, idProductandiManufacturer和一些其他成员。//************************************************

0 投票
1 回答
4928 浏览

linux - libusb_bulk_transfer() 读取在 USB 大容量存储设备上首次成功写入 libusb_bulk_transfer() 后挂起

我正在尝试在我的USB大容量存储设备上执行写入/读取 libusb_bulk_transfer()。但是在第一次成功的 libusb_bulk_transfer() 写入之后,我的程序只是挂起并且不执行 libusb_bulk_transfer() 读取。我观察到我的 USB 设备已分离。为什么我无法执行读取?

以下是我的代码片段:

0 投票
2 回答
2371 浏览

arm - 如何通过 USB 读取 swd 输出?

我正在尝试编写一个类似于 stmicro STM-STUDIO的应用程序,它通过 USB从设备( STM32Fx Discovery )上运行的嵌入式应用程序读取变量。如何读取来自开发板的输出(变量),最好是使用 C# 应用程序的应用程序?

0 投票
0 回答
1329 浏览

linux - Linking native hidapi and libusb-1.0 library in eclipse on Ubuntu

I am new to Ubuntu and searched on-line for two days, tried a lot of solutions but do not have any luck yet. If anyone can help with this, I will appreciate.

I wrote a program in Java with eclipse on Windows. My program makes use of Java hidapi library, which is a Java wrapper of the C version hidapi library (.dll). In eclipse, by adding the Java hidapi to the build path and setting the C hidapi as a native library, everything works just fine.

Now I want to do the same on Ubuntu. The same Java hidapi is used, which now will make use of the C version hidapi library for Linux (a .so file). When making the C version hidapi library for Linux, it turns out that I need another library called libusb-1.0 (which hidapi needs to deals with the low level communication). So I install libusb-1.0 (now I have a libusb-1.0.so file under /usr/lib/i386-linux-gnu), make the C version hidapi library for Linux. I have a small C program and I test it under bash, it works so I believe until this point everything, both libsub-1.0.so and C version hidapi library for Linux libhidapi-jni.so are installed/generated correctly, and when running the small C program the system is able to find the shared libusb-1.0.so library without explicitly mentioning where libsub-1.0 is (which makes sense because libusb-1.0 is installed in a place where the system loader will always search).

So I go to eclipse. I import the eclipse work space, add the Java hidapi to the build path (as I did in Windows), move the C version hidapi library for Linux (the .so file) into a folder called 'lib' (where the .dll version of native library also resides). And I set the native library to 'lib', by "build path" -> "configure build path" -> "libraries" tab -> "native library location". So till this point, the two native libraries are: libusb-1.0 under /usr/lib/i386-linux-gnu, and hidapi.so under 'wherever eclipse workspace is'/lib. Finally in the source code I add two lines:

System.loadLibrary("usb-1.0"); // Call this line A.

System.loadLibrary("hidapi-jni"); // Call this line B.

I run the program as a Java application. It reports "java.lang.UnsatisfiedLinkError: no usb-1.0 in java.library.path" at line A. So I guess the Java runtime is not able to find where libsub-1.0 is.

Just for clarification, I already did the following trials, none of them worked.

  1. Remain the two libraries where they are, add vm argument (Run -> Run Configuration -> Arguments -> VM arguments): -Djava.library.path="${workspace_loc:project_name}/lib; /usr/lib/i386-linux-gnu". It gives: "java.lang.UnsatisfiedLinkError: no usb-1.0 in java.library.path" at line A.
  2. Undo 1. Move libsub-1.0.so to 'wherever eclipse workspace is'/lib, so now the two .so files are together. Set .jar's native library location to this folder. It gives "java.lang.UnsatisfiedLinkError: blablabla: undefined symbol: libusb_control_transfer" at line B. So I think it founds the libusb library, however the symbol (which should be in libusb) is still unresolved. This is really weird.

Can anyone help me? Thanks in advance.

0 投票
1 回答
2816 浏览

c - libusb - Segmentation fault: 11

I've got a very basic, bare minimum libusb example going, which compiles, but the output produced by the following application:

is as follows:

The failure occurs on line 13:

device_count = libusb_get_device_list(context, &devices);

I'm running the above on Mac OS X 10.9, and have libusb version 1.0.9 installed via Homebrew.

Any idea what could be the problem?

0 投票
3 回答
10750 浏览

c - 无法在 Mac OS X 上使用 C + libusb 声明 USB 接口

我有一个使用 PIC32 微控制器构建的复合 USB + CDC 设备,我正在尝试连接到该设备并将一些数据从我的 Mac 发送到 CDC 数据接口端点。

我知道电路可以 100% 工作,因为设备注册为 HID 操纵杆,并且我可以使用 Zoc 终端在 /dev/tty.usbmodemfa132 上连接到设备。我可以使用Zoc发送命令,并通过闪烁电路上的一些 LED 来查看我的 MCU 对这些命令的响应。

我在 Mac OS X Mavericks 上运行它,但是几周前在 Mountain Lion 上我放弃了一个类似的例子也遇到了同样的问题。

我的代码如下所示:

我收到以下错误输出:

有没有办法可以从其他进程中释放 USB 设备,释放它以便我可以认领它?

有没有其他方法可以连接到 /dev/tty.usbmodemfa132 以向 USB 设备上的 CDC 接口发送和接收数据?

也许是 libusb 的替代品?

0 投票
0 回答
299 浏览

windows - 如何使用安装程序自动安装 libusbx 驱动程序以及应用程序?

我为设备编写了一个应用程序,并使用了libusbx库。我必须使用 Zadig 安装 WinUSB 驱动程序才能运行我的应用程序。现在,我正在使用Inno Setup安装程序部署我的应用程序。如何为 libusbx 库自动安装 WinUSB 驱动程序?