B4J Question SOLVED :Serial AStream_NewData

besoft

Active Member
Licensed User
Longtime User
HI
I need help. I have the following code:

B4X:
Sub AStream_NewData (Buffer() As Byte)
    Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "Windows-1252")
    TextArea1.Text = TextArea1.Text & "Recive from serial: " & s & Chr(13) & Chr(10)
    Log(s)
End Sub

This part of the code is working normally.
At the input get data in HEX format as follows "3F 32 2E 26 E6 A6 A9 FA 3E F2 F2 F2 E6 CA D6 00".

How can I get the information in this raw form. Now considers part of the code is converted to string and get a set of strange characters that are not useful.

So I would like to keep the data in HEX format.

Thanks
 

besoft

Active Member
Licensed User
Longtime User
Thanks for the reply.

Currently, the data looks like this: "? 2.æ| & ‰: & '6 * ÊÖò", which is useless.
 
Upvote 0

besoft

Active Member
Licensed User
Longtime User
SOLVED

B4X:
Sub AStream_NewData (Buffer() As Byte)
    'Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "Windows-1252")
    Dim raw As String = bc.HexFromBytes(Buffer)
    TextArea1.Text = TextArea1.Text & "Recive from serial: " & raw & Chr(10)
    'Log(raw)
End Sub
 
Upvote 0
Top