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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -