Skip to content

Commit c35d677

Browse files
committed
app: script: Improve handling to trace stop
CMUX Modem traces should be stopped before any attempt to close the CMUX pipes. Otherwise it might hang up the ldattach utility. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent 75e93ce commit c35d677

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

app/scripts/sm_start_ppp.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,22 @@ fi
230230
sleep 3
231231

232232
stty -F $AT_CMUX clocal
233+
test -c $AT_CMUX
233234

235+
if [ $TRACE -gt 0 ]; then
236+
echo "Starting trace collection..."
237+
start-stop-daemon --start --pidfile $TRACE_PID_FILE --make-pidfile \
238+
--background --exec /bin/dd -- if=$MT_CMUX of=$MODEM_TRACE_FILE bs=1024
239+
fi
234240
echo "Connect and wait for PPP link..."
235-
test -c $AT_CMUX
236-
test $TRACE -gt 0 && start-stop-daemon --start --pidfile $TRACE_PID_FILE --make-pidfile --background --exec /bin/dd -- if=$MT_CMUX of=$MODEM_TRACE_FILE bs=1024
237241

238242
chat $CHATOPT -t$TIMEOUT "${CHAT_SCRIPT[@]}" >$AT_CMUX <$AT_CMUX
239243

240244
shutdown_modem() {
241245
set +eu
246+
start-stop-daemon --stop --pidfile $TRACE_PID_FILE --remove-pidfile --oknodo --retry 1
242247
chat $CHATOPT -t5 '' $SHUTDOWN_SCRIPT >$AT_CMUX <$AT_CMUX
243248
CHAT_ERR=$?
244-
start-stop-daemon --stop --pidfile $TRACE_PID_FILE --remove-pidfile --oknodo
245249
pkill ldattach
246250
sleep 1
247251
if [ "$CHAT_ERR" -ne 0 ]; then

app/scripts/sm_stop_ppp.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ PIDFILE="/var/run/nrf91-modem.pid"
88
PPP_PIDFILE="/var/run/ppp-nrf91.pid"
99
TRACE_PID_FILE="/var/run/nrf91-modem-trace.pid"
1010

11-
# Request PPPD to terminate
12-
if [ -f $PPP_PIDFILE ]; then
13-
echo "Stopping PPP link..."
14-
kill -SIGTERM $(head -1 <$PPP_PIDFILE)
15-
fi
16-
1711
# Stop trace collection
1812
if [ -f $TRACE_PID_FILE ]; then
1913
echo "Stopping trace collection..."
20-
kill $(cat $TRACE_PID_FILE) 2>/dev/null || true
21-
rm -f $TRACE_PID_FILE
14+
start-stop-daemon --stop --pidfile $TRACE_PID_FILE --remove-pidfile --oknodo --retry 1
15+
fi
16+
17+
# Request PPPD to terminate
18+
if [ -f $PPP_PIDFILE ]; then
19+
echo "Stopping PPP link..."
20+
start-stop-daemon --stop --pidfile $PPP_PIDFILE
2221
fi
2322

2423
# Wait for Shutdown script to complete

0 commit comments

Comments
 (0)