I am trying to write a Bash script to receive a file of known number of Bytes (we are talking about 1MB) of binary data from a serial device connected to my embedded device. These bytes must then be saved to a file for later ops.
I've tried something like (stty raw; cat > blob.bin) < /dev/ttyS0 but I would like cat to stop when it reaches the number of Bytes I am expecting, as the script needs to progress on other functions when the file is complete.
The data flow will be started from the external device and it will run continuously until the the end of the binary file from the external device.
Working on Linux Buster, unfortunately I cannot use Python or other programming languages.
Thanks!
ddcommand and set a block size and count.