Skip to content

Commit

Permalink
Handle missing temperature (fix traccar#3806)
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Mar 12, 2018
1 parent 708c387 commit 612547f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/org/traccar/protocol/Gl200TextProtocolDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,9 @@ private Object decodeEri(Channel channel, SocketAddress remoteAddress, String se
for (int i = 1; i <= deviceCount; i++) {
index += 1; // id
index += 1; // type
position.set(Position.PREFIX_TEMP + i, (short) Integer.parseInt(data[index++], 16) * 0.0625);
if (!data[index++].isEmpty()) {
position.set(Position.PREFIX_TEMP + i, (short) Integer.parseInt(data[index - 1], 16) * 0.0625);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public void testDecode() throws Exception {

Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(new Gl200Protocol());

verifyPositions(decoder, buffer(
"+RESP:GTERI,310603,863286023345490,,00000002,,10,1,2,0.3,0,155.7,8.000000,52.000000,20171215213040,0262,0002,1450,9F13,00,1130.3,00539:27:19,,,110000,2,1,28FFD5239115034E,1,,20171215213041,27C7$"));

verifyPositions(decoder, buffer(
"+RESP:GTERI,250C02,868789023691057,,00000019,,10,1,1,0.0,196,2258.0,-99.201807,19.559242,20180214002957,0334,0003,235B,7F8D,00,6786.7,,,,100,110000,1,0394,1,4,100.0,100.0,20180214003006,C72B$"));

Expand Down

0 comments on commit 612547f

Please sign in to comment.