After restarting gpsd.service, the /dev/ttyACM0.pty file becomes inaccessible

In presence of gnss-monitor ptp-instance monitoring a device (/dev/ttyACM0),
gpspipe@.service connects to gpsd daemon and provides NMEA output in
/dev/ttyACM0.pty file. When gpsd.service daemon restarted, gpspipe@.service
exits with success return-code and not restarted, causing the output
file unavailable.

This commit fixes the issue by restarting the gpspipe@.service always,
whether the return-code be success or failure.

Test Plan:
  PASS: Deploy gnss-monitor ptp-instance with device /dev/ttyACM0
        - /dev/ttyACM0.pty file is accessible
        - systemctl restart gpsd.service
          /dev/ttyACM0.pty file accessible.
          gpspipe@-dev-ttyACM0.service is running (get restarted)
  PASS: stop gpsd.service, gpspipe service automatically restarts
        gpsd.service too, and /dev/ttyACM0.pty file accessible
  PASS: stop gpsd.socket, gpspipe service keep restarting, until
        gpsd.socket started again.
  PASS: Test same as above for two devices, after following:
       system ptp-instance-parameter-delete gnss0 'devices=/dev/ttyACM0'
       system ptp-instance-parameter-add gnss0 'devices=/dev/ttyACM0 /dev/ttyACM1'
       system ptp-instance-apply

Closes-bug: 2126965

Change-Id: I445f99e548b96b0bbee4d35dfa31e2c4e3c768ca
Signed-off-by: Tara Nath Subedi <tara.subedi@windriver.com>
This commit is contained in:
Tara Subedi
2025-10-06 15:28:11 -04:00
parent 99336c0788
commit 922928bbec

View File

@@ -7,7 +7,8 @@ Type=simple
ExecStart=/bin/bash -c 'python /usr/rootdirs/opt/collectd/extensions/python/gpspipe.py -r localhost:2947:%I | socat - PTY,link=%I.pty,raw,echo=0'
ExecStartPost=/bin/bash -c 'echo $MAINPID > /var/run/gnss-monitor-%i.pid'
ExecStopPost=/bin/rm -f /var/run/gnss-monitor-%i.pid
Restart=on-failure
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target