Skip to content

Commit

Permalink
fix up switch and endless loops
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmclean committed Jan 6, 2018
1 parent 0a22610 commit ff882df
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,22 +341,26 @@ private byte[] encodeData(Object[] values) {
////////////////////////////////////////////////////////////////////////////////

private ResponseCode decodeResponseCode(DataTransportErrorCode dataTransportErrorCode) {
if(dataTransportErrorCode != null) {
switch (dataTransportErrorCode) {
case OK:
return ResponseCode.OK;
case NOT_FOUND:
return ResponseCode.NOT_FOUND;
case INVALID_ADDRESS:
return ResponseCode.INVALID_ADDRESS;
}
if (dataTransportErrorCode == null) {
return ResponseCode.INTERNAL_ERROR;
}
switch (dataTransportErrorCode) {
case OK:
return ResponseCode.OK;
case NOT_FOUND:
return ResponseCode.NOT_FOUND;
case INVALID_ADDRESS:
return ResponseCode.INVALID_ADDRESS;
default:
return ResponseCode.INTERNAL_ERROR;
}
return ResponseCode.INTERNAL_ERROR;
}

private List<Object> decodeData(Class<?> datatype, byte[] s7Data) throws PlcProtocolException {
List<Object> result = new LinkedList<>();
for(int i = 0; i < s7Data.length;) {
int i = 0;

while (i < s7Data.length) {
if (datatype == Boolean.class) {
result.add((s7Data[i] & 0x01) == 0x01);
i+=1;
Expand Down

0 comments on commit ff882df

Please sign in to comment.