aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-04-16 23:06:45 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-04-16 23:06:45 -0700
commit8852f1176ac32a065db734079c295783811c192f (patch)
tree7b129550c2bdf8aa3941e1b550d7aa82d8c17cf5 /src/main/java
parent5180e877de462a5950878d69d3ba33dc9ebf790b (diff)
downloadtraccar-server-8852f1176ac32a065db734079c295783811c192f.tar.gz
traccar-server-8852f1176ac32a065db734079c295783811c192f.tar.bz2
traccar-server-8852f1176ac32a065db734079c295783811c192f.zip
Support binary serial data
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 974d2c106..485df833a 100644
--- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -145,8 +145,22 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
} else {
position.set(Position.KEY_TYPE, type);
- position.set(Position.KEY_RESULT, buf.readSlice(buf.readInt()).toString(StandardCharsets.US_ASCII));
+ int length = buf.readInt();
+ boolean readable = true;
+ for (int i = 0; i < length; i++) {
+ byte b = buf.getByte(buf.readerIndex() + i);
+ if (b < 32 && b != '\r' && b != '\n') {
+ readable = false;
+ break;
+ }
+ }
+
+ if (readable) {
+ position.set(Position.KEY_RESULT, buf.readSlice(length).toString(StandardCharsets.US_ASCII));
+ } else {
+ position.set(Position.KEY_RESULT, ByteBufUtil.hexDump(buf.readSlice(length)));
+ }
}
}