Android USB Accessory Multi Thread

前端 未结 2 728
醉梦人生
醉梦人生 2021-02-19 16:38

Headache caused by multi-threading and Android Open Accessory.

I need to communicate with a USB Accessory, but I need to do it from 2 threads.

2条回答
  •  星月不相逢
    2021-02-19 17:19

    If using multiple threads, I do run into I/O Error (No such device) sooner or later, because I will have a collision between read & write being executed at the same time.

    This says it all. Since you are doing read and write on the same channel that does not support concurrent access, you are required to have your thread wait until the other thread is done doing read/write.

    Your two-thread approach is what I would do, more or less. Good luck and trust in yourself.

提交回复
热议问题