Index: scripts/globals.sh =================================================================== diff -u -r316fd0742fb841e3a6bb27fcc628240a262cb5a3 -r2d38e1a292732115e5884919d3dd7ae7152fa0ad --- scripts/globals.sh (.../globals.sh) (revision 316fd0742fb841e3a6bb27fcc628240a262cb5a3) +++ scripts/globals.sh (.../globals.sh) (revision 2d38e1a292732115e5884919d3dd7ae7152fa0ad) @@ -37,6 +37,7 @@ USB_MNT=/media/usb CLOUDSYNC_FOLDER=cloudsync # both for log and application +DRYDEMO_FOLDER=drydemo LOG_LOCATION=$HOME/Desktop LOG_OUT_FILE="" @@ -59,6 +60,7 @@ SRC_PATH_SCRIPTS="scripts" SRC_PATH_CONFIG="settings" SRC_PATH_CLOUDSYNC="cloudsync" +SRC_PATH_DRYDEMO="dry-demo" SRC_PATH_FONTS="fonts" DST_IP="" @@ -67,6 +69,7 @@ DST_PATH_HOME="/home/$DST_USER" DST_PATH_SCRIPTS="/home/$DST_USER/scripts" DST_PATH_CLOUDSYNC="/home/$DST_USER/cloudsync" +DST_PATH_CLOUDSYNC="/home/$DST_USER/dry-demo" DST_PATH_FONTS="/usr/share/fonts/truetype" POSTLOG=/tmp/post.log @@ -116,10 +119,32 @@ CLOUD_HOME=/home/$CLOUD_USER DENALI_USER=denali DENALI_HOME=/home/$DENALI_USER +DEMO_USER=root +DEMO_HOME=/home/$DEMO_USER SETTING_CONF_FOLDER_PATH=/var/configurations SETTINGS_CRC_FILE_PATH=$DENALI_HOME/settings.crc +DEMO_MODE=0 +P_CANBUS=can0 +V_CANBUS=can1 +D_CANBUS=$P_CANBUS + +function checkDemoMode() { + if [ -d "$DEMO_HOME/$DEMO_FOLDER" ]; then + DEMO_MODE=1 + fi +} + +# *** this function should be used without brackets in the if to be effective. +function isDemoMode() { + if [ "$DEMO_MODE" == "1" ]; then + return 0 # exit/return 0 for if in bash is true + else + return 1 # exit/return not 0 for if in bash is false + fi +} + function user_input() { read -p "$1? $2" -n 1 -r if [ "$CONTINUE" == "y" ]; then @@ -292,22 +317,43 @@ post_log "$(ip addr show $ieth)" # -details -statistics } -function setupCANBus() { +function setupPCAN() { #setting up can interface ----------------- CANBus post_log_dash " 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 + #$ ip -details -statistics link show $P_CANBUS + ip link set $P_CANBUS up type can bitrate 250000 restart-ms 100 + ifconfig $P_CANBUS txqueuelen 4000 +} + +function setupVCAN() { + modprobe vcan + ip link add dev $V_CANBUS type vcan + ip link set $V_CANBUS up +} + +function checkCANBus() { + candump $D_CANBUS -T1 # check if candump can successfully use the port. will terminate in 1ms if [ $? -eq 0 ]; then post_log_pass "$POSTMSG_CANBUS$POSTMSG_POSTFIX_PASSED" - post_log "$(ip link show can0)" # -details -statistics + post_log "$(ip link show $D_CANBUS)" # -details -statistics else post_log_fail "$POSTMSG_CANBUS$POSTMSG_POSTFIX_FAILED" fi } +function setupCANBus() { + # *** eliminated brackets are intentional. *** + if $(isDemoMode); then + D_CANBUS=$V_CANBUS + setupVCAN + else + D_CANBUS=$P_CANBUS # it is the default but kept to be consistent. + setupPCAN + fi + checkCANBus +} + function setupSDCard() { #mounting sdcard -------------------------- SD-CARD post_log_dash " SD-CARD " @@ -418,7 +464,6 @@ fi } - function testApplicationShasum_setup() { # ----------------------------------------- Sha256Sum post_log_dash " Sha256Sum " @@ -432,7 +477,6 @@ fi } - function testApplicationShasum_local() { # ----------------------------------------- Sha256Sum post_log_dash " Sha256Sum " @@ -446,15 +490,13 @@ fi } - function testCloudSystem() { # ----------------------------------------- CloudSystem post_log_dash " CloudSystem " post_log "$(ip addr show $iwlan)" # -details -statistics post_log "$(ping www.diality.staging.kebormed.com -I $iwlan -c 3 -4)" } - function startCloudSync_setup() { # ----------------------------------------- CloudSync post_log_dash " CloudSync " @@ -508,7 +550,6 @@ echo "" } - function startCloudSync_local() { # ----------------------------------------- CloudSync post_log_dash " CloudSync " @@ -542,20 +583,34 @@ fi } - function startApplication_local() { # ----------------------------------------- Denali post_log_dash " Denali " #launching denali application DENALI_VERSION="$($DENALI_HOME/$DENALI_BIN -v)" if [ -n "$DENALI_VERSION" ]; then post_log_pass "$DENALI_VERSION" # log UI Software version + # *** eliminated brackets are intentional. *** + if $(isDemoMode); then + APPLICATION_PARAMS="$APPLICATION_PARAMS"" -q -D -A $D_CANBUS" + fi sudo -u $DENALI_USER $DENALI_HOME/$DENALI_BIN $APPLICATION_PARAMS 1>> /tmp/denali.out 2>> /tmp/denali.out & else post_log_fail "Unknown Applicaion Version for $DENALI_HOME/$DENALI_BIN" fi } +function startDemoMode_local() { + # *** eliminated brackets are intentional. *** + if $(isDemoMode); then + # ----------------------------------------- Demo Mode + post_log_dash " Demo Mode " + local DRYDEMO_PATH=$DEMO_HOME/$DEMO_FOLDER + cd $DRYDEMO_PATH + ./run.py > $DRYDEMO_PATH.log & # create the log file at same level and name of the folder. + post_log "Dry-Demo Started" + fi +} function timerStart() { time_start=$(date +%s) @@ -574,6 +629,7 @@ setupConsoleout disableRootSSH cleanupPOSTLogs + checkDemoMode queryOSVersion setupCANBus setupResolved Index: scripts/run.sh =================================================================== diff -u -r3f328e08487912536ea5f9633014d08fd2010dac -r2d38e1a292732115e5884919d3dd7ae7152fa0ad --- scripts/run.sh (.../run.sh) (revision 3f328e08487912536ea5f9633014d08fd2010dac) +++ scripts/run.sh (.../run.sh) (revision 2d38e1a292732115e5884919d3dd7ae7152fa0ad) @@ -24,5 +24,6 @@ applicationPOST testApplicationShasum_local startCloudSync_local +startDemoMode_local startApplication_local timerEndLog Index: scripts/start.sh =================================================================== diff -u -rccddb9de7bc94036e130e034b1de67dca00e028d -r2d38e1a292732115e5884919d3dd7ae7152fa0ad --- scripts/start.sh (.../start.sh) (revision ccddb9de7bc94036e130e034b1de67dca00e028d) +++ scripts/start.sh (.../start.sh) (revision 2d38e1a292732115e5884919d3dd7ae7152fa0ad) @@ -20,10 +20,16 @@ source ./globals.sh +DEMO_SETUP=0 +DEMO_SWITCH="-D" +if [ "$2" == $DEMO_SWITCH ]; then + DEMO_SETUP=1 +fi + function displayHelp() { if [ "$1" = "-h" -o "$1" = "--help" ]; then echo -e "-h \t This help" - echo "usage start.sh [ [xxx] or [xxx.xxx.xxx.xxx] or [] ]" + echo "usage start.sh [ [xxx] or [xxx.xxx.xxx.xxx] ]" exit 0 fi } @@ -86,7 +92,7 @@ } function sshRun() { - ssh $SSH_PARAM $DST_USER@$DST_IP $1 + ssh $SSH_PARAM $DST_USER@$DST_IP $1:: return $? } @@ -230,6 +236,17 @@ copyFileTo $DENALI_BIN $DST_PATH_HOME } +function setupDemoMode() { + if [ $DEMO_SETUP != 0 ]; then return fi + echo_dash_comment + echo_dash_message "Installing Dry-Demo" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "killall python3" + sshRun "rm -frd $DST_PATH_DRYDEMO;" + sshRun "mkdir -p $DST_PATH_DRYDEMO;" + copyFolderTo $SRC_PATH_DRYDEMO $DST_PATH_DRYDEMO +} + function connect() { echo_dash_comment echo_dash_message "please ssh into device $DST_IP and run ./setup.sh" @@ -266,6 +283,7 @@ setupCloudSync setupFonts setupApplication + setupDemoMode } # running the main function