如何在启动时自动启动 GPSD?

Geo*_*y-c 5 configuration 16.04

我想弄清楚是什么阻止gpsd了通过 USB 自动连接到外部 GPS BU 353 加密狗并接收数据。我的两台笔记本电脑(硬件不同)都有同样的问题,所以这纯粹是软件配置问题。

我已经设法gpsd使用以下步骤手动工作,但每次我的机器断电时,我都必须再次执行这些步骤。

  1. sudo killall gpsd

  2. 删除任何gpsd可能留下的套接字:

    须藤rm /var/run/gpsd.sock

  3. 检查设备路径:

    dmesg - which shows PLU353 
    
    Run Code Online (Sandbox Code Playgroud)
  4. 确保没有其他程序正在使用该设备。没有列出

    lsof -n | grep /dev/ttyUSB0
    
    Run Code Online (Sandbox Code Playgroud)
  5. 手动启动gpsd

    sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
    
    Run Code Online (Sandbox Code Playgroud)
  6. xgps 看到 GPS 输出 - 所以这有效

我最好的猜测是gpsd需要加入一个组或获得额外的权限,或者,这是udev配置问题。但我在黑暗中胡思乱想,只是胡乱猜测。

wal*_*tor 8

你是对的 - 这是一个组成员身份问题。首先,看看谁拥有设备:

ls -l /dev/ttyUSB0
Run Code Online (Sandbox Code Playgroud)

在我的系统,我没有/dev/ttyUSB0,所以我将使用/dev/ttyS0替代

walt@bat:~(0)$ ls -l /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Feb 23 08:19 /dev/ttyS0
walt@bat:~(0)$ 
Run Code Online (Sandbox Code Playgroud)

ls命令的输出显示它归 拥有root:dialout,并允许对设备进行组访问。

使用以下命令将您的用户添加到dialout(或任何适合您系统的)组:

sudo adduser $USER dialout
Run Code Online (Sandbox Code Playgroud)

然后要使该组成员身份生效,注销/登录,或newgrp dialout使用该组成员身份启动 shell。

使用 来检查您的组成员身份/usr/bin/id


hey*_*ema 5

  • 在防火墙中打开 TCP 端口 2947(如果您希望其他网络客户端访问
  • terminal...
  • sudo adduser $USER dialout# 将用户添加到组 dialout
    • 注销/登录以完成 adduser 命令
  • sudo -H gedit /etc/default/gpsd# 编辑 gpsd 设置文件

# Start the gpsd daemon automatically at boot time
START_DAEMON="true"

# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="true"

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
# DEVICES="/dev/ttyUSB0"
DEVICES=""

# Other options you want to pass to gpsd
GPSD_OPTIONS=""
Run Code Online (Sandbox Code Playgroud)
  • 保存文件并退出 gedit
  • sudo systemctl restart gpsd#重启GPS

gpsmon、cgps 和 xgps 现在可以正常工作。