Index: scripts/run.sh =================================================================== diff -u -r7077e38c74db9cccb5496ffefcf8936c0916de76 -r3f555c49ddd2c983f469709e3c001d0e76159248 --- scripts/run.sh (.../run.sh) (revision 7077e38c74db9cccb5496ffefcf8936c0916de76) +++ scripts/run.sh (.../run.sh) (revision 3f555c49ddd2c983f469709e3c001d0e76159248) @@ -8,76 +8,119 @@ # # @file run.sh # -# @author (last) Behrouz NematiPour -# @date (last) 25-Aug-2020 -# @author (original) Behrouz NematiPour -# @date (original) 28-Oct-2019 +# @author (last) Behrouz NematiPour +# @date (last) 2-Aug-2021 +# @author (original) Behrouz NematiPour +# @date (original) 28-Oct-2019 # ############################################################################ + +function currDate() +{ + echo $(date +"%d%m%Y%H%M%S") +} + + HOME=/home/root SDCARD_DEV=/dev/mmcblk1p1 SDCARD_MNT=/media/sd-card USB_DEV=/dev/sda1 USB_MNT=/media/usb -LOG_PATH=$SDCARD_MNT +#DO NOT MODIFY POST VARIABLES +#unless the denali applicaiton is updated as well to match. +POSTLOG=$HOME/post.log +POSTMSG_CANBUS="CANBus passed" +POSTMSG_SDCARD="SD-CARD passed" +POSTMSG_TOUCH="Touch passed" +POSTMSG_RTC="RTC passed" + +# cleanup the POST log file +echo "Start: $(currDate)" > $POSTLOG + + #create folders for sd-card and usb if not exist mkdir -p $SDCARD_MNT mkdir -p $USB_MNT +# ---------------------------------------- UPDATE #mounting usb mount $USB_DEV $USB_MNT if [ $? -eq 0 ]; then echo ":: USB drive found and mounted on $USB_MNT" fi - #A simple none secure update -if [ -e $USB_MNT/denali ]; then - mv $HOME/denali $HOME/denali.$(date +"%d%m%Y%H%M%S") +if [ -e $USB_MNT/denali ]; then + mv $HOME/denali $HOME/denali.$(currDate) cp $USB_MNT/denali $HOME/denali - sync;sync;sync; - mv $USB_MNT/denali $USB_MNT/denali.updated - sync;sync;sync; + # check if update where successful + if [ $? -eq 0 ]; then + sync;sync;sync; + echo ":: Denali application has been updated with the one on the USB drive" + mv $USB_MNT/denali $USB_MNT/denali.updated + sync;sync;sync; + fi fi -# check if update where successful -if [ $? -eq 0 ]; then - echo ":: Denali application has been updated with the one on the USB drive" -fi +# ---------------------------------------- SETUP & POST +#Here only passed is logged and if nothing added to the post.log means it failed. -#setting up can interface -# current settings can be retrieved by the command below -# $ ip -details -statistics link show can0 +#setting up can interface ----------------- CANBus +#current settings can be retrieved by the command below +#$ ip -details -statistics link show can0 ip link set can0 up type can bitrate 250000 restart-ms 100 ifconfig can0 txqueuelen 4000 +candump can0 -T1 # check if candump can successfully use the port. will terminate in 1ms if [ $? -eq 0 ]; then - echo ":: Can interface setup" + echo $POSTMSG_CANBUS >> $POSTLOG fi -#mounting sdcard + +#mounting sdcard -------------------------- SD-CARD mount $SDCARD_DEV $SDCARD_MNT if [ $? -eq 0 ]; then - echo ":: SD-Card found and mounted on $SDCARD_MNT" -else - #setting the can log location - LOG_PATH=$HOME + SDTEST="$(mount | grep "$SDCARD_DEV on $SDCARD_MNT.*(rw,")" + if ! [ -z "$SDTEST" ]; then + echo $SDTEST >> $POSTLOG + echo $POSTMSG_SDCARD >> $POSTLOG + fi fi -echo ":: Log location set to $LOG_PATH" -#launching candump and setting the can log locations -#candump can0 1>$LOG_PATH/canmsg.log 2>$LOG_PATH/canmsg.err & -#if [ $? -eq 0 ]; then -# echo ":: candump launched" -#fi +#test the touch screen -------------------- Touch +#if loaded successful it has a long description with "Touch" keyword, 'T' capital. +#if fails has a one line error with "touch" keyword, 't' non-capital. +#if there is other issues can even be empty. +TSTEST="$(dmesg | grep Touch)" +if [ $? -eq 0 ]; then + echo $POSTMSG_TOUCH >> $POSTLOG +fi + + +#test the RTC ----------------------------- RTC +#may not be an accurate test but sufficient for now +#and couldn't find a way to get the rtc clock with the higher resolusion +#it should not be confused with date command which is system date/time and not hwclock +hwclock -r # if there is any issue with rtc hwclock will show errors +if [ $? -eq 0 ]; then + RTC1=$(cat /sys/class/rtc/rtc/since_epoch) + sleep 1 + RTC2=$(cat /sys/class/rtc/rtc/since_epoch) + if [ $(($RTC2 - $RTC1)) -eq 1 ]; then + echo $POSTMSG_RTC >> $POSTLOG + fi +fi + + # stop the connection manager daemon killall connmand # setup wifi killall wpa_supplicant >> $HOME/filesystem.out 2>> $HOME/filesystem.err #launching denali application, disable keep-alive -$HOME/denali -u & # 2>> $HOME/filesystem.err & +$HOME/denali -u & udhcpc -i eth0 -n & +echo "End: $(date +"%d%m%Y%H%M%S")" >> $POSTLOG