Get unreadable string from GPS tracker

我只是一个虾纸丫 提交于 2019-12-13 22:36:22

问题


I'm getting this unreadable string from a GPS tracking device and I need to decode these information so I can use it in my application (c#).

$A  grQ05Ah@‘)���ÿÿûÿÿ����°#~À‚¡U

But in fact what i expect is something like below :

*HQ,XXXXXX,41,4#V1,time,A,**Lat**,N/S,**Lng**,W/E,000.00,000,date,FFFFFBFF,432,35,32448,334

How can i convert the string to standard format in c# ?

I convert data to byte as you can see :

24-41-20-20-67-72-51-30-35-41-68-40-91-29-3F-3F-3F-FF-FF-FB-FF-FF-3F-3F-3F-3F-B0-23-7E-C0-82-A1-55

回答1:


Its really some binary information and If you have clearly read out the product manual then it says formation of this binaries.

Converting the data to hex will give something like this..

24-41-20-20-67-72-51-30-35-41-68-40-91-29-3F-3F-3F-FF-FF-FB-FF-FF-3F-3F-

And then you need to refer the manual for exact meaning of these hex numbers

ex--(in some chinese devices)

2 bytes(24),  stand for standard mode
10 bytes,  is device'ID (41 20 20 67 72)
6 bytes, is time 
6 bytes, is data
8 bytes, is latitude
2 bytes, battery like this 06= 100% 05=80% 04=60% 03=40% 02=20% 01=10%
10 bytes is  longitude

** You are receiving these binaries because you've asked it to send the info in binary mode.




回答2:


It all depends how your string initially was encoded. But basic idea is using transform functions with required parameters.

You can use Encoding.GetString method of appropriate encoding.

For example if you know that original string was encoded in UTF-8 format before being transmitted to you, you may convert it to the string as

string converted = Encoding.UTF8.GetString(bytesReceived);



来源:https://stackoverflow.com/questions/38380404/get-unreadable-string-from-gps-tracker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!