Update camera firmware

pull/1653/head
Ivan Ivanov 2025-01-04 03:44:01 +03:00
parent 5d87a96935
commit ed5ab7c3cd
4 changed files with 32 additions and 12 deletions

View File

@ -1,28 +1,51 @@
#!/bin/sh #!/bin/sh
DAEMON="Telemetry_Transfer" DAEMON="Telemetry_Transfer"
PIDFILE="/var/run/$DAEMON.pid" PIDFILE="/var/run/$DAEMON.pid"
COMMAND="socat UDP-RECV:2002 STDOUT | mcom -s 420000 /dev/ttyAMA0 | socat - udp-sendto:192.168.144.222:2001" LOG_DIR="/var/log/$DAEMON"
STDOUT_LOG="$LOG_DIR/stdout.log"
STDERR_LOG="$LOG_DIR/stderr.log"
COMMAND="socat UDP-RECV:2002 STDOUT | mcom -s 420000 /dev/ttyAMA0 2>>STDERR_LOG | socat - udp-sendto:192.168.144.201:5601 2>>STDERR_LOG "
# Ensure the log directory exists
[ ! -d "$LOG_DIR" ] && mkdir -p "$LOG_DIR"
start() { start() {
echo -n "Starting $DAEMON: " echo -n "Starting $DAEMON: "
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x /bin/sh -- -c "$COMMAND"
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x /bin/sh -- -c "$COMMAND" \
>> "$STDOUT_LOG" 2>> "$STDERR_LOG"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "OK" echo "OK"
else else
echo "FAIL" echo "FAIL"
fi fi
# Schedule the restart of S95telemetry after 30 seconds
(sleep 30 && /etc/init.d/S95telemetry restart) &
} }
stop() { stop() {
echo -n "Stopping $DAEMON: " echo -n "Stopping $DAEMON: "
start-stop-daemon -K -q -p "$PIDFILE"
if [ $? -eq 0 ]; then # Kill the process using the PID file
if start-stop-daemon -K -q -p "$PIDFILE"; then
rm -f "$PIDFILE" rm -f "$PIDFILE"
echo "OK" echo "OK"
else else
echo "FAIL" echo "FAIL"
fi fi
# Kill any remaining processes by checking COMMAND
for pattern in "UDP-RECV:2002" "mcom -s 420000" "udp-sendto:192.168.144.201:5601"; do
pids=$(ps | grep "$pattern" | grep -v grep | awk '{print $1}')
for pid in $pids; do
kill "$pid" 2>/dev/null
echo "Killed process $pid with pattern $pattern"
done
done
} }
restart() { restart() {
@ -31,22 +54,19 @@ restart() {
start start
} }
case "$1" in case "$1" in
start) start)
start start
;; ;;
stop) stop)
stop stop
;; ;;
restart|reload) restart|reload)
restart restart
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
;; ;;
esac esac

View File

@ -69,7 +69,7 @@ records:
maxUsage: 95 maxUsage: 95
outgoing: outgoing:
enabled: true enabled: true
server: udp://192.168.144.222:8000 server: udp://192.168.144.201:5600
watchdog: watchdog:
enabled: true enabled: true
timeout: 300 timeout: 300

View File

@ -29,7 +29,7 @@ null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
::sysinit:/etc/init.d/rcS ::sysinit:/etc/init.d/rcS
# Put a getty on the serial port # Put a getty on the serial port
console::respawn:/sbin/getty -L console 0 vt100 #console::respawn:/sbin/getty -L console 0 vt100
# Stuff to do before rebooting # Stuff to do before rebooting
::shutdown:/etc/init.d/rcK ::shutdown:/etc/init.d/rcK

View File

@ -2,4 +2,4 @@ auto eth0
iface eth0 inet static iface eth0 inet static
address 192.168.144.200 address 192.168.144.200
netmask 255.255.255.0 netmask 255.255.255.0
gateway 192.168.1.1 gateway 192.168.144.1