A Anastasios Michaelides Member Licensed User Longtime User Apr 19, 2015 #1 Hello to all, I am new to B4A and i want to make a question. I am trying to make an application to connect with obdii, so far i managed to communicate with cars ecu to send commands and get response's. My issue is that the response's are in Hex and are containing for example 6 bytes(41 05 5A), from that bytes the first 4 (41 05) are not usable. The bytes after first 4 are containing the answer information(5A). Is there a way to get from every response the bytes after the first 4 and convert them to decimal ? Thank you in advance.
Hello to all, I am new to B4A and i want to make a question. I am trying to make an application to connect with obdii, so far i managed to communicate with cars ecu to send commands and get response's. My issue is that the response's are in Hex and are containing for example 6 bytes(41 05 5A), from that bytes the first 4 (41 05) are not usable. The bytes after first 4 are containing the answer information(5A). Is there a way to get from every response the bytes after the first 4 and convert them to decimal ? Thank you in advance.
raphael75 Active Member Licensed User Longtime User Apr 19, 2015 #2 I understand that you have converted "41055A" to a string since you talk about 6 bytes and not 3. Then you can use this kind of code: Code: Copy Dim S As String = "41055A" If S.Length >= 6 Then ' Condition to avoid error when using SubString2(4, 6) Dim S2 As String = S.SubString2(4, 6) ' => S2 = "5A". Dim I As Int = Bit.ParseInt(S2, 16) ' => I = 90 (= 0x5A) End If Help > Bit > ParseInt: https://www.b4x.com/android/help/core.html#bit_parseint Upvote 0
I understand that you have converted "41055A" to a string since you talk about 6 bytes and not 3. Then you can use this kind of code: Code: Copy Dim S As String = "41055A" If S.Length >= 6 Then ' Condition to avoid error when using SubString2(4, 6) Dim S2 As String = S.SubString2(4, 6) ' => S2 = "5A". Dim I As Int = Bit.ParseInt(S2, 16) ' => I = 90 (= 0x5A) End If Help > Bit > ParseInt: https://www.b4x.com/android/help/core.html#bit_parseint
A Anastasios Michaelides Member Licensed User Longtime User Apr 21, 2015 #3 Thank you for your time I will try your code and I will inform you. Upvote 0