1 问题描述
I write a uart program using c++ on Jetson Nx(Jetpack 4.6.1,Ubuntu version 18.04 LTS) to communicate with a PC. On PC there’s a uart simulator( as below figure 1) sending data at a period of one second, 30 bytes data are : EB90021112131415161718191A1B1C1D1E1F202122232425262728292A2B
When my program receive the data, it will lost the first byte “EB”, and sometimes more bytes are lost. as show in figure 2:
Besides, I tried more tests:
1 C code check. I run my c code on a PC( Ubuntu 18.04.6 LTS os on a windows virtual machine), it doesn’t lost byte. As show in figure 3 above:
2 I changed my c code as below ,set a un-blocking mode, it will not lost any data. Thren I change back to blocking mode as below, it won’t lost any data; and then I restart the Nx, and run my original code(blocking mode), the lost first byte appears.
3 I tried two third party softwares on Nx to receive data, CuteCom won’t lost first data while MiniCom lost first byte, the same problem. Test figure as Figure 4 above:
(CuteCom not lost first byte, Note this tiem sending data are EB901f1112……1c1d)
Figure 5 (Mini Com Lost first byte ‘EB’, note sending data are eb901f1112…28cb146c)
2 解决措施
禁止掉服务nvgetty,通过以下命令:
$ sudo systemctl stop nvgetty.service
$ sudo systemctl disable nvgetty.service
3 问题解析
JetNx中默认会启动服务nvgetty。这个服务中会启动串口0,然后使用串口0通过TCU给上位机发送日志信息用的。
这个服务使用串口,导致影响了正常的一些通信,本例中就是一个问题,类似的还有一些权限等问题,也是由它引起的。
4 相关参考及知识
(1)nvgetty服务干什么用的
https://forums.developer.nvidia.com/t/do-we-ned-nvgetty-service/232140
(2)TCU解释 https://elinux.org/Jetson/AGX_Xavier_Tegra_Combined_UART