我对libusb有一个小问题。我想打开一个USB端口,但是找不到这个端口。 lsusb命令的结果:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 002: ID 0461:4e22 Primax Electronics, Ltd
Bus 001 Device 003: ID 046d:c326 Logitech, Inc.
Bus 001 Device 004: ID 080c:0300 Datalogic S.p.A. Gryphon D120 Barcode Scanner
所以在我的main.c中我尝试打开一个USB端口:
libusb_open_device_with_vid_pid(NULL, VID, PID);
所以我的main.c是:
#include <stdio.h>
#include <libusb-1.0/libusb.h>
#include <errno.h>
#define VID 0x0461
#define PID 0x4e22
static struct libusb_device_handle *devh = NULL;
int main(int argc,char** argv)
{
libusb_init(NULL);
devh = libusb_open_device_with_vid_pid(NULL, VID, PID);
if (devh == NULL )
{
printf("not found\n");
return -1;
}
}
如果我测试所有端口usb找不到