• Post Reply Bookmark Topic Watch Topic
  • New Topic

Decode Junk charactes

 
Gerald Amalraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to decode the characters received from Client Socket inputstream. what are these characters ? I'm receiving these characters from Gps tracker through inputstream. Code mentioned below

BufferedReader in = new BufferedReader(new InputStreamReader(clientSock.getInputStream(), "UTF-8"));
while ((userInput = in.readLine()) != null) {
System.out.println("!!! "+userInput);
}

!!! xx
!!! ☺♥UH? ▬H? ?9
!!! xx
!!! ☺♥UH? ▬H? ?9
!!! xx▼↕♫♀¶
!!! ?☺c0?C? 4?☺?(#> |? ?M
!!! xx▼↕♫♀¶
!!! &&?☺c/?C? 5◄☺?(#> |?
!!! \?
!!! xx▼↕♫♀¶
!!! ?☺c/?C? 4i☺?(#> |? ♂i☻
!!! xx▼↕♫♀¶
!!! ''?☺c/?D\ 4i☺?(#> |? ♀3B
!!! xx▼↕♫♀¶
!!! ( ?☺c/?D\ 4i☺?(#> |?
!!! ??
!!! xx
!!! ‼E 5 ☺ ♫??
!!! xx
!!! ☺♥UH? ▬H? ☼?☼
!!! xx▼↕♫♀¶
!!! ('?☺c/?DV 5/☺?(#> |? ☼?
!!! xx▼↕♫♀¶
!!! ) ?☺c/?Cu 5↔☺?(#> |? ►??
!!! xx▼↕♫♀¶
!!! )'?☺c/?Ck 4j☺?(#> |? ◄R)
!!! xx▼↕♫♀¶
!!! * ?☺c/?E→ 4[☺?(#> |? ↕▲►
!!! xx▼↕♫♀¶
!!! *'?☺c/?E| 4[☺?(#> |? ‼??
!!! xx
!!! ‼E § ☺ ¶-?
!!! xx
!!! ☺♥UH? ▬H? §Y?
!!! xx▼↕♫♀¶
!!! +
!!! ?☺c/? 4
!!! ☺?(#> |? §?~
!!! xx▼↕♫♀¶
!!! +(?☺c/?D? 4
!!! ☺?(#> |? ▬☺?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you assuming that the data consists of characters, and if it is characters, that they're UTF-8 encoded? I would start by consulting the documentation of the device to see what it mentions about its connectivity.
 
Gerald Amalraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying.

You think this chunk probably don't contain any information at all ? UTF-8 is one of the encoding type I'm currently trying with.

What are these characters ? If the chunk data contains real text behind then how to get the readable data out of it.

The data is hitting the server from a GPS tracker (GT02).

Gerald.J
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It probably contains information, but maybe not as characters - it could be binary data. Or if it is characters, it might not be encoded in UTF-8. But binary data is more likely, IMO.

Is this the device http://p.globalsources.com/IMAGES/PDT/SPEC/086/K1047370086.pdf? I don't even see anything in there to suggest how to interface with it aside from SMS. You may have to find out who the manufacturer is, and check their web site for technical information.
 
Gerald Amalraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks. Exactly the one you're pointing.

http://www.traccar.org/docs/protocol.jsp. Protocol document is available in this link.

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, that's binary, so you need to use Streams instead of Readers and Writers, and then make sense of individual bytes (or groups of bytes) according to information in that document.

For starters, read 42 bytes from the device, and make sure that the first two are hex 68 68, and the last two hex 0D 0A. Then the part in between should be interpretable according to the table.
 
Gerald Amalraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[color=red]For starters, read 42 bytes from the device, and make sure that the first two are hex 68 68, and the last two hex 0D 0A. Then the part in between should be interpretable according to the table.[/color]

Can you give me or point me to some examples?

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The basics are shown at http://docs.oracle.com/javase/tutorial/essential/io/bytestreams.html, except that your InputStream would come from the socket, not from a file, and you wouldn't need an OutputStream.

Instead for reading single bytes you can also read multiple bytes into an array - see the javadocs of InputStream for two methods you can use.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!