S-Jinn

Serial Communications Jinni

Overview
Command Reference
Examples
Sjinn Project Page

SourceForge Logo

Sample Scripts


dacq - starts and stops data acquisition.
dacqd - acquires data, creates daily files & adds timestamps to readings.

From the scripts directory:
  • Modify the rs232 command in 'dacqd' for your particular instrument
  • Modify the scan_rate value in 'dacqd' to specify time between measurements
  • Type './dacq start' to start data acquisition
  • Type 'tail -f mmddyyyy' where mmddyyyy are todays month, day, and year
  • You should see the data being written to the file
  • Press ctrl-c when you want to quit viewing the data
  • Type './dacq stop' when you want to stop aquiring data

dacq

dacq
#!/bin/bash
case "$1" in
start)
echo -n "Starting data acquisition: "
sleep 1
nohup ./dacqd &>/dev/null &
echo -n "dacq started at " >> dacqlog
date >> dacqlog
echo dacqd
;;
stop)
echo -n "Shutting down data acquisition: "
echo -n "dacq stopped at " >> dacqlog
date >> dacqlog
killall dacqd
echo dacqd
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

exit 0

dacqd

#!/bin/bash

# will store data in a file named mmddyyyy (current month, day, and year)
# and automatically create a new file for each day.
# readings will be timestamped in the format 'hh:mm.ss, reading'
# (hours, minutes, seconds, reading from instrument)
# dacq log will record start and stop times and stderr from sjinn

# set to number of secCheatsheetonds between readings
SCAN_TIME=3

while :
do
datestamp=`date "+%m%d%Y"`
timestamp=`date "+%H:%M.%S"`

# modify next 2 lines for your particular rs232 device
data=$(rs232 -b600 -p7n2 -s"\n" -r16 2>>dacqlog)
data=$(echo -n $data|awk '{print $2}')

echo $timestamp, $data >> $datestamp
sleep $SCAN _TIME
done

Notes

The single quotes around the date command are ` characters not ' characters.


Do you have a script using S-Jinn you'd be willing to share?
I'd like to hear from you. Submit examples to S-Jinn. or post to the project forums.