5 - 12
IP
N 07
4-
51
1-
P1
C
SQM-160 Operating Manual
5.5 CRC Examples
In this section you will find examples of code for calculating the CRC in Visual
Basic, Java, and C++. Instructions for calculating the CRC are located in
.
5.5.1 Visual Basic
®
5/6
Public Sub CalcChkSumByte(ByRef ByData() As Byte, ByRef byCRC() As
Byte)
Dim CRC As Integer
Dim TmpCRC As Integer
Dim LastIndex As Long
Dim i As Integer
Dim j As Integer
LastIndex = UBound(ByData())
' Avoid on length messages
If ByData(1) > 0 Then
' Set 14 bit CRC to all ones
CRC = &H3FFF
For j = 1 To LastIndex - 2
' XOR current character with CRC
CRC = CRC Xor ByData(j)
' Go thru lower 8 bits of CRC
For i = 1 To 8
' Save CRC before shift
TmpCRC = CRC
' Shift right one bit
CRC = Shri(CRC, 1)
If (TmpCRC And 1) = 1 Then
' If LSB is 0 (before shift), XOR with hex 2001
CRC = CRC Xor &H2001
End If
Next i
Next j
' Be sure we still have 14 bits
CRC = CRC And &H3FFF
byCRC(0) = (LoByte(CRC) And &H7F) + 34
byCRC(1) = (LoByte(Shri(CRC, 7)) And &H7F) + 34
Else
' Empty message
byCRC(0) = 0
byCRC(1) = 0
End If
Содержание SQM-160
Страница 1: ...O P E R A T I N G M A N U A L SQM 1 60 Multi Film Rate Thickness Monitor IPN 074 511 P1C ...
Страница 2: ......
Страница 5: ......
Страница 6: ......
Страница 8: ......
Страница 22: ...1 10 IPN 074 511 P1C SQM 160 Operating Manual This page is intentionally blank ...
Страница 30: ...2 8 IPN 074 511 P1C SQM 160 Operating Manual This page is intentionally blank ...
Страница 60: ...4 12 IPN 074 511 P1C SQM 160 Operating Manual This page is intentionally blank ...
Страница 76: ...5 16 IPN 074 511 P1C SQM 160 Operating Manual This page is intentionally blank ...
Страница 98: ...6 22 IPN 074 511 P1C SQM 160 Operating Manual This page is intentionally blank ...
Страница 110: ...8 8 IPN 074 511 P1C SQM 160 Operating Manual This page is intentionally blank ...
Страница 120: ...A 10 IPN 074 511 P1C SQM 160 Operating Manual This page is intentionally blank ...