我正在尝试使用libusb1.0.9实现用户空间usb驱动程序.我有lpc2148蓝板(ARM7)和我一起使用.这个主板是由Bertrik Sikken先生装载的开源USB堆栈/固件.现在我的用户空间驱动程序尝试用板写读.我正在获取垃圾数据.我想了解批量转运的流程.对于任何传输/事务是否涉及内核设备驱动程序?我们还需要usb小工具设备驱动吗?我无法理解数据被复制的位置.重要的是,当我读/写中断生成时,我可以在LCD上看到正确的数据.我需要读/写USBRxData/USBTxData吗?请做必要的.
我尝试了以下代码进行批量传输读写.
int usb_read(struct libusb_device *dev,struct libusb_device_handle *hDevice)
{
char *data,*data1;
struct libusb_endpoint_descriptor *ep;
struct libusb_interface_descriptor *id;
int len=64,r,ret_alt,ret_clm,ret_rst,i;
struct libusb_device **list;
data = (char *)malloc(512); //allocation of buffers
data1 = (char *)malloc(512);
memset(data,'\0',512);
memset(data1,'\0',512);
if(hDevice==NULL)
{
printf("\nNO device found\n");
return 0;
}
int ret_open = libusb_open(dev,&hDevice);
if(ret_open!=0)
{
printf("Error in libusb_open\n");
libusb_free_device_list(list,1);
return -1;
}
char str_tx[512]="G"; //data to send to device
char str_rx[512]; //receive string
data = str_tx;
printf("data::%s\t,str::%s\n",data,str_tx);
//printf("%c\n",data);
ep = active_config(dev,hDevice);
printf("after ep\n");
//printf("alt_interface = …Run Code Online (Sandbox Code Playgroud)