shell - Arduino Serial Port with Bash -
i got arduino sketch writes binary data serial port. like:
0110101010010 01010100011011110 10101000110
these codes can have different lengths. now need bash script reads serial output line line,shows read codes spinner , appends codes textfile.
this came with: (relevant parts of script)
spinner() { local pid=$1 local delay=0.2 local spinstr='|/-\' while [ "$(ps | awk '{print $1}' | grep $pid)" ]; local temp=${spinstr#?} printf " [%c] " "$spinstr" local spinstr=$temp${spinstr%"$temp"} sleep $delay printf "\b\b\b\b\b\b" done printf " \b\b\b\b" } function monitor { trap ctrl_c int echo "starting monitor mode" echo "receiving..." stty -f $1 raw speed 9600 ( cat $1 ) & spinner $! } function ctrl_c() { echo -e "\naborting. collected keys saved." #save keys exit 0 }
the method show spinner taken : http://fitnr.com/showing-a-bash-spinner.html.
actually trying read serial output these 2 commands:
stty -f $1 raw speed 9600 ( cat $1 >> $keyfile) & spinner $!
unfortunately not work. here sample screenshot of codes send:
this output getting :
can me correct code desired behaviour (marked bold) can accomplished ?
edit: nevermind got working myself of this:
( tee -a < $1 $keyfile ) & spinner $!
Comments
Post a Comment