如何使用gpsdecode以可读的方式输出gpscat的结果?

如何使用gpsdecode以可读的方式输出gpscat的结果?

我通过 USB 串行端口连接到带有 GPS 的处理器。我一直在尝试做的是通过执行以下操作来读取 GPS 数据:

gpscat /dev/ttyS2 | gpsdecode

然而,它非常慢,很长一段时间后它输出:

130 root@gw-0317STLG0067 ~ # gpscat /dev/ttyS2 | gpsdecode            
:(
{"class":"SKY","device":"stdin","vdop":1.20,"hdop":1.20,"pdop":1.80,"satellites":[{"PRN":29,"el":28,"az":79,"ss":39,"used":false},{"PRN":31,"el":18,"az":204,"ss":18,"used":false}]}

当我终止该进程时,它输出如下:

close failed in file object destructor: 
sys.excepthook is missing 
lost sys.stderr

这是正确的命令吗?如果是这样,有什么问题吗?

编辑----新建

输出{“class”:“TPV”,“device”:“stdin”,“mode”:2,“lat”:50.782431667,“lon”:6.076753333} {“class”:“SKY”,“device”:“ stdin","卫星":[{"PRN":27,"el":86,"az":124,"ss":30,"used":false}]} {"class":"TPV", “设备”:“标准输入”,“模式”:2,“纬度”:50.782431667,“经度”:6.076753333} {“类”:“TPV”,“设备”:“标准输入”,“模式”:2,”纬度”:50.782431667,“经度”:6.076753333} {“类”:“TPV”,“设备”:“stdin”,“模式”:2,“纬度”:50.782431667,“经度”:6.076753333} {“类” :“TPV”,“设备”:“stdin”,“模式”:2,“时间”:“2017-07-17T14:52:13.000Z”,“ept”:0.005,“lat”:50.782431667,“lon ":6.076753333,"track":206.8000,"speed":0.000} {"class":"SKY","device":"stdin","vdop":1.60,"hdop":1.00,"pdop":2.00 ,"卫星":[{"PRN":7,"el":10,"az":289,"ss":19,"used":false},{"PRN":8,"el":54 ,"az":296,"ss":19,"used":false},{"PRN":10,"el":59,"az":122,"ss":43,"used":false },{"PRN":15,"el":11,"az":38,"ss":43,"used":false},{"PRN":27,"el":84,"az" :126,"ss":34,"used":false}]} {"class":"SKY","device":"stdin","vdop":1.60,"hdop":1.00,"pdop": 2.00,"卫星":[{"PRN":7,"el":10,"az":289,"ss":19,"used":false},{"PRN":8,"el": 54,"az":296,"ss":19,"used":false},{"PRN":10,"el":59,"az":122,"ss":43,"used":假},{"PRN":15,"el":11,"az":38,"ss":43,"使用":false},{"PRN":27,"el":84,"az ":126,"ss":34,"used":false},{"PRN":27,"el":84,"az":126,"ss":34,"used":false}]} {“class”:“SKY”,“device”:“stdin”,“vdop”:1.60,“hdop”:1.00,“pdop”:2.00,“卫星”:[{“PRN”:7,“el” :10,"az":288,"ss":17,"已使用":false},{"PRN":8,"el":55,"az":296,"ss":22,"已使用" :false},{"PRN":10,"el":60,"az":120,"ss":41,"used":false},{"PRN":15,"el":10,“az”:37,“ss”:45,“used”:false},{“PRN”:16,“el”:35,“az”:188,“ss”:25,“used”:false} ,{"PRN":18,"el":46,"az":70,"ss":40,"used":false},{"PRN":21,"el":23,"az": 71,"ss":38,"used":false},{"PRN":26,"el":10,"az":175,"ss":24,"used":false},{"PRN ":27,"el":84,"az":126,"ss":33,"used":false}]} {"class":"SKY","device":"stdin","vdop" :1.60,"hdop":1.00,"pdop":2.00,"卫星":[{"PRN":7,"el":10,"az":288,"ss":17,"used":false },{"PRN":8,"el":55,"az":296,"ss":22,"used":false},{"PRN":10,"el":60,"az" :120,"ss":41,"used":false},{"PRN":15,"el":10,"az":37,"ss":45,"used":false},{" PRN":16,"el":35,"az":188,"ss":25,"已使用":false},{"PRN":18,"el":46,"az":70," ss":40,"已使用":false},{"PRN":21,"el":23,"az":71,"ss":38,"已使用":false},{"PRN":26 ,"el":10,"az":175,"ss":24,"used":false},{"PRN":27,"el":84,"az":126,"ss":33 ,"used":false},{"PRN":70,"el":14,"az":23,"ss":25,"used":false},{"PRN":86,"el" :39,"az":82,"ss":32,"已使用":true},{"PRN":65,"el":0,"az":174,"ss":19,"已使用" :假},{“PRN”:71,“el”:47,“az”:70,“ss”:29,“使用”:true},{“PRN”:72,“el”:35,“ az":142,"ss":29,"used":true}]}假},{"PRN":10,"el":60,"az":120,"ss":41,"used":false},{"PRN":15,"el":10,"az ":37,"ss":45,"used":false},{"PRN":16,"el":35,"az":188,"ss":25,"used":false},{ "PRN":18,"el":46,"az":70,"ss":40,"used":false},{"PRN":21,"el":23,"az":71, "ss":38,"used":false},{"PRN":26,"el":10,"az":175,"ss":24,"used":false},{"PRN": 27,"el":84,"az":126,"ss":33,"used":false},{"PRN":70,"el":14,"az":23,"ss": 25,"使用":假},{"PRN":86,"el":39,"az":82,"ss":32,"使用":true},{"PRN":65,"el ":0,"az":174,"ss":19,"已使用":false},{"PRN":71,"el":47,"az":70,"ss":29,"已使用":true},{"PRN":72,"el":35,"az":142,"ss":29,"used":true}]}假},{"PRN":10,"el":60,"az":120,"ss":41,"used":false},{"PRN":15,"el":10,"az ":37,"ss":45,"used":false},{"PRN":16,"el":35,"az":188,"ss":25,"used":false},{ "PRN":18,"el":46,"az":70,"ss":40,"used":false},{"PRN":21,"el":23,"az":71, "ss":38,"used":false},{"PRN":26,"el":10,"az":175,"ss":24,"used":false},{"PRN": 27,"el":84,"az":126,"ss":33,"used":false},{"PRN":70,"el":14,"az":23,"ss": 25,"使用":假},{"PRN":86,"el":39,"az":82,"ss":32,"使用":true},{"PRN":65,"el ":0,"az":174,"ss":19,"已使用":false},{"PRN":71,"el":47,"az":70,"ss":29,"已使用":true},{"PRN":72,"el":35,"az":142,"ss":29,"used":true}]}

答案1

如果是这样,有什么问题吗?

出现就好像你正在终止 gpsdecode 进程一样曾是读取 gpscat 的输出。当它停止读取时,gpscat 的输出缓冲区已满。当终止信号到达 gpscat 进程时,python 尝试关闭非空输出句柄,但失败并显示该消息,如链接的 Stack Overflow 问答中所示。

为了避免此特定错误,您可以尝试终止 gpscat 进程而不是 gpsdecode 进程。

相关内容