Adb USB Protocol

438 views
Skip to first unread message

Nick Hanna

unread,
Mar 14, 2012, 11:30:07 PM3/14/12
to android-...@googlegroups.com
Hello,

I've been working with USB host APIs in order to interface with adb on a connected device, and through trial and error, I've been mostly successful.  I've been able to transfer data through the file sync service, but there are a few small details I've yet to pinpoint.  I've successfully transferred a small file but I now need to transfer something larger (approximately 660kb).  The issue I'm having is the setting the size in the following four bytes after defining the message when sending a message that requires multiple chunks. I'm able to initiate the send sequence and transfer data up to approximately 64kb (65544 bytes including the DATA message), and it appears to give me a FAIL message with the reason "invalid data message".  I've grepped through the source and found that this message corresponds to one of three different messages, two of which give reasons, and one doesn't.

The ADB_TRACE variable and strace in bash has shown the structure of the message that adb push uses, and I've determined the structure of the message i need to send, however the service doesn't seem to accept it.  I've compiled adb for linux-x86 and tried to find the answer with some debug statements, but nothing that's working.  

All that being said, I believe my question is: How do I structure a data message that has to be split into several messages?  I've applied some trial and error to the messages and it is the 4  bytes after the ID_DATA message that control that size, however I've tried specifying the length in hex as I do the previous messages, but it still chokes out at the same point.  If I set that size to an arbitrarily high number, it will spit the first write back at me and tell me that the data message is over sized.

In the source, a companion document (named SYNC.TXT) is mentioned in the services document (SERVICES.TXT) that seems to outline the nuances of the file sync service, but I can't find it in any of the sources/branch history.  I'm not sure if this document has the answer, but it would be nice to see it.

Thank You,

Nicholas

MoeBe

unread,
Oct 17, 2012, 2:20:05 PM10/17/12
to android-...@googlegroups.com
Thanks for replying but I don't think that is SYNC.TXT. It looks like a derivative of protocol.txt. SYNC.TXT should be contained in the Android source.

If you want to communicate with the ADB daemon on the Android device using the file and directory synchronization service that adb uses you will either have to reverse engineer it from the source or get the documentation contained in SYNC.TXT (if it were available).

On Wednesday, October 17, 2012 6:32:20 AM UTC-4, Andy Holmes wrote:
This is probably what you're looking for: https://github.com/rfc1459/adbd/wiki/ADB-Protocol
Reply all
Reply to author
Forward
0 new messages