{"action":"created","issue":{"url":"https://api.github.com/repos/libusb/libusb/issues/200","repository_url":"https://api.github.com/repos/libusb/libusb","labels_url":"https://api.github.com/repos/libusb/libusb/issues/200/labels{/name}","comments_url":"https://api.github.com/repos/libusb/libusb/issues/200/comments","events_url":"https://api.github.com/repos/libusb/libusb/issues/200/events","html_url":"https://github.com/libusb/libusb/issues/200","id":168021121,"number":200,"title":"libusb_bulk_transfer read misses byte","user":{"login":"jacky830","id":19575495,"avatar_url":"https://avatars.githubusercontent.com/u/19575495?v=3","gravatar_id":"","url":"https://api.github.com/users/jacky830","html_url":"https://github.com/jacky830","followers_url":"https://api.github.com/users/jacky830/followers","following_url":"https://api.github.com/users/jacky830/following{/other_user}","gists_url":"https://api.github.com/users/jacky830/gists{/gist_id}","starred_url":"https://api.github.com/users/jacky830/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacky830/subscriptions","organizations_url":"https://api.github.com/users/jacky830/orgs","repos_url":"https://api.github.com/users/jacky830/repos","events_url":"https://api.github.com/users/jacky830/events{/privacy}","received_events_url":"https://api.github.com/users/jacky830/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-07-28T06:17:09Z","updated_at":"2016-07-29T15:34:36Z","closed_at":null,"body":"Hi All,\r\nI am using libusb_bulk_transfer  to read from serial. Here is the detail:\r\ndevh - initial somewhere\r\nmReadEndpoint - initial somewhere as read end point\r\nint readAmt=8;\r\nunsigned char mReadBuffer[readAmt];\r\nint timeoutMillis=50;\r\nlibusb_bulk_transfer(devh, mReadEndpoint, mReadBuffer, readAmt, &numBytesRead, timeoutMillis);\r\n\r\nIt works for reading. However, in some cases, it fails to read one byte data (i.e. ACK byte). I am sure I grabbed the data bytes even it return timeout code, ie. -7. I have no idea why it happens.\r\n\r\nIt seems to work if I increase the timeout value from 50 to 60, but seems not a good way to solve it.\r\n\r\nDoes anyone meet this problem and know how to solove this problem?\r\n\r\nThanks.\r\n\r\nJacky \r\n"},"comment":{"url":"https://api.github.com/repos/libusb/libusb/issues/comments/236213404","html_url":"https://github.com/libusb/libusb/issues/200#issuecomment-236213404","issue_url":"https://api.github.com/repos/libusb/libusb/issues/200","id":236213404,"user":{"login":"jacky830","id":19575495,"avatar_url":"https://avatars.githubusercontent.com/u/19575495?v=3","gravatar_id":"","url":"https://api.github.com/users/jacky830","html_url":"https://github.com/jacky830","followers_url":"https://api.github.com/users/jacky830/followers","following_url":"https://api.github.com/users/jacky830/following{/other_user}","gists_url":"https://api.github.com/users/jacky830/gists{/gist_id}","starred_url":"https://api.github.com/users/jacky830/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacky830/subscriptions","organizations_url":"https://api.github.com/users/jacky830/orgs","repos_url":"https://api.github.com/users/jacky830/repos","events_url":"https://api.github.com/users/jacky830/events{/privacy}","received_events_url":"https://api.github.com/users/jacky830/received_events","type":"User","site_admin":false},"created_at":"2016-07-29T15:34:36Z","updated_at":"2016-07-29T15:34:36Z","body":"I also implemented it with cdc/acm, and I still got the same result with the cdc implementataion.\r\nThis is what I have implemented for cdc using libusb:\r\n\r\nint cdc_acm_read(unsigned char *dest, int length, int timeoutMillis)\r\n{\r\n\tint numBytesRead=0;\r\n\tint readAmt, ret;\r\n\r\n\treadAmt = MIN(length, BUFSIZE);\r\n    ret = libusb_bulk_transfer(devh_cdc, mReadEndpoint, mReadBuffer, readAmt, &numBytesRead, timeoutMillis);\r\n    if (ret < 0) {\r\n        if (numBytesRead<=0) {\r\n            return 0;\r\n        }\r\n    }\r\n    memcpy(dest, mReadBuffer, numBytesRead);\r\n    return numBytesRead;\r\n}\r\n"}}
{"actor":{"display_login":"jacky830"}}