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:

correct codes

this output getting :

wrong codes

can me correct code desired behaviour (marked bold) can accomplished ?

edit: nevermind got working myself of this:

( tee -a < $1 $keyfile ) & spinner $! 


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -