Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing USB File Transfer Rate with UsbSerialExamples on Linux and Android @cdc #543

Open
xingxing7290 opened this issue Nov 3, 2023 · 4 comments

Comments

@xingxing7290
Copy link

"Hello, I've been using the UsbSerialExamples sample and have developed with it. The development scenario involves a Linux device emulating a CDC slave device over USB, and connecting to an Android smartphone. The issue I've encountered is that when the Linux device uses open /dev/ttyGS0 and writes data using write, I intend to transfer files with each write operation consisting of 16*1024+50 bytes (following a specific protocol). However, I've noticed that the USB receiver on the Android side only receives 512 bytes at a time, and I have to assemble them into complete data sets. Is the 512-byte limit fixed for each reception, or is there a way to increase it and improve the file reception rate? I appreciate your help in advance."

@xingxing7290
Copy link
Author

At the same time, there may also be partial loss of data. I set the baud rate to 460800 on Android and Linux, but as mentioned in the previous issues, CDC devices are not suitable for any baud rate

@xingxing7290
Copy link
Author

xingxing7290 commented Nov 16, 2023

In Android, using USB to receive data, the sender sends a large amount of data, and the Android app is designed to receive this data. While receiving data, if the application is suddenly killed, the sender stops sending data accordingly. However, upon reopening the application, it is noticed that the Android receiving application continues to receive the data that was being sent before. Why does this happen? Could it be related to the buffering mechanism? Should the buffer be cleared when entering the background, or should the data in the buffer be ignored when the application is reopened? How can this be implemented? (I set it to automatically connect when CDC Settings are detected) Thank you very much for your response.

@kai-morich
Copy link
Collaborator

pure serial devices will not stop sending, when the app disconnects. With CDC the other side might detect USB disconnect and stop. There is no API to clear buffers. You could try adding some additional flow control like setting/resetting DTR line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants