|
本帖最后由 y296144646q 于 2010-6-13 12:04 编辑
我通过打印信息测试得知是如下过程出错:
在usb_modeswitch.c中的ret = usb_bulk_write(devh, MessageEndpoint, (char *)command, 31, 0);和ret = usb_bulk_read(devh, ResponseEndpoint, data, 36, 0);我的程序走过了usb_bulk_write,却在usb_bulk_read中进入了死循环。。。。。然后我在移植的libusb库中找到了int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size,
int timeout)
{
/* Ensure the endpoint address is correct */
return usb_urb_transfer(dev, ep, USB_URB_TYPE_BULK, bytes, size,
timeout);
}
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
int timeout)
{
/* Ensure the endpoint address is correct */
ep |= USB_ENDPOINT_IN;
return usb_urb_transfer(dev, ep, USB_URB_TYPE_BULK, bytes, size,
timeout);
}
/*然后通过打印信息知道是在usb_urb_transfer中的 while (!urb.usercontext && ((ret = ioctl(dev->fd, IOCTL_USB_REAPURBNDELAY, &context)) == -1) && waiting) {
tv.tv_sec = 0;
tv.tv_usec = 1000; // 1 msec
select(dev->fd + 1, NULL, &writefds, NULL, &tv); //sub second wait
} usb_bulk_write执行一次就退出来拉 而usb_bulk_read确实无限循环 网上有 人说是卡里没钱啦 但这段代码和卡里有没有钱好像没关系啊 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|