A line must have been accidentally skipped somewhere... I suggest you add the following line, otherwise ret is unitialized :int ret;int i,j,k;ret = libusb_get_device_descriptor(dev, &desc);//this line !if(ret<0){ fprintf(stderr,"error in getting device descriptor\n"); return;}要将输出与 lsusb 之一进行比较,请更改为%x 以打印 idVendor 和 idProduct 使用十六进制格式.To compare the output to the one of lsusb, change for %x to print idVendor and idProduct using hexadecimal format.printf("Vendor: %x\n",desc.idVendor);printf("Product ID: %x\n",desc.idProduct);以下问题 libusb半工作,但未声明libusb_device_descriptor吗?有助于查找缺失的行.这帮助我将 libusb Libusb未定义引用链接到通过 gcc main.c -o main -lusb-1.0 进行编译.The following question libusb semi-working, but libusb_device_descriptor undeclared? was helpful to find the missing line. And this one helped me linking libusb Libusb undefined reference to it advices to compile by gcc main.c -o main -lusb-1.0. 这篇关于使用libusb的输出不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 20:41