Problem with B4RSerializator. My hardware is an Elegoo Uno R3
The problem is getting the data back from the Serializator.
I am sending a 4 byte number (B4A int) from a B4A app via Bluetooth using the B4R Serializator.
Logging the detail from the Array returned by the Serializator produces the correct data. However trying to store the number as a B4R long gives me a totally incorrect result.
If I get the number as a string this gives the correct result.
However, converting the String to a Long integer gives the correct number but always with an small error of 64.
Example code attached (Output from log shown in comments)
Something strange is going on here, can anyone point me to a solution? All the examples on the Internet end with a Log statement.
The problem is getting the data back from the Serializator.
I am sending a 4 byte number (B4A int) from a B4A app via Bluetooth using the B4R Serializator.
Logging the detail from the Array returned by the Serializator produces the correct data. However trying to store the number as a B4R long gives me a totally incorrect result.
If I get the number as a string this gives the correct result.
However, converting the String to a Long integer gives the correct number but always with an small error of 64.
Example code attached (Output from log shown in comments)
Something strange is going on here, can anyone point me to a solution? All the examples on the Internet end with a Log statement.
B4X:
Sub AStream_NewData (Buffer() As Byte)
Dim be(50) As Object 'used as a storage buffer. Can be a global variable
Dim data() As Object = ser.ConvertBytesToArray(Buffer, be)
If data.Length = 0 Then Return 'invalid message
' Sent from B4A 1618977600
Log ("Data1 = ", data(1)) ' 1618977600
Dim ObjectData1 As Object = data(1)
Log(" Object Data1 = ", ObjectData1) ' 1618977600
Dim LongData1 As Long = data(1)
Log("Long Data1 = ", LongData1) ' 1148
Dim StringData1 As String = data(1)
Log ("String Data1 = ", StringData1) ' 1618977600
Dim StringToLongData1 As Long = StringData1
Log("StringToLong data1 = ", StringToLongData1) ' 1618977536 - error of -64