Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Unreadable data #18

Closed
jamrockmedz opened this issue Sep 2, 2015 · 24 comments
Closed

Unreadable data #18

jamrockmedz opened this issue Sep 2, 2015 · 24 comments

Comments

@jamrockmedz
Copy link

I tried using this source to parse data from a tk102 device. The received data is always unreadable, for Example 1:
connected
UH� t"3�T

UH� t"3�T

xx 04���[��<�R�w�3vQ

Example 2:

63.143.78.70 wrote:
UH� t"'�

63.143.78.67 wrote:
UH� t"'�

63.143.78.69 wrote:
UH� t"(A

63.143.78.65 wrote:
UH� t"(A

63.143.78.67 wrote:
UH� t"(A

63.143.78.67 wrote:
UH� t")P�

63.143.78.70 wrote:
UH� t")P�

63.143.78.68 wrote:
UH� t"*b

63.143.78.68 wrote:
UH� t"*b

63.143.78.68 wrote:
UH� t"*b

63.143.78.66 wrote:
UH� t"+s�

63.143.78.69 wrote:
UH� t"+s�

63.143.78.65 wrote:
UH� t"+s�

63.143.78.70 wrote:
UH� t"-�

63.143.78.65 wrote:
UH� t"-�

63.143.78.67 wrote:
UH� t".$0

63.143.78.67 wrote:
UH� t".$0

63.143.78.69 wrote:
UH� t".$0

63.143.78.70 wrote:
UH� t"/5�

63.143.78.65 wrote:
UH� t"/5�

63.143.78.65 wrote:
UH� t"/5�

63.143.78.66 wrote:
UH� t"0

63.143.78.67 wrote:
UH� t"0

63.143.78.69 wrote:
UH� t"0

63.143.78.70 wrote:
UH� t"1

63.143.78.65 wrote:
UH� t"1

63.143.78.70 wrote:
UH� t"1

63.143.78.69 wrote:
UH� t"3

63.143.78.66 wrote:
UH� t"3

63.143.78.69 wrote:
UH� t"3

@fvdm
Copy link
Owner

fvdm commented Sep 2, 2015

That indeed doesn't look right. Is the encoding of your script file and terminal UTF-8?

@jamrockmedz
Copy link
Author

I'm using Putty, Remote character set currently on

UTF-8
I tried:

socket.on('data', function (data) {
console.log ('Incoming data: ');
console.log(data.toString('UTF-8'));
});

result:

capture

fvdm added a commit that referenced this issue Sep 3, 2015
@fvdm
Copy link
Owner

fvdm commented Sep 3, 2015

I created a separate branch to work this out. Please install with:

npm install fvdm/nodejs-tk102#charset

And add these debug lines to your code:

tk102.on ('fail', console.log);
tk102.on ('error', console.log);

@jamrockmedz
Copy link
Author

Results after trying new branch:

UH� t"ngq�ata: xx

UH� t"ngq�ata: xx

Incoming data: xx %��HX_[<�R�w ��

{ [Error: Cannot parse GPS data from device]
reason: 'Cannot parse GPS data from device',
socket:
{ _connecting: false,
_handle: null,
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: true,
endEmitted: true,
reading: false,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: false,
domain: null,
_events:
{ finish: [Function: onSocketFinish],
_socketEnd: [Object],
data: [Function],
readable: [Function],
close: [Function],
error: [Function] },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16384,
objectMode: false,
needDrain: false,
ending: true,
ended: true,
finished: true,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [] },
writable: false,
allowHalfOpen: false,
onend: null,
destroyed: true,
errorEmitted: false,
bytesRead: 72,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server:
{ domain: null,
_events: [Object],
_maxListeners: 10,
_connections: 0,
connections: [Getter/Setter],
_handle: [Object],
_usingSlaves: false,
_slaves: [],
allowHalfOpen: false,
maxConnections: 10,
_connectionKey: '4:0.0.0.0:5001' },
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 1441283208806,
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
consuming: true,
write: [Function: writeAfterFIN] },
input: 'xx\r\u0001\u0003UH� \u0014t"\u0000\tq�\r\nxx\r\u0001\u0003UH� \u0014t"\u0000\tq�\r\nxx\u001f\u0012\u000f\t\u0003\u0007\u001a%�\u0001�H�\bX
[\u0000<�\u0001R\u0005\u0013�\u0000w\u0011\u0000\t��\r\n' }

@jamrockmedz
Copy link
Author

I also tried to use python to determine encoding,
function returns binary as encoding:

def handle(self):
# self.request is the TCP socket connected to the client
self.data = self.request.recv(1024 * 6)
print "{} wrote:".format(self.client_address[0])
print self.data

    m = magic.open(magic.MAGIC_MIME_ENCODING)
    m.load()
    encoding = m.buffer(self.data) 
    print "encoding: " + encoding

Results when binary is used to decode data:

Incoming data:

<Buffer 78 78 0d 01 03 55 48 80 20 14 74 22 00 0b 52 9f 0d 0a>

decoded data:

UH� t"
R�

Incoming data:

<Buffer 78 78 0d 01 03 55 48 80 20 14 74 22 00 0b 52 9f 0d 0a>

decoded data:

UH� t"
R�

{ [Error: Cannot parse GPS data from device]
reason: 'Cannot parse GPS data from device',
socket:
{ _connecting: false,
_handle: null,
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: true,
endEmitted: true,
reading: false,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: false,
domain: null,
_events:
{ finish: [Function: onSocketFinish],
_socketEnd: [Object],
data: [Function],
readable: [Function],
close: [Function],
error: [Function] },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16384,
objectMode: false,
needDrain: false,
ending: true,
ended: true,
finished: true,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [] },
writable: false,
allowHalfOpen: false,
onend: null,
destroyed: true,
errorEmitted: false,
bytesRead: 36,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server:
{ domain: null,
_events: [Object],
_maxListeners: 10,
_connections: 0,
connections: [Getter/Setter],
_handle: [Object],
_usingSlaves: false,
_slaves: [],
allowHalfOpen: false,
maxConnections: 10,
_connectionKey: '4:0.0.0.0:5001' },
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 1441285231325,
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true,
write: [Function: writeAfterFIN] },
input: 'xx\r\u0001\u0003UH� \u0014t"\u0000\u000bR�\r\nxx\r\u0001\u0003UH� \u0014t"\u0000\u000bR�\r\n' }

@fvdm
Copy link
Owner

fvdm commented Sep 3, 2015

What brand and model is your tracker?

@jamrockmedz
Copy link
Author

@fvdm
Copy link
Owner

fvdm commented Sep 3, 2015

I updated the code to use binary input, please retry with npm install fvdm/nodejs-tk102#charset

@jamrockmedz
Copy link
Author

Incoming data:

7© t"

decoded data:

7© t"

Incoming data:

7© t"

decoded data:

7© t"

Trace: { [Error: uncaught exception]
error:
7© t"ypeError: Object xx
has no method 'copy'] }
at process.tk102.createServer.tk102.settings.(anonymous function) (/var/www/smart/smart/gps_module/test2/node_modules/tk102/tk102.js:79:11)
at process.EventEmitter.emit (events.js:95:17)
at process._fatalException (node.js:272:26)

Incoming data:

UH� t"»

decoded data:

UH� t"»

Incoming data:

UH� t"»

decoded data:

UH� t"»

Trace: { [Error: uncaught exception]
error:
UH� t"»peError: Object xx
has no method 'copy'] }
at process.tk102.createServer.tk102.settings.(anonymous function) (/var/www/smart/smart/gps_module/test2/node_modules/tk102/tk102.js:79:11)
at process.EventEmitter.emit (events.js:95:17)
at process._fatalException (node.js:272:26)

