xtrx-sdr / images

Pre-built XTRX packages and firmware images
https://www.crowdsupply.com/fairwaves/xtrx
43 stars 27 forks source link

GPSD Permissions Issues #91

Open arzulo opened 3 years ago

arzulo commented 3 years ago

I'm having an issue with permissions between my XTRX and gpsd to try and read GPS data. No matter how I format permissions, I end up with the error...

sudo gpsd -D 5 -N -n /dev/ttyXTRX0
gpsd:INFO: launching (Version 3.20)
gpsd:IO: opening IPv4 socket
gpsd:IO: opening IPv6 socket
gpsd:INFO: listening on port gpsd
gpsd:PROG: NTP: shmat(14,0,0) succeeded, segment 0
gpsd:PROG: NTP: shmat(15,0,0) succeeded, segment 1
gpsd:PROG: NTP: shmat(16,0,0) succeeded, segment 2
gpsd:PROG: NTP: shmat(17,0,0) succeeded, segment 3
gpsd:PROG: NTP: shmat(18,0,0) succeeded, segment 4
gpsd:PROG: NTP: shmat(19,0,0) succeeded, segment 5
gpsd:PROG: NTP: shmat(20,0,0) succeeded, segment 6
gpsd:PROG: NTP: shmat(21,0,0) succeeded, segment 7
gpsd:PROG: successfully connected to the DBUS system bus
gpsd:PROG: shmget(0x47505344, 24024, 0666) for SHM export succeeded
gpsd:PROG: shmat() for SHM export succeeded, segment 22
gpsd:INFO: stashing device /dev/ttyXTRX0 at slot 0
gpsd:PROG: no /etc/gpsd/device-hook present, skipped running ACTIVATE hook
gpsd:INFO: SER: opening GPS data source type 2 at '/dev/ttyXTRX0'
gpsd:ERROR: SER: device open of /dev/ttyXTRX0 failed: Permission denied - retrying read-only
gpsd:ERROR: SER: read-only device open of /dev/ttyXTRX0 failed: Permission denied
gpsd:ERROR: initial GPS device /dev/ttyXTRX0 open failed
gpsd:ERROR: can't run with neither control socket nor devices open

I've gone through the setup at https://github.com/xtrx-sdr/images#non-root-access-for-devxtrx0 in order to have non-root access, as well as all other setup procedures in the images repo.
I also have gpsd and my user account included into the dialout group since I see that's what the XTRX is under.

I am able to see GPS data however by connection directly through serial via minicom -D /dev/ttyXTRX0

Any idea what's going on?

mind22 commented 2 years ago

I had the same problem and solved it by adding "XTRX" into the apparmor config file (Ubuntu 20.04).

Steps to do:

sudo nano /etc/apparmor.d/usr.sbin.gpsd

# add 'XTRX' after 'AMA' into following lines:

# ------------------------------------------------------------------------------
# common serial paths to GPS devices
/dev/tty{,S,USB,AMA,ACM,XTRX}[0-9]*    rw,

# default paths feeding GPS data into chrony
/{,var/}run/chrony.tty{,S,USB,AMA,XTRX}[0-9]*.sock rw,
/tmp/chrony.tty{,S,USB,AMA,XTRX}[0-9]*.sock rw,
# ------------------------------------------------------------------------------

sudo systemctl restart apparmor

# test gpsd if service disabled, else restart service gpsd
sudo gpsd -N -n -D 5 /dev/ttyXTRX0 /dev/pps0

br