UsbConnection.bulkTransfer returns "-1". What does it mean?
Asked Answered
C

3

5

According to the doc negative response means failure. How to know what's wrong? is there any full doc about error types?

For more curious: I'm trying to upload arduino sketch via USB. First i'm getting bootloader attention by turning DTR/RTS off/on and then sending data using Stk500 protocol. It's working fine if running on mac/arduino via usb (rxtx serial is used) so i think it should work on android AS-IS (just change serial), but it fails to send the data after DTR/RTS toggling.

Courteous answered 16/3, 2013 at 6:47 Comment(1)
have you found any solution to this? I feel like xkcd.com/979Schiff
D
0

From the documentation for bulkTransfer():

Returns

length of data transferred (or zero) for success, or negative value for failure

So if you're getting -1, then it means your data transfer has failed. You could look into the logcat, or work with breakpoints to figure out why.

Davao answered 16/3, 2013 at 7:22 Comment(2)
nothing in the log cat, no breakpoints can be set as it's android os classCourteous
Minus one (-1) is also returned if the timeout is reachedIolanthe
C
1

Well, after diving into log i was able to handle it - don't close/open usb few times in a row

Courteous answered 16/3, 2013 at 19:28 Comment(0)
D
0

From the documentation for bulkTransfer():

Returns

length of data transferred (or zero) for success, or negative value for failure

So if you're getting -1, then it means your data transfer has failed. You could look into the logcat, or work with breakpoints to figure out why.

Davao answered 16/3, 2013 at 7:22 Comment(2)
nothing in the log cat, no breakpoints can be set as it's android os classCourteous
Minus one (-1) is also returned if the timeout is reachedIolanthe
L
0

May be you forgot to claim the interface:

deviceConnection.ClaimInterface(interf, true);
Lianna answered 6/4, 2023 at 8:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.