Incoming data:

UH� t"üÍ

decoded data:

UH� t"üÍ

@fvdm
Copy link
Owner

fvdm commented Sep 3, 2015

Hm I can't help you at this moment. To further investigate the data I need my laptop, but I only have my phone with me.

Is this a high priority issue for you or can it wait a couple of weeks?

@jamrockmedz
Copy link
Author

Okay, thank you for the assistance. Kinda high, but will try some more troubleshooting and get another model if necessary.

fvdm added a commit that referenced this issue Sep 3, 2015
`tk102.settings.encoding = 'binary';`
fvdm added a commit that referenced this issue Sep 3, 2015
fvdm added a commit that referenced this issue Sep 3, 2015
@fvdm
Copy link
Owner

fvdm commented Sep 3, 2015

OK. I added input conversion. Set with:

tk102.settings.encoding = 'ENC';

Where ENC is one of: binary, utf16, etc.
Does this give you any better results?

In your earlier data I see \r\n and \t, I hope that doesn't mean linebreaks and tabs. The device can be one of the many fakes with weird firmware.

@fvdm
Copy link
Owner

fvdm commented Sep 28, 2015

Hi @jamrockmedz, could you please retry with npm install fvdm/nodejs-tk102#develop?
I changed the way incoming data is handled.

@jamrockmedz
Copy link
Author

