2 java – INFICON SQM-160 Thin Film Deposition Monitor User Manual

Page 74

Advertising
background image

5 - 14

IP

N 07

4-

51

1-

P1

C

SQM-160 Operating Manual

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"Shri"
Resume PROC_EXIT

End Function

5.5.2 Java

®

private short calcCRC(byte[] str) {
short crc = 0;
short tmpCRC;
int length = 1 + str[1] - 34;
if (length > 0) {

crc = (short) 0x3fff;
for (int jx = 1; jx <= length; jx++) {
crc = (short) (crc ^ (short) str[jx]);

for (int ix = 0; ix < 8; ix++) {
tmpCRC = crc;
crc = (short) (crc >> 1);
if ((tmpCRC & 0x1) == 1) {
crc = (short) (crc ^ 0x2001);
}
}
crc = (short) (crc & 0x3fff);
}
}
return crc;
}

private byte crcHigh(short crc) {
byte val = (byte) (((crc >> 7) & 0x7f) + 34);
return val;
}
private byte crcLow(short crc) {
byte val = (byte) ((crc & 0x7f) + 34);
return val;
}

5.5.3 C++

class CRC14
{
public:

CRC14(void) { crc = 0x0;};

public:

Advertising