Hi, thanks for the response. I wondered if there was another way of approaching the problem? I just found the following VB code on the site. This code calculates the CRC-8 checksum which looks pretty close to what I need. Unfortunately I don't understand the original C code enough to be able to figure out what changes I need to make. I know this VB code isn't giving me the right answer but it might be along the right lines?
'-------------------------
' Procedure : XGetCRC8
' Purpose : Calculate the CRC8 code for the entire string
'-------------------------
'
Private Function XGetCRC8(CRC8 As String) As Integer
Dim l_Len As Integer
Dim l_Char As String
Dim l_CRC8 As Integer
l_CRC8 = 0
For l_Len = 1 To Len(CRC8)
l_Char = Mid(CRC8, l_Len, 1)
l_CRC8 = XCalculateCRC8(l_CRC8, l_Char)
Next
XGetCRC8 = l_CRC8
End Function
'-------------------------
' Procedure : XCalculateCRC8
' Purpose : Calculate the cumulative CRC8 code for the given character
'-------------------------
'
Private Function XCalculateCRC8(CRC8 As Integer, Character As String) As Byte
Dim l_BitPopped As Boolean
Dim l_Bit As Byte
Dim l_Char As Integer
l_Char = Asc(Character)
For l_Bit = 0 To 7
l_BitPopped = (CRC8 And &H80)
CRC8 = CRC8 * 2
If l_Char And &H80 Then
CRC8 = CRC8 Or &H1
Else
CRC8 = CRC8 And &HFE
End If
If l_BitPopped Then
CRC8 = CRC8 Xor &H85
End If
l_Char = l_Char * 2
Next
XCalculateCRC8 = CRC8 And &HFF
End Function
Main Topics
Browse All Topics





by: roshkinsPosted on 2008-04-06 at 14:17:31ID: 21293186
unfortunately, VB.NET does not have any bit manipulation operators. It is impossible. So sorry.