Lib usb如何从端口读取字符
我想编写一个从 USB 设备读取数据的应用程序,并且正在寻找一个可以使工作变得更轻松的库。我找到了一个名为 lib-usb
的库。不幸的是,它几乎没有文档。这是我尝试过的:
#include <stdio.h>
#include <stdlib.h>
#include <usb.h>
int main(){
struct usb_device dev;
struct usb_device *device;
usb_dev_handle *handle;
struct usb_bus bus;
usb_init();
usb_find_busses();
int a=usb_find_devices();
bus=usb_get_buses();
handle=usb_open(device);
return 0;
}
但我不知道如何选择我想要读取的端口。我想将读取的数据保存为字符串。任何建议表示赞赏。
I want to write an application that reads data from the USB device and was looking for a library that can make the job easier. I found a library called lib-usb
. Unfortunately, it has almost no documentation. Here is what I have tried:
#include <stdio.h>
#include <stdlib.h>
#include <usb.h>
int main(){
struct usb_device dev;
struct usb_device *device;
usb_dev_handle *handle;
struct usb_bus bus;
usb_init();
usb_find_busses();
int a=usb_find_devices();
bus=usb_get_buses();
handle=usb_open(device);
return 0;
}
But I can't figure out how to select a port that I want to read from. I would like to save read data as a string. Any advice is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
USB 并不真正传输字符,而是传输数据包。此外,你的代码根本没有任何意义;在 http://libusb.sourceforge.net/api-1.0/,我建议您阅读。
USB doesn't really transfer characters -- it transfers packets. Additionally, your code makes no sense at all; there is some pretty good documentation online at http://libusb.sourceforge.net/api-1.0/, which I recommend that you read.