1

I'm working with a device connected to my PC via serial port.
When i send a command to this device (using putty or minicom) it send me back some output.
I would like to save this output (serial input of my PC) on a local file.
I found this workaround to do this:

-In the first terminal i type:

 cat -v /dev/ttyACM0 > filename

-In another terminal i type:

 echo -ne 'cat "filename"\n\r' > /dev/ttyACM

It works, but i'd like to automate the process with a single bash script.

./serialDownload.sh filename

I tried to put in background the first command before executing the second one but it doesn't work...

#!/bin/bash 


SERIAL_PORT="/dev/ttyACM0"
BAUDRATE=9600  

stty raw speed $BAUDRATE
./serialListen.sh $1& (->this put in background the first command)
sleep 2
echo -e 'cat "'$1'"\n\r' > $SERIAL_PORT

Thank you in advance for any kind of help!

3
  • 1
    duplicate: stackoverflow.com/questions/12990702/… Commented Jan 4, 2017 at 11:15
  • ...it doesn't really fix my problem but it gives me some good hints i have to work on..thank you! Commented Jan 4, 2017 at 12:57
  • Have you tried wait or sleep 1 at the end of the script? Commented Jan 4, 2017 at 14:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.