I'm working on a proof of concept that pulls in data from medical devices e.g. oximeter and stores that data in a database for subsequent analysis. The data is mostly binary. I've written a C# app on Windows that reads the data in and stores it as binary, csv, database.
Now, I'm working on an Android app (and maybe iOS) that will pull in the binary data and populate a SQLite database. The issue is get the unsigned short/int/long data out of the binary files.
Here's a snippet of what I've encountered:
I have comments at end of each line to indicate what value I get.
I also used suggested code that produces unsigned values which is called (commented out) and produced an exception:
java.lang.RuntimeException: Method: andLong not found in: b4a.example.b4xmainpage
It appears there may be an issue with little/big endian which works with C# and not B4X.
Any help would be appreciated.
Now, I'm working on an Android app (and maybe iOS) that will pull in the binary data and populate a SQLite database. The issue is get the unsigned short/int/long data out of the binary files.
Here's a snippet of what I've encountered:
Example:
Dim aByte As Byte
Dim aShort As Short
Dim anInt As Int
Dim aLong As Long
rafInput.Initialize(internalDir, "O2M.dat", True)
' should be 5
Dim theVersion As Short = rafInput.ReadShort(rafInput.CurrentPosition) ' 1280
' should be 2023
'Dim theYear As Long = rafInput.ReadShort(rafInput.CurrentPosition) ' -6393
Dim theYear As Int = rafInput.ReadShort(rafInput.CurrentPosition) ' -6393
'Dim theYear As Long = ToUnsigned(rafInput.ReadShort(rafInput.CurrentPosition)) ' exception
'aShort = rafInput.ReadUnSignedByte(rafInput.CurrentPosition) ' postive 231 vs -25 if byte
I also used suggested code that produces unsigned values which is called (commented out) and produced an exception:
java.lang.RuntimeException: Method: andLong not found in: b4a.example.b4xmainpage
Unsigned value conversion:
Sub ToUnsigned(i As Int) As Long
Return AndLong(i, 0xFFFFFFFF)
End Sub
public Sub AndLong (N1 As Long, N2 As Long) As Long
Return jo.RunMethod("andLong", Array(N1, N2)) ' not found
End Sub
It appears there may be an issue with little/big endian which works with C# and not B4X.
Any help would be appreciated.