#!/bin/sh # Functionality: # Slaves COM is sending a defined String to the same COM on Master. # Master is running a background process that # only returns what comes in. # Hint: "ori" = ORIginal; "rb" = ReadBack; "res" = RESult; "err" = ERRor #----------------------------------------------------------------------------- # PREPERATIONS #----------------------------------------------------------------------------- # Make shure that result Directory exists if [ ! -d /test/result ] then mkdir /test/result fi # Make shure that result file of Test does NOT exists if [ -s /test/result/bus1.res ] then rm /test/result/bus1.res fi # Make shure that error file of Test does NOT exists if [ -s /test/result/bus1.err ] then rm /test/result/bus1.err fi # Make shure that Original file of Test does NOT exists if [ -s /test/result/bus1.ori ] then rm /test/result/bus1.ori fi # Make shure that readback file of Test does NOT exists if [ -s /test/result/bus1.rb ] then rm /test/result/bus1.rb fi # Set up COM3 stty -F /dev/ttyS4 -echo -echoe -echok -echonl -echoprt -echoctl -echoke -ocrnl -icrnl -onlcr -opost crtscts clocal cread cs8 ignpar stty -F /dev/ttyS5 -echo -echoe -echok -echonl -echoprt -echoctl -echoke -ocrnl -icrnl -onlcr -opost crtscts clocal cread cs8 ignpar #----------------------------------------------------------------------------- # TEST WITH 19200 BAUD #----------------------------------------------------------------------------- # Message Baudrate to Log echo -e "Test bus1 with Baudrate: 19200\n\r" # Set Baudrate stty -F /dev/ttyS4 19200 stty -F /dev/ttyS5 19200 # Start a Backgroundprocess to receive something cat /dev/ttyS5 1>> /test/result/bus1.rb & sleep 1 # Send the defined String echo "This is BUS1 Test with 19200 Baud" > /dev/ttyS4 echo "This is BUS1 Test with 19200 Baud" 1>> /test/result/bus1.ori # Set Script-Process to Sleep to have time to receive something sleep 1 # After Receiving (Or Timeout), kill all Processes on CAT killall cat # Compare the read String with the original one diff /test/result/bus1.ori /test/result/bus1.rb 1>> /test/result/bus1.res 2>> /test/result/bus1.err #----------------------------------------------------------------------------- # TEST WITH 115200 BAUD #----------------------------------------------------------------------------- # Message Baudrate to Log echo -e "Test bus1 with Baudrate: 115200\n\r" # Set Baudrate stty -F /dev/ttyS4 115200 stty -F /dev/ttyS5 115200 # Start a Backgroundprocess to receive something cat /dev/ttyS5 1>> /test/result/bus1.rb & sleep 1 # Send the defined String echo "This is BUS1 Test with 115200 Baud" > /dev/ttyS4 echo "This is BUS1 Test with 115200 Baud" 1>> /test/result/bus1.ori # Set Script-Process to Sleep to have time to receive something sleep 1 # After Receiving (Or Timeout), kill all Processes on CAT killall cat # Compare the read String with the original one diff /test/result/bus1.ori /test/result/bus1.rb 1>> /test/result/bus1.res 2>> /test/result/bus1.err #----------------------------------------------------------------------------- # OUTPUT AND RESULT CALCULATION #----------------------------------------------------------------------------- # Display content of /test/result/bus1.res echo -e "\n\rContent of bus1.res" cat /test/result/bus1.res # Display content of /test/result/bus1.err echo -e "\n\rContent of bus1.err" cat /test/result/bus1.err # If comparison returned neither results nor errors, the copying and comparision was successful if [ ! -s /test/result/bus1.res -a ! -s /test/result/bus1.err ] then # Test was successful echo -e "\n\rBUS1 TEST-PASSED" echo "BUS1 TEST-PASSED" >> /test/result/bus1.res else # Test failed echo -e "\n\rBUS1 TEST-FAIL" echo "BUS1 TEST-FAILED" >> /test/result/bus1.res fi