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.
Well, after diving into log i was able to handle it - don't close/open usb few times in a row
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.
来源:https://stackoverflow.com/questions/15446413/usbconnection-bulktransfer-returns-1-what-does-it-mean