Public message_size_Upload(42) As Byte
Public crc_value = 0
Public bitvalue As Byte()
Public bitcrc As Byte()
Public Const POLY As Integer = &H8005
Public len_upload As String = 80
Public msg_size_Upload As Byte = len_upload
Function CRC_Check_Table_Upload(ByVal msg_size_Upload As Integer) As Integer
Dim i As Integer
Dim j As Integer
Dim msg As Integer
crc_value = 0
message_size_Upload(0) = 97
message_size_Upload(1) = 140
message_size_Upload(2) = 105
message_size_Upload(3) = 188
message_size_Upload(4) = 51
message_size_Upload(5) = 79
message_size_Upload(6) = 99
message_size_Upload(7) = 92
message_size_Upload(8) = 64
message_size_Upload(9) = 162
message_size_Upload(10) = 19
message_size_Upload(11) = 109
message_size_Upload(12) = 76
message_size_Upload(12) = 48
message_size_Upload(14) = 48
message_size_Upload(15) = 49
message_size_Upload(16) = 55
message_size_Upload(17) = 57
message_size_Upload(18) = 6
message_size_Upload(19) = 76
message_size_Upload(20) = 48
message_size_Upload(21) = 48
message_size_Upload(22) = 49
message_size_Upload(23) = 55
message_size_Upload(24) = 57
message_size_Upload(25) = 56
message_size_Upload(26) = 49
message_size_Upload(27) = 51
message_size_Upload(28) = 69
message_size_Upload(29) = 69
message_size_Upload(30) = 54
message_size_Upload(31) = 129
message_size_Upload(32) = 16
message_size_Upload(33) = 89
message_size_Upload(34) = 62
message_size_Upload(35) = 230
message_size_Upload(36) = 1
message_size_Upload(37) = 213
message_size_Upload(38) = 107
message_size_Upload(39) = 21
message_size_Upload(40) = 82
'loops through message of byte
For i = 0 To msg_size_Upload - 1
msg = (message_size_Upload(40))
msg = (msg << 8) And &HFFFF
'loop through the message of bits
For j = 0 To 7
If ((msg Xor crc_value) >> 15) > 0 Then
'shifts the CRC bit values and compare with POLY
crc_value = ((crc_value << 1) Xor POLY) And &HFFFF
Else
crc_value <<= 1
'shift the CRC bit values
crc_value = (crc_value) And &HFFFF
End If
msg <<= 1
msg = (msg) And &HFFFF
Next j
Next i
'returns the CRC value in decimal (number) format
bitcrc = BitConverter.GetBytes(crc_value)
Return (crc_value Xor 0)
End Function
|