Android Question Sharing makeshift solution

Beja

Expert
Licensed User
Longtime User
While playing with serial communications I found, in the incoming data, the first
byte was missing-in-action, so I put a simple delay loop and it worked, please
don't ask my how it worked!
B4X:
Sub AStream_NewData (Buffer() As Byte)
Dim i As Long
For i = 1 To 1000 : Next

Enjoy (or correct).

Sorry, that was not reliable solution..

Any help?
 
Last edited:

Beja

Expert
Licensed User
Longtime User
Sorry that (solution) was not right.. the problem still there that the first byte does not
stay.. my controller is sending a byte array and I can read all of them using CommX utillity, but
in my phone running Erel's example, the first byte is not logged... with any number of bytes in the array only the first
byte that is not showing.
Please help.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi Erel and thanks..
here is the code and it is the very same one of the serial chat example.

B4X:
Sub AStream_NewData (Buffer() As Byte)
Dim i As Long
    LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
    LogMessage("You", BConv.HexFromBytes(Buffer))
    txtLog.Text =  BConv.HexFromBytes(Buffer)
End Sub
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Took the prefix away...
The byte is not a fixed value and it changes. e.g. if I send F8 BB 23 85, only BB 23 85 shows
on the phone. But sometimes all bytes show in the beginning of the app start, but still sometimes
and not all the time. The byte array is also variable. If you send 2 bytes, only the last
one shows.. or if 10 bytes the last 9... etc.
I noticed one thing though. that the first byte comes in the beginning by itself and then
disappears quickly in a fraction of a second. I didn't notice that before.

I am using Huawei Y301A1, Android 4.1.1, B4A3.
Let me do a little more troubleshooting and will come back with more info. (will use another device).
 
Upvote 0
Top