I’m using RS-485 coms to send a Hex string containing 16 input values to XOJO. Im trying to convert the Hex string into an array representing the binary values converted to boolean. I’m stumbling on the conversion from decimal to boolean to fill the array.
Public Sub ProcessInputDataRecieved(hexString as string)
Const SIZE As Integer = 16
// Convert the hex string to a numeric value
Dim hexValue As UInt16
hexValue = Val("&h" + hexString)
// Convert the numeric value to an array of boolean values representing each input state
Var inputArray(SIZE-1) As Boolean // Corrected array size
For i As Integer = 0 To SIZE - 1
inputArray(i) = (hexValue And (1 << i)) <> 0 // Problem is here!!!!
Next
End Sub