I believe the issue was with the firmware, i don't currently have those devices nearby. I however got two other tk102 device from a different manufacturer which do send readable characters to the server. The only issue with these new devices is that the data format is different from the common ones I have seen.

For example:
(027043348515BR00150928A1801.5454N07650.7534W000.32321030.000000000000L00000000)

I can see the date, imei, and coordinates but i am not quite sure which sections are the velocity and bearing.

@fvdm
Copy link
Owner

fvdm commented Nov 12, 2015

I now have a similar device with the same data format and it's pushing more weird data, I'm working on it.

@tedbear
Copy link

tedbear commented Nov 25, 2015

Hi fvdm,
I have the exact same problem as jamrockmedz and with the same device as you know apparently own. Have you gotten any further in regards to decode the data?

@fvdm
Copy link
Owner

fvdm commented Nov 25, 2015

Hi @tedbear, I managed to get 4 different strings from the device, one including the actual GPS position. Another is some sort of keepalive message. I think it may be possible to send commands from the server to the device to program it and switch features on and off remotely without SMS contact.

@natehudson
Copy link

Sorry to thread hijack as I have not personally seen the binary/encoding problem but I do have a clone/fake TK102 device with the same (027043348515BR00150928A1801.5454N07650.7534W000.32321030.000000000000L00000000) format.

After finding that this new? protocol was not support with any of the TK102 websites/code (that I could find) I have been working on decoding the basics of it.

The closet protocol docs was in a pdf I found titled "TK103 ALTERNATE protocol vs 2.1.pdf" on this random protocol cache https://docs.google.com/a/docs.gogle.com/folderview?id=0B9QofkYKWsMuZnIwZ1BqeXhzQlE#list

The translation is terrible but I have seen two similar commands from my device and broken out the basic gps coords:

  1. short_imei+BP00+long_imei+HS0 = They call: Uplink -> "Handshake signal Message"
    (in which the server should respond "AP01" to the client)
  2. short_imei+BR00+date+gpsLock?+LAT+LONG+whoKnows-heading-Alt-stuff? = They call it "Isochronous and continues feedback message"

Notes:

  • These are the only 2 commands I have seen my device send.
  • I have noticed that if my server stops sending the "AP01", the GPRS data will stop coming in.

Has anyone documented the full protocol / capabilities of these clones?

@lorenzosfarra
Copy link

Hi everyone,

I have not other information to share, just adding myself to the conversation, asking if you had time to work on it. I am trying to contact the seller, too, but I have doubts that he knows something about it...anyway, I will update the issue asap if I am able to obtain any news.

Thanks,
Lorenzo

@fvdm
Copy link
Owner

fvdm commented Jan 17, 2016

Hey everyone,

Thanks for joining!

I'm fieldtesting the TK102B while at the same time collecting gps and network data from my phone. By comparing the results I can figure out (kind of) the format of the data messages. I'll share my findings here too, soon.

@mirkods
Copy link

mirkods commented Mar 23, 2016

I have the same problem with the encoding, how can I fix it?

This is my output

{ [Error: Cannot parse GPS data from device]
  reason: 'Cannot parse GPS data from device',
  input: 'xx\r\u0001\u0003UH� \u0011�h\u0000=�5',
  connection: 
   { address: '0.0.0.0',
     family: 'IPv4',
     port: 8000,
     remoteAddress: '5.86.224.14',
     remotePort: 65068 } }

@mirkods
Copy link

mirkods commented Mar 25, 2016

@fvdm any update about it?

@fvdm
Copy link
Owner

fvdm commented Mar 28, 2016

Hi @mirkods, sorry no update yet.
My tracker died again, the quality of these devices is really really terrible.

@fvdm
Copy link
Owner

fvdm commented Jun 14, 2021

This project is no longer maintained. If anyone wishes to over please tell me in issue #36.

@fvdm fvdm closed this as completed Jun 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants