技术专栏
nvidia nx平台传递GPS信息调试
1. 前言
尝试一种从Jertson传递GPS信息到微软Azure物联网中心的方法
Jetson上安装Azure IoT SDK:
https://github.com/Azure/azure-iot-sdks#microsoft-azure-iot-sdks-1
- 1
使用诸如MQQT之类的消息代理传递GPS的非microsoft方法
DeepStream与Azure IoT框架集成(它也支持MQQT):
https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvmsgbroker.html
- 1
2. 转发/dev/pts/26
它不是很清楚如何使用元数据缓冲区,因为我只是想转发像/dev/pts/26输出与它,对吗?
terminal 1:
nvidia@nx_xavier:~$ socat -d -d pty,raw,echo=0 pty,raw,echo=0
2021/05/06 13:13:55 socat[23720] N PTY is /dev/pts/25
2021/05/06 13:13:55 socat[23720] N PTY is /dev/pts/26
2021/05/06 13:13:55 socat[23720] N starting data transfer loop with FDs [5,5] and [7,7]
- 1
- 2
- 3
- 4
- 5
terminal 2:
sudo apt install csh -y
wget https://iweb.dl.sourceforge.net/project/gpsfeed/gpsfeed-latest.zip
unzip gpsfeed-latest.zip
nvidia@nx_xavier:~$ tclsh8.6 gpsfeed+.tcl
- 1
- 2
- 3
- 4
- 5
例如:
in serial section goes代替default COM1→/dev/pts/25;波特率→9600
- 1
然后在第二个GUI窗口=按play[在左上角-一个圆点在中心的圆圈图标;]
从第三个终端可以看到GPS信号
~$ cat /dev/pts/26
$GPGGA,180756,3756.2421,N,02346.8948,E,1,04,5.6,724.4,M,34.5,M,,*43
$GPRMC,180756,A,3756.2421,N,02346.8948,E,,,060521,5,E,A*01
$GPGGA,180758,3751.4936,N,02349.1123,E,1,04,5.6,384.3,M,34.5,M,,*4D
$GPRMC,180758,A,3751.4936,N,02349.1123,E,9109.2,159.8,060521,5,E,A*30
$GPGGA,180800,3747.8756,N,02353.0000,E,1,04,5.6,134.0,M,34.5,M,,*4C
$GPRMC,180800,A,3747.8756,N,02353.0000,E,8541.7,139.7,060521,5,E,A*3E
$GPGGA,180802,3745.9547,N,02358.0261,E,1,04,5.6,9.7,M,34.5,M,,*49
$GPRMC,180802,A,3745.9547,N,02358.0261,E,7942.4,115.8,060521,5,E,A*31
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
想尝试绕过DeepStream来传递GPS信息
如果您想绕过DeepStream,那么似乎可以选择安装Azure IoT SDK并使用它
或者直接使用MQTT之类的消息代理
看起来有一个Python包paho-mqtt
3. 订阅paho-mqtt到/dev/pts/26
没有确切的步骤如何加载输出/dev/pst/26
例如paho mqqt
Dockerfile很简单
FROM alpine
RUN apk update
RUN apk add mosquitto
CMD /usr/sbin/mosquitto
- 1
- 2
- 3
- 4
- 5
- 6
这张图片使用Alpine作为基础,然后添加mosquitto
最后,它使用CMD值启动代理
要构建它,运行以下命令:
docker build -t mosquitto -f Dockerfile.mosquitto .
- 1
要在默认网络上运行:
docker run -it --rm --name mosquitto -p 1883:1883 mosquitto
- 1
想要找出的是如何准确地订阅paho-mqtt到/dev/pts/26
这就是想要弄清楚的,可能应该有一个简单的命令来做这件事
应该有这样的命令
python
import paho-mqtt
- 1
- 2
4. 脚本编写
需要在Python中打开/dev/tty文件
(如果需要,也可以使用pyserial模块)
并以编程方式提取数据,以便为代理构造消息
或者可能有一些命令行工具可以从其他文件中转消息
cat pts_v2.py
import sys
with open("/dev/pts/26", "wb+", buffering=0) as term:
while True:
print(term.read(26).decode(), end='')
sys.stdout.flush()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
python3 pts_v2.py
$GPGGA,191157,3756.8819,N,02404.8014,E,1,04,5.6,455.4,M,34.5,M,,*4D
$GPRMC,191157,A,3756.8819,N,02404.8014,E,3442.9,42.0,060521,5,E,A*04
$GPGGA,191159,3758.8726,N,02405.7998,E,1,04,5.6,809.2,M,34.5,M,,*4E
$GPRMC,191159,A,3758.8726,N,02405.7998,E,3853.2,21.6,060521,5,E,A*00
$GPGGA,191201,3801.1623,N,02405.9797,E,1,04,5.6,1190.8,M,34.5,M,,*73
$GPRMC,191201,A,3801.1623,N,02405.9797,E,4129.4,3.5,060521,5,E,A*39
$GPGGA,191203,3803.4176,N,02405.2627,E,1,04,5.6,1544.6,M,34.5,M,,*73
$GPRMC,191203,A,3803.4176,N,02405.2627,E,4184.8,345.9,060521,5,E,A*3C
$GPGGA,191205,3805.2904,N,02403.7043,E,1,04,5.6,1819.2,M,34.5,M,,*7E
$GPRMC,191205,A,3805.2904,N,02403.7043,E,4029.8,326.8,060521,5,E,A*32
$GPGGA,191207,3806.4714,N,02401.4940,E,1,04,5.6,1974.4,M,34.5,M,,*71
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
但缺少与消息代理的集成
5. 例子
#! /usr/bin/python
# Based on
# Written by Dan Mandle http://dan.mandle.me September 2012
# License: GPL 2.0
import os
from gps import *
from time import *
import time
import threading
import json
import paho.mqtt.client as paho
gpsd = None
class GpsPoller(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
global gpsd #bring it in scope
gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
<
docker run -it --rm --name mosquitto -p 1883:1883 mosquitto
- 1
然后尝试修改代码,这样它就会与mosquitto一致
import os
from gps import *
from time import *
import time
import threading
import json
import paho.mqtt.client as mqtt
MQTT_BROKER = os.getenv('MQTT')
gpsd = None
class GpsPoller(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
global gpsd #bring it in scope
gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info
self.current_value = None
self.running = True #setting the thread running to true
def run(self):
global gpsd
while gpsp.running:
gpsd.next() #this will continue to loop and grab EACH set of gpsd info to clear the buffer
if __name__ == '__main__':
gpsp = GpsPoller() # create the thread
try:
gpsp.start() # start it up
while True:
if gpsd.fix.latitude > 0:
row = [ { 'latitude': str(gpsd.fix.latitude),
'longitude': str(gpsd.fix.longitude),
'utc': str(gpsd.utc),
'time': str(gpsd.fix.time),
'altitude': str(gpsd.fix.altitude),
'eps': str(gpsd.fix.eps),
'epx': str(gpsd.fix.epx),
'epv': str(gpsd.fix.epv),
'ept': str(gpsd.fix.ept),
'speed': str(gpsd.fix.speed),
'climb': str(gpsd.fix.climb),
'track': str(gpsd.fix.track),
'mode': str(gpsd.fix.mode)} ]
json_string = json.dumps(row)
client = mqtt.Client("P1")
client.connect(MQTT_BROKER)
client.publish("gps", payload=json_string, qos=0, retain=True)
time.sleep(60)
except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
gpsp.running = False
gpsp.join() # wait for the thread to finish what it's doing
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
<
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包
92
收藏
评论
打赏
- 分享
- 举报
评论
0个
手气红包

相关专栏
-
浏览量:7346次2021-07-31 15:26:23
-
浏览量:8769次2021-05-14 14:43:43
-
浏览量:9582次2021-04-27 17:56:41
-
浏览量:7583次2021-05-11 17:51:48
-
浏览量:9741次2021-05-26 14:17:15
-
2021-05-06 16:03:00
-
浏览量:11067次2021-05-06 16:22:01
-
浏览量:5336次2021-05-10 17:48:42
-
浏览量:7203次2021-05-11 17:04:57
-
浏览量:7641次2021-05-20 17:08:14
-
浏览量:9585次2021-05-25 17:31:40
-
浏览量:9420次2021-05-19 17:32:00
-
浏览量:8111次2021-05-25 15:32:16
-
浏览量:7227次2021-05-20 16:37:42
-
2021-07-30 17:20:54
-
2021-07-30 17:04:37
-
2021-04-23 15:54:21
-
浏览量:9601次2021-07-21 16:55:40
-
浏览量:7122次2021-01-22 15:28:47
切换马甲
上一页
下一页
打赏用户
共 1 位
我要创作
分享技术经验,可获取创作收益
分类专栏
-
178篇
热门专栏
- 从大众到劳斯莱斯,日内瓦车展上的新车全部采用NVIDIA技术
- xavier nx 平台 EQOS LAN端口连接异常问题调试2
- 英伟达将取消的RTX 4080恢复为“新”12GB RTX 4070 TI
- Nvidia 通过 Project GR00T 涉足人形机器人领域
- 准备接招吧!你必须知道的《魔兽世界•德拉诺之王》
- nvidia xaiver平台四路camera同步采集调试
- 铁杆儿Nfan齐聚一堂 NVIDIA展台精彩不停歇
- 零售商们的新宠:边缘计算和AI
- 四倍粒子浓度!《无主之地:前传》PhysX特效展示
- NVIDIA Tegra K1设备包揽Futuremark 12月GPU榜单前三甲!
置顶时间设置
结束时间
删除原因
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
打赏作者
free-jdx
您的支持将鼓励我继续创作!
打赏金额:
¥1

¥5

¥10

¥50

¥100

支付方式:

举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
审核成功
发布时间设置
发布时间:
请选择发布时间设置
是否关联周任务-专栏模块
审核失败
失败原因
请选择失败原因
备注
请输入备注