added send_packet script

pull/218/head
Felipe Herranz 2019-03-03 22:04:15 +01:00
rodzic 47f606396c
commit d369c0d31d
1 zmienionych plików z 35 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,35 @@
#!bin/bash
# UsbSerial
#
# This test generates a number of files specified by the user and send them through the serial port.
#
# args:
# -p: serial port (ttyUSB0, ttyUSB1..)
# -b: baud rate
# -t: number of times this test will be repeated
# -s: size of the random files generated for testing purposes
while getopts p:t:s:b: OPTION;
do
case $OPTION
in
p) PORT=$OPTARG;;
t) TIMES=$OPTARG;;
s) SIZE=$OPTARG;;
b) BAUD=$OPTARG;;
esac
done
stty -F $PORT $BAUD
for i in $(seq 1 $TIMES);
do
dd if=/dev/urandom of=$i bs=$SIZE count=1 status=none
echo "Packet $i of $SIZE was created"
cat $i > $PORT
echo "Packet $i of $SIZE was sent"
done
rm [0-9]*