//command über rs232 schicken (inkl '\n'), wait for ACK
logger.debug("TX: "+command.getRequestCmd());
writeString(command.getRequestCmd() + '\n');
sleep(250);
DavisCommandType commandType = DavisCommandType.getCommandTypeByCommand(command.getRequestCmd());
switch (commandType.getResponsetype()) {
case Constants.RESPONSE_TYPE_NONE:
break;
case Constants.RESPONSE_TYPE_ACK:
int in = inputStream.read();
if ( in != Constants.ACK) {
throw new IOException("Invalid response");
}
break;
case Constants.RESPONSE_TYPE_OK:
expectString("\n\rOK\n\r");
break;
}
byte[] inputBuf = null;
switch (commandType.getResponselimitertype()) {
case Constants.RESPONSE_LIMITER_TYPE_CRLF:
inputBuf = new BufferedReader(new InputStreamReader(inputStream)).readLine().getBytes();
break;
case Constants.RESPONSE_LIMITER_TYPE_FIXED_SIZE:
inputBuf = readBytes(commandType.getResponselength());
break;
case Constants.RESPONSE_LIMITER_TYPE_MULTIPLE_CRLF:
//TODO add support
break;
}
switch (commandType.getCrcchecktype()) {
case Constants.CRC_CHECK_TYPE_VAR1:
if (!CRC16.check(inputBuf, 0, inputBuf.length)) {
throw new IOException("CRC error");
}
break;