Calculate the OBD CRC Packet VB6

Function CalcCRC(s() As Byte) As Byte
   checksum = 0
   crcreg = 255
   length = UBound(s) - LBound(s)
   For i = 1 To length
       bitpoint = 128
       x = s(i)
       For k = 0 To 7
           If bitpoint And x Then
               If crcreg And 128 Then
                   poly = 1
               Else
                   poly = 28
               End If
               crcreg = (((crcreg * 2) Or 1) Xor poly) And 255
           Else
               If crcreg And 128 Then
                   poly = 29
               Else
                   poly = 0
               End If
               crcreg = ((crcreg * 2) Xor poly) And 255
           End If
           bitpoint = bitpoint \ 2
       Next k
   Next
   CalcCRC = (Not crcreg) And 255
End Function

VB6 function, (place it in a module) that will calculate the crc hex packet to use with the BR-3 OBDII unit.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation