adb_client icon indicating copy to clipboard operation
adb_client copied to clipboard

usb: use bincode for conversions between message header struct and raw bytes

Open lavafroth opened this issue 1 year ago • 3 comments

Changes

  • Added an ADBUsbMessageHeader struct without the payload and implement Serialize and Deserialize on it.
  • Replaced to_bytes method body to use bincode::serialize
  • Made the try_from method use bincode::deserialize. Note: We're using unwraps so far, we need to add an error variant for invalid bytes.
  • The USBCommand enum variants equal their respective values.
    • The enum has a #[repr(u32)] for the underlying type.
    • The to_u32 method has been removed in favor of the as u32 since the enum is a primitive now.

lavafroth avatar Sep 17 '24 14:09 lavafroth

I rebased usb branch on this one as there were merge conflicts due to previous PR merge.

I cannot make it work, get stuck with logs:

written 24
writing payload...
written 18
written 24
writing payload...
written 0
Error: Operation timed out

Can you have a look at it please ? Thanks !

cocool97 avatar Sep 29 '24 14:09 cocool97

Yes, I'll look into it.

lavafroth avatar Sep 30 '24 08:09 lavafroth

The C like enum USBCommand with its non-sequential variants was being encoded as a zero indexed enum. Fixed it with serde_repr

lavafroth avatar Sep 30 '24 09:09 lavafroth

Hi, there are a lot of conflicts with the changes I've made and upstream usb. Would you like me to rebase and one-shot this and force-push? It would be easier for me since I'd have an lsp for sanity checks.

lavafroth avatar Oct 17 '24 02:10 lavafroth

Yes, please ! I had a look into it and did not manage to make it work, maybe it'll work with the new version of usb branch

cocool97 avatar Oct 17 '24 05:10 cocool97

Okay, I have made the necessary changes and have tested them on my device. Let me know if you want me to implement the adb pull command. I have a local branch with that already implemented!

lavafroth avatar Oct 17 '24 09:10 lavafroth

Thanks for the rebase ! I'll check it tomorrow :)

You can of course create a new PR with pull support, I'd like to merge the usb branch in master as soon as possible and this is a feature I'm yet missing

cocool97 avatar Oct 17 '24 19:10 cocool97