本帖最后由 simon2137 于 2019-12-12 17:49 编辑
几个月前看见dodojie大大traccar从零开始到完美使用完全教程,从买设备到搭平台这一系列流程实在是受益良多(我的途强GT550也是在青岛那家闲鱼店买的,老板很不错)。但是在使用的过程中我发现部分定位点会有漂移的现象,而且漂移的方向和距离大体都一致,所以我猜测肯定是因为什么未知的原因导致node-red转换坐标失败所致。于是我仔细看了GT06的协议文本,找出了原因和临时解决方法,因为两三句话也说不清楚,所以专门开了一贴来分享一下。
1.首先从traccar平台的历史轨迹可以看出某些坐标点非常有规律的漂移了。
2.比如2019-12-06 15:37:19这个时间有4个坐标点,只有第1个是对的,后面3个全部漂移了。
3.导出node-red里监听gt550服务那个节点的日志,可以看出这一段内容特别长(日志保存为文件用到了node-red-contrib-advance-logger节点,生成的时间戳似乎是UTC+0时区,正好和平台差了8小时)
4.分析日志中的数据部分,转换成16进制。78 78为起始位,0D 0A为停止位,这段数据正好分成4段。[120,120,34,34,19,12,6,7,36,45,204,3,43,223,236,11,107,153,0,55,212,30,1,204,0,7,115,0,26,251,1,0,0,0,66,68,242,13,10,120,120,34,34,19,12,6,7,36,55,203,3,43,232,212,11,107,159,16,62,212,31,1,204,0,129,116,0,40,51,1,0,0,0,67,250,105,13,10,120,120,34,34,19,12,6,7,37,5,204,3,43,242,156,11,107,165,112,66,212,30,1,204,0,129,116,0,40,51,1,0,0,0,68,37,90,13,10,120,120,34,34,19,12,6,7,37,15,204,3,43,252,64,11,107,171,240,61,212,30,1,204,0,51,99,0,83,224,1,0,0,0,69,53,226,13,10]
78,78,22,22,13,0C,06,07,24,2D,CC,03,2B,DF,EC,0B,6B,99,00,37,D4,1E,01,CC,00,07,73,00,1A,FB,01,00,00,00,42,44,F2,0D,0A
78,78,22,22,13,0C,06,07,24,37,CB,03,2B,E8,D4,0B,6B,9F,10,3E,D4,1F,01,CC,00,81,74,00,28,33,01,00,00,00,43,FA,69,0D,0A
78,78,22,22,13,0C,06,07,25,05,CC,03,2B,F2,9C,0B,6B,A5,70,42,D4,1E,01,CC,00,81,74,00,28,33,01,00,00,00,44,25,5A,0D,0A
78,78,22,22,13,0C,06,07,25,0F,CC,03,2B,FC,40,0B,6B,AB,F0,3D,D4,1E,01,CC,00,33,63,00,53,E0,01,00,00,00,45,35,E2,0D,0A
5.这下真相大白了,原来function-npm节点只考虑了正常的定位数据,而GT06设备有时候会把几段定位数据放在一个tcp包里面发出来,这似乎跟设备本身的网络中断后的数据补传机制有关。要解决也很简单,在function-npm之前加一个split节点就行了,设置成buffer按照固定长度39个字节来拆分。
[{"id":"bd236b68.2d9578","type":"split","z":"d04acc16.f6e38","name":"","splt":"39","spltType":"len","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":411,"y":420,"wires":[["c4771009.a41cb","45429509.72b85c","524c257.358c0dc"]]}]
6.把车开出去跑了一段时间,暂时没有发现有问题了
|