besoft Active Member Licensed User Longtime User Feb 18, 2017 #1 HI I need help. I have the following code: Code: 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
HI I need help. I have the following code: Code: 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
Erel B4X founder Staff member Licensed User Longtime User Feb 19, 2017 #2 You should never treat raw bytes as string. If you want to print (mainly for debugging) the raw bytes then you can use ByteConverter.HexFromBytes. Upvote 0
You should never treat raw bytes as string. If you want to print (mainly for debugging) the raw bytes then you can use ByteConverter.HexFromBytes.
besoft Active Member Licensed User Longtime User Feb 19, 2017 #3 Thanks for the reply. Currently, the data looks like this: "? 2.æ| & ‰: & '6 * ÊÖò", which is useless. Upvote 0
Thanks for the reply. Currently, the data looks like this: "? 2.æ| & ‰: & '6 * ÊÖò", which is useless.
besoft Active Member Licensed User Longtime User Feb 19, 2017 #4 SOLVED Code: 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
SOLVED Code: 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