Skip to content

Commit

Permalink
Detailed error description
Browse files Browse the repository at this point in the history
  • Loading branch information
docbender committed Jan 27, 2022
1 parent 285ae34 commit 84a9f2a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
@NonNullByDefault
public class SimpleBinaryBindingConstants {
public static final String VERSION = "3.2.0-beta.7";
public static final String VERSION = "3.2.0-beta.8";

private static final String BINDING_ID = "simplebinary";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,26 @@ public boolean setDeviceState(Integer deviceAddress, SimpleBinaryDeviceState.Dev
} else if (state == DeviceStates.NOT_RESPONDING) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Not responding");
} else if (state == DeviceStates.DATA_ERROR) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Data error");
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Data error (see log)");
} else if (state == DeviceStates.RESPONSE_ERROR) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "CRC error (see log)");
} else if (state == DeviceStates.DATA_ERROR_ADDRESS) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Response error (wrong CRC)");
"Received and sent address are different");
} else if (state == DeviceStates.DATA_ERROR_SAVE) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Device cannot save data");
} else if (state == DeviceStates.DATA_ERROR_UNKNOWN_ADDRESS) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Device does not know item address");
} else if (state == DeviceStates.DATA_ERROR_UNKNOWN_DATA) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Unknown message received by device");
} else if (state == DeviceStates.DATA_ERROR_UNKNOWN_MSG) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Unknown message received from device");
} else if (state == DeviceStates.DATA_ERROR_UNSUPPORTED_MSG) {
x.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Unsupported message received");
} else {
x.updateStatus(ThingStatus.UNKNOWN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,33 @@ public enum DeviceStates {
*/
RESPONSE_ERROR,
/**
* Device communicates but there is same problem with data (unknown address, not supported telegram, error
* during save data in slave, ...)
* Device communicates but there is same problem with data
*/
DATA_ERROR
DATA_ERROR,
/**
* Received unknown message ID
*/
DATA_ERROR_UNKNOWN_MSG,
/**
* Device reported unknown data message type
*/
DATA_ERROR_UNKNOWN_DATA,
/**
* Device reported unknown address
*/
DATA_ERROR_UNKNOWN_ADDRESS,
/**
* Received unsupported message type
*/
DATA_ERROR_UNSUPPORTED_MSG,
/**
* Device cannot save data
*/
DATA_ERROR_SAVE,
/**
* Received differ from sent
*/
DATA_ERROR_ADDRESS
}

private DeviceStates state = DeviceStates.UNKNOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ protected int processData(SimpleBinaryByteBuffer inBuffer, SimpleBinaryItemData
logger.warn("{} - Income unknown message: input buffer cleared", this.toString());

// set state
setDeviceState(receivedID, DeviceStates.DATA_ERROR);
setDeviceState(receivedID, DeviceStates.DATA_ERROR_UNKNOWN_MSG);

return ProcessDataResult.UNKNOWN_MESSAGE;
} else {
Expand Down Expand Up @@ -864,7 +864,7 @@ protected SimpleBinaryMessageType processDecompiledData(SimpleBinaryMessage item
SimpleBinaryProtocol.arrayToString(lastSentData.getData(), lastSentData.getData().length));
}
// set state
setDeviceState(itemData.getDeviceId(), DeviceStates.DATA_ERROR);
setDeviceState(itemData.getDeviceId(), DeviceStates.DATA_ERROR_UNKNOWN_DATA);
} else if (itemData.getMessageType() == SimpleBinaryMessageType.UNKNOWN_ADDRESS) {
logger.warn("{} - Device {} for item {} report unknown address", toString(), itemData.getDeviceId(),
(lastSentData != null && lastSentData.getItemAddress() >= 0) ? lastSentData.getItemAddress()
Expand All @@ -875,7 +875,7 @@ protected SimpleBinaryMessageType processDecompiledData(SimpleBinaryMessage item
SimpleBinaryProtocol.arrayToString(lastSentData.getData(), lastSentData.getData().length));
}
// set state
setDeviceState(itemData.getDeviceId(), DeviceStates.DATA_ERROR);
setDeviceState(itemData.getDeviceId(), DeviceStates.DATA_ERROR_UNKNOWN_ADDRESS);
} else if (itemData.getMessageType() == SimpleBinaryMessageType.SAVING_ERROR) {
logger.warn("{} - Device {} for item {} report saving data error", toString(), itemData.getDeviceId(),
(lastSentData != null && lastSentData.getItemAddress() >= 0) ? lastSentData.getItemAddress()
Expand All @@ -886,7 +886,7 @@ protected SimpleBinaryMessageType processDecompiledData(SimpleBinaryMessage item
SimpleBinaryProtocol.arrayToString(lastSentData.getData(), lastSentData.getData().length));
}
// set state
setDeviceState(itemData.getDeviceId(), DeviceStates.DATA_ERROR);
setDeviceState(itemData.getDeviceId(), DeviceStates.DATA_ERROR_SAVE);
} else if (itemData.getMessageType() == SimpleBinaryMessageType.HI) {
if (logger.isDebugEnabled()) {
logger.debug("{} - Device {} says Hi", toString(), itemData.getDeviceId());
Expand All @@ -896,7 +896,7 @@ protected SimpleBinaryMessageType processDecompiledData(SimpleBinaryMessage item
itemData.getDeviceId(), itemData.getMessageType().toString());

// set state
setDeviceState(itemData.getDeviceId(), DeviceStates.DATA_ERROR);
setDeviceState(itemData.getDeviceId(), DeviceStates.DATA_ERROR_UNSUPPORTED_MSG);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public void serialEvent(SerialPortEvent event) {
logger.warn("{} - Address not valid: input buffer cleared", this.toString());

// set state
setDeviceState(getLastSentData().getDeviceId(), DeviceStates.DATA_ERROR);
setDeviceState(getLastSentData().getDeviceId(), DeviceStates.DATA_ERROR_ADDRESS);

return;
}
Expand Down

0 comments on commit 84a9f2a

Please sign in to comment.