I was posting the below code when I saw something that fixed the problem but am still posting this in case someone else runs into this problem
The below code was not working because my hex string only created 2 bytes and I guess byteconverter needs 4 bytes to make an int array
THIS seems like a byteconverter bug to me - it should see there aren't 4 bytes but still return and array of ints.
I am processing Pronto Hex strings and they are in groups of 4 bytes. To make the code below work.
What I did was add pHexCode = "0000" &pHexCode this make the HexToBytes produce 4 bytes that then made IntsFromBytes work
I have the following code (I am sure I am doing something dumb but just can't see it)
The below code was not working because my hex string only created 2 bytes and I guess byteconverter needs 4 bytes to make an int array
THIS seems like a byteconverter bug to me - it should see there aren't 4 bytes but still return and array of ints.
I am processing Pronto Hex strings and they are in groups of 4 bytes. To make the code below work.
What I did was add pHexCode = "0000" &pHexCode this make the HexToBytes produce 4 bytes that then made IntsFromBytes work
I have the following code (I am sure I am doing something dumb but just can't see it)
B4X:
Public Sub ConvertCode(pHexCode As String) As Int ' <---------------------------- this value is "007e"
if pHexCode.Length = 4 then '<------------------- Check length if 4 make it 8 otherwise not enough bytes to make ints
pHexCode = "0000" &pHexCode '<------------------- THIS line will make the code below work
end if '<-------------------
Dim bc As ByteConverter
Dim HexBytes() As Byte = bc.HexToBytes(pHexCode) '<-------------------- Gets converted to 2 byes 0 and 7E
Dim HexResult() As Int = bc.IntsFromBytes(HexBytes) '<-------------------- DOES not return anything
return HexResult(0) '<-------------------- FAILS because HexResult does not contain anything
end sub