UsbConnection.bulkTransfer returns “-1”. What does it mean?

我与影子孤独终老i 提交于 2019-12-07 10:31:27

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/15446413/usbconnection-bulktransfer-returns-1-what-does-it-mean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!