Android Question [Solved]Serial Async Buffersize

Amateurtje

Member
Licensed User
Longtime User
Hi all,

Is there a way to increase the buffer size to more than 100?
or
Is there a way to know the total received bytes (to know when to store it in a temp buffer)?

I came across Streamtotal and Streamreceived but they give a 0 value when reading these in "astream_NewData". This is probably due to the fact they are only available in prefix mode.....
 

Amateurtje

Member
Licensed User
Longtime User
indeed, sorry.

but It receives for sure a complete bytearray of more than 100 and it always cuts it in pieces of 100 or less. The Buffer that comes in in Astream_newdata is never more than 100 while for sure more than 100 is send.. Thna it activates Newdata always several times.... IF this maximum could be raised, it would be nice...
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
This is the way serial comms works. You can never guarantee that a complete message arrives in a single transaction. I'm afraid that you just have to live with it and reassemble the messages yourself. In my experience going back over 50 years this has always been a feature that means a robust serial comms protocol is more difficult to implement than it at first appears if you want to cater for all possibilities including lost and corrupted characters.
 
Upvote 0

Amateurtje

Member
Licensed User
Longtime User
Thanks. The B4XBytesBuilder works nicely. Saves a lot of code in buffering....Luckily I had already added a kind of indicator of the length in the beginning part of the serial message. the message is not text based.
On the other side, a number like 'chunks of 100 bytes' that come in at a time, looks like a chosen number and usually there is a setting for numbers that are chosen. therefore this question...

it works!!
 
Upvote 0
Top