INFICON Guardian EIES Controller User Manual

Page 149

Advertising
background image

7 - 11

IP

N 07

4-

51

7-

P1

D

Guardian Co-Deposition Controller Operating Manual

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

private static byte crcLow(short crc) {
byte val = (byte) ((crc & 0x7f) + 34);
return val;
}
public static byte[] pack(String str) {
int cursor = 0;
byte[] cmd = null;
str += " ";
cmd = new byte[str.length() + 5];
cmd[cursor++] = (byte) '!';
cmd[cursor++] = (byte) (34 + str.length() + 1);
char[] chrs = str.toCharArray();
for (int ix = 0; ix < str.length(); ix++) {
cmd[cursor++] = (byte) chrs[ix];
}
if (useCheckSum) {
short crc = calcCRC(cmd);
cmd[cursor++] = (byte) crcLow(crc);
cmd[cursor++] = (byte) crcHigh(crc);
} else {
cmd[cursor++] = (byte) 0;
cmd[cursor++] = (byte) 0;
}
cmd[cursor++] = (byte) 0x0a /* LF */;

return cmd;
}

public static String unpack(String msg) {
String str = null;
if (msg != null && msg.length() > 4) {
str = msg.substring(3, msg.length() - 2);
}
return str;
}
}

A small utility program, MessageGen, is available to illustrate proper message
generation. A typical complete command/response string is illustrated in the @
command below.

Advertising