@Override
public ModuleStatus execute() {
// if (!tagEnable.getBoolean())
// return ModuleStatus.OK;
ModuleStatus status = super.execute();
if (status==ModuleStatus.OK) {
for (int attempt=0; attempt<=tagRetrains.getInteger(); attempt++) {
// System.out.println(".");
// send
status=ModuleStatus.NO_ANSWER;
// init data request command
bufout[0] = 0x55;
bufout[1] = (byte)(0x40 + tagAddress.getInteger() & 0xFF);
if (port.writeBytesAA55(bufout)) {
// receive
if (port.readBytesAA55(bufin)>0) {
// System.out.println("\n>>>" + attempt + ": " + RpHyperstring.bytesToHexString(bufin));
// checking control sum
status=ModuleStatus.BAD_CS;
if (ModuleIO_PA.checkCS(bufin, tagAddress.getInteger())) {
// process data
int mask = 1;
for (int i=0; i<64; i++) {
data[i].set( ((bufin[i/8] & mask) == 0)? 0: 1 );
if ((mask = mask << 1) > 0x80)
mask = 1;
}
status=ModuleStatus.OK;
break;
}
}
}
port.discard();
}
if (status!=ModuleStatus.OK)
tagErrorCounter.set(tagErrorCounter.getInteger() + 1);
}
tagErrorCode.set(status.ordinal());
return status;
}