#!/bin/sh

case "$1" in
	start)
		echo "Starting msposd..."
		devmem 0x1F207890 16 0x8
		sleep 1
		size=$(curl -s localhost/api/v1/config.json | jsonfilter -qe "@.video0.size")
		msposd -b 115200 -c 8 -r 20 -m /dev/ttyS2 -z "$size" > /dev/null &
		;;

	stop)
		echo "Stopping msposd..."
		killall -q msposd
		;;

	*)
		echo "Usage: $0 {start|stop}"
		exit 1
		;;
esac
