ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've written a usb device driver and a program that sends and receives data over the bulk pipe. The read function sometimes returns -1 when I'm reading an unknown amount of data. However, using a usb tracker I can see that the correct data is being sent.
The error only occurs sometimes. I expect that the read function is told to read more data that it receives it would fail and return -1, however if this was the case then every read call would fail.
The read function only returns a -1 if an error occurs, which if you are using non-blocking could include the EAGAIN error meaning no data was available at the time you tried to read
Thanks for the response. The value I get back is errno 5, which is Input/Output error. Also the problem goes away every time I disconnect and reconnect the device.
I also found out that I can make as many read/write calls to the device with out any problems initially. Its when the program closes then opens again that the problem occurs.
I know the data is being sent at the time of the read as I have a usb tracker which is logging every usb packet on a separate machine so I know the data is being sent, the same data each time whether the read command returns an error or not.
do you verify that you are getting a good file descriptor on your open, maybe the device isn't getting released for another open to occur successfully on
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.