Raspberry Pi acquisition of IMU sensor data using basic server-client modelling
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

16 lines
903 B

#!/bin/bash
#Starting local nc server at background
(nc -l -p 9000 &) && echo "Server is running and accepting incoming connections at localhost:port 9000!"
#nodeserial.js will be executed to the background as to write serial data to a file that will be then sended to local nc
node nodeserial.js >> json_data.txt 2>/dev/null &
#if something fails inside nodeserial.js, e.g. with the parsing of JSON data, an attempt is made to restart nodeserial.js script.
while [ $? -ne 0 ]
do
sleep 1;
node nodeserial.js >> json.data.txt 2>/dev/null &
done
echo -e "Data from IMU sensor are now being send over to the server:\n\n"
#JSON data are now read continuously from file json_data.txt and are send with piped netcat to our local netcat instance
tail -f json_data.txt | nc 127.0.0.1 9000
#Job 1 now is brought to the foreground at standard output, i.e the local nc server with the json data received
fg 1