Android Question Asyncstream prefix source code available ?

sanduro

Member
Licensed User
Longtime User
Hallo,

I cannot use async stream library for communication with my microcontroller (MC).

if I use async stream with BT everything works fine , data flows every 300 ms from MC to android, they are in chunks but I get em kina immediatelly.

When I use same code but with wifi, it behaves quite differently, it buffers the data somehow and sometimes NEWDATA event is raised after 10 seconds and sends LOT of data.

I tried to use prefix mode which I think can resolve my problem but I cant make it work. I always get AStream_Error. I hope my data is OK , now i send from MC sequence of 142 bytes , so I substract 4 which is 138. 138 is 8A in hexa , so i sent following sequence

0000008AFE8102010200800000000000000000003C00F000000000009A006900000101012B6756CE01040100010C1739120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AA

I get the AStream_error eveytime. I do not know what I am doing wrong

Is it possible to get the source code of AsyncStream so I can modify it to serve my purposes, I can identify the header and footer of my message to parse it, or should I use RandomAcccessFile library and to do low level ReadBytes in some process and parse my message there ?

Please advice
 

sanduro

Member
Licensed User
Longtime User
Hi Erel I use UTF-8 , actually I use you BT example for that ....

I add the project zip , you can just switch between prefix and non prefix by commenting uncommenting the line

prefix gets always error, non prefix works fine but it chops message to chunks,
non prefix wifi version buffers a lot but not on all tablests i have, for sure it buffers on Prestigio Android 4.2.2 version.

If it is any help to you I am sending the bluetooth version
 

Attachments

  • bt.zip
    9 KB · Views: 217
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
non prefix wifi version buffers a lot but not on all tablests i have, for sure it buffers on Prestigio Android 4.2.2 version.
AsyncStreams in non-prefix mode doesn't buffer anything. The buffering happens somewhere else.

The "prefix" problem is not in the B4A project. It is in the data that you are sending.

The prefix should be 8A000000 as you initialized AsyncStreams with BigEndian = False.
 
Upvote 0

sanduro

Member
Licensed User
Longtime User
Thanks, oh so that INT32 is written opposite way ? oooh stupid my mistake, Erel will you please make some additional docu or example of data somewhere I think I am not only one confused.or mayne be i am just plain stupid
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…