我正在使用 libusb 与笔式驱动器进行交互。我们必须使用函数 int libusb_bulk_transfer(struct libusb_device_handle * dev_handle, unsigned char endpoint, unsigned char * data,int length,int * transfer,unsigned int timeout)
但是这里我们只指定了终点所以我的问题是它实际上可以读取写入文件(文本或图像)到笔式驱动器。还是只是为了理解?请帮忙!代码::
r = libusb_bulk_transfer(dev_handle, (2 | LIBUSB_ENDPOINT_OUT), data, 4, &actual, 0);
//my device's out endpoint was 2, found with trial- the device had 2 endpoints: 2 and 129
if(r == 0 && actual == 4) //we wrote the 4 bytes successfully
cout<<"Writing Successful!"<<endl;
else
cout<<"Write Error"<<endl;