I am running into a weird bug with iOS. It may be in android as well, I havent tested.
I am sitting here testing my packet receive/parsing routine for robustness, and it failed of course. With this weird bug:
Let a string called RxPacket be this:
RxPacket = "01A00304"
This is a string representing hex data, but its still a string...
So, Given the VB function of this:
causes a crash of:
CRASH: Line 597 Cannot parse: A0
Line 597 is the Return Text.Substring2 from my Mid subroutine.
Now figure this: If I change A0, to 9F or smaller, It doesnt crash! it works fine. But >9F causes crash.
Keep in mind this is all technically "strings" at this point, Substring2 should function regardless of the data inside.
Subroutine Mid:
any ideas? I know I am passing a string into a byte with HexString, but I changed it to Val, same error...
I am sitting here testing my packet receive/parsing routine for robustness, and it failed of course. With this weird bug:
Let a string called RxPacket be this:
RxPacket = "01A00304"
This is a string representing hex data, but its still a string...
So, Given the VB function of this:
B4X:
TestLength = HexString(Mid(RxPacket, 3, 2)) 'Send Length byte <--- Returns "A0" which
causes a crash of:
CRASH: Line 597 Cannot parse: A0
Line 597 is the Return Text.Substring2 from my Mid subroutine.
Now figure this: If I change A0, to 9F or smaller, It doesnt crash! it works fine. But >9F causes crash.
Keep in mind this is all technically "strings" at this point, Substring2 should function regardless of the data inside.
Subroutine Mid:
B4X:
Sub Mid(Text As String, Start As Int, Length As Int) As String
Return Text.SubString2(Start-1,Start+Length-1)
End Sub
Sub HexString(Number As Byte) As String
Dim retVal As String
Dim retByte(0+1) As Byte
Dim Convert As ByteConverter
retByte(0) = Number
retVal = Convert.HexFromBytes(retByte)
Return retVal
End Sub
any ideas? I know I am passing a string into a byte with HexString, but I changed it to Val, same error...
Last edited: