Lines 276-282
Link Here
|
276 |
int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, |
276 |
int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, |
277 |
int timeout) |
277 |
int timeout) |
278 |
{ |
278 |
{ |
279 |
int fd, ret, sent = 0; |
279 |
int fd, ret; |
280 |
|
280 |
|
281 |
/* Ensure the endpoint address is correct */ |
281 |
/* Ensure the endpoint address is correct */ |
282 |
ep &= ~USB_ENDPOINT_IN; |
282 |
ep &= ~USB_ENDPOINT_IN; |
Lines 298-305
Link Here
|
298 |
USB_ERROR_STR(ret, "error setting timeout: %s", |
298 |
USB_ERROR_STR(ret, "error setting timeout: %s", |
299 |
strerror(errno)); |
299 |
strerror(errno)); |
300 |
|
300 |
|
301 |
do { |
301 |
ret = write(fd, bytes, size); |
302 |
ret = write(fd, bytes+sent, size-sent); |
|
|
303 |
if (ret < 0) |
302 |
if (ret < 0) |
304 |
#if __FreeBSD__ |
303 |
#if __FreeBSD__ |
305 |
USB_ERROR_STR(ret, "error writing to bulk endpoint %s.%d: %s", |
304 |
USB_ERROR_STR(ret, "error writing to bulk endpoint %s.%d: %s", |
Lines 309-324
Link Here
|
309 |
dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); |
308 |
dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); |
310 |
#endif |
309 |
#endif |
311 |
|
310 |
|
312 |
sent += ret; |
311 |
return ret; |
313 |
} while(ret > 0 && sent < size); |
|
|
314 |
|
315 |
return sent; |
316 |
} |
312 |
} |
317 |
|
313 |
|
318 |
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, |
314 |
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, |
319 |
int timeout) |
315 |
int timeout) |
320 |
{ |
316 |
{ |
321 |
int fd, ret, retrieved = 0, one = 1; |
317 |
int fd, ret, one = 1; |
322 |
|
318 |
|
323 |
/* Ensure the endpoint address is correct */ |
319 |
/* Ensure the endpoint address is correct */ |
324 |
ep |= USB_ENDPOINT_IN; |
320 |
ep |= USB_ENDPOINT_IN; |
Lines 345-352
Link Here
|
345 |
USB_ERROR_STR(ret, "error setting short xfer: %s", |
341 |
USB_ERROR_STR(ret, "error setting short xfer: %s", |
346 |
strerror(errno)); |
342 |
strerror(errno)); |
347 |
|
343 |
|
348 |
do { |
344 |
ret = read(fd, bytes, size); |
349 |
ret = read(fd, bytes+retrieved, size-retrieved); |
|
|
350 |
if (ret < 0) |
345 |
if (ret < 0) |
351 |
#if __FreeBSD__ |
346 |
#if __FreeBSD__ |
352 |
USB_ERROR_STR(ret, "error reading from bulk endpoint %s.%d: %s", |
347 |
USB_ERROR_STR(ret, "error reading from bulk endpoint %s.%d: %s", |
Lines 355-364
Link Here
|
355 |
USB_ERROR_STR(ret, "error reading from bulk endpoint %s.%02d: %s", |
350 |
USB_ERROR_STR(ret, "error reading from bulk endpoint %s.%02d: %s", |
356 |
dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); |
351 |
dev->device->filename, UE_GET_ADDR(ep), strerror(errno)); |
357 |
#endif |
352 |
#endif |
358 |
retrieved += ret; |
|
|
359 |
} while (ret > 0 && retrieved < size); |
360 |
|
353 |
|
361 |
return retrieved; |
354 |
return ret; |
362 |
} |
355 |
} |
363 |
|
356 |
|
364 |
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, |
357 |
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, |