Hello.
I am sending datetimes from a microcontroller as a byte array. It took me so long to work out how to get the data into b4x. My confusion was around LongsFromBytes and IntsFromBytes. The code here is working but I don't understand why the value is stored in "dtime()" and not "dtime" (the first looks, to me, like an array and the second just an int, but it is declared as an int)
A sub question is that I couldn't get it to work with the value being created in a 3 byte chunk. So in Micropython:
value.to_bytes(3,'big') doesn't work.
value.to_bytes(4,'big') does work.
4 bytes just gets padded with 0x00 for the first byte.
I spent so long trying to figure it out and though I have got it working I don't really understand it, which is annoying. Any pointers or some further reading would help.
I am sending datetimes from a microcontroller as a byte array. It took me so long to work out how to get the data into b4x. My confusion was around LongsFromBytes and IntsFromBytes. The code here is working but I don't understand why the value is stored in "dtime()" and not "dtime" (the first looks, to me, like an array and the second just an int, but it is declared as an int)
A sub question is that I couldn't get it to work with the value being created in a 3 byte chunk. So in Micropython:
value.to_bytes(3,'big') doesn't work.
value.to_bytes(4,'big') does work.
4 bytes just gets padded with 0x00 for the first byte.
I spent so long trying to figure it out and though I have got it working I don't really understand it, which is annoying. Any pointers or some further reading would help.
B4X:
Dim bb As B4XBytesBuilder
Dim bc As ByteConverter
bb.Initialize
For i =0 To b.Length -1
bb.Append(Array As Byte(b(i)))
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''TimeA
Dim ta() As Byte =bb.SubArray2(1,5)
Dim dtime() As Int = bc.IntsFromBytes(ta) '<---------------why dtime() and not dtime?
Log(dtime(0))