Home > Mobile >  Android can't send more than 8 bytes of data serial communication [against AndroidStudio built-
Android can't send more than 8 bytes of data serial communication [against AndroidStudio built-

Time:09-25

I created a virtual serial port on the PC, respectively opened two serial assistants to communicate, no matter how many bytes of data can be smoothly to send and receive,
Then I will be one of the serial port to mount an Android emulator, using a serial port assistant to communicate with the simulator, less than or equal to 8 bytes of data can be smoothly to send and receive, once with a serial port assistant send simulator is more than 8 bytes of data, the application will be stuck, have no reaction, the simulator is then hung up,
Application is dependent on Google's android - serialport - API, it should not be application problems, I took the apk that others have written test, and even Google's own apk testing, is such result,
I see there is a serial port devices receive the problem of the size of the buffer, the use of serial assistants have a problem, is because of the Android emulator?
There has many don't understand about serial communication, hope god help solve!!!!!

CodePudding user response:

And if the receive buffer size is the problem, why don't more than eight bytes of data received in two times? Maybe is the problem that the library?

CodePudding user response:

Find an article on the Internet (https://dp2px.com/2019/06/12/virtualserial/), which is mounted a serial port using Genymotion simulator, implementing serial communication practice according to the article, I found that this problem does not exist, it was the problem of the Android native simulator?

CodePudding user response:

Estimation is a problem, you receive more than 8 bytes of data flow causes you to receive the thread card dead or an error, but still ask, did you set the buffer??

CodePudding user response:

reference ro_Qing reply: 3/f
estimation is a problem, you receive more than 8 bytes of data flow causes you to receive the thread card dead or an error, but still ask, did you set the buffer??

It is as you say, read the size of the buffer? Is this?
MReadBuffer=new byte [1024].
Program card to death when I see the log is not an error

CodePudding user response:

Or hardware problem? I've just set size to 7 test, mReadBuffer=new byte [7], sending two received when 8 bytes of data

CodePudding user response:

To stick pack oh, according to your bytes, to capture what you want

CodePudding user response:

We applied to a serial port communication is 41 bytes, sending and receiving is 41, there is no problem,
Should be properly, you hair past data, the first is the length, tell the length of the serial port devices read,
  • Related