#!/bin/bash # Define the variables we are looking for VARS=("EPROG" "ESP_DEBUG" "ESP_SENSOR" "I2C_EMULATOR") echo "------------------------------------------------" echo "🔍 Starting ESP Hardware Verification..." echo "------------------------------------------------" FAILED=0 for VAR_NAME in "${VARS[@]}"; do # 1. Check if Environment Variable exists PORT_PATH="${!VAR_NAME}" if [ -z "$PORT_PATH" ]; then echo "❌ [ERROR]: \$$VAR_NAME is not set in environment." FAILED=1 continue fi # 2. Check if the device node exists if [ -e "$PORT_PATH" ]; then # 3. Check for Read/Write permissions if [ -r "$PORT_PATH" ] && [ -w "$PORT_PATH" ]; then TARGET=$(readlink -f "$PORT_PATH") echo "✅ [OK]: $VAR_NAME is active at $PORT_PATH -> ($TARGET)" else echo "⚠️ [PERM]: $VAR_NAME found at $PORT_PATH but NO R/W PERMISSION!" echo " Run: sudo chmod 666 $PORT_PATH" FAILED=1 fi else echo "❌ [MISSING]: $VAR_NAME ($PORT_PATH) is NOT connected." FAILED=1 fi done echo "------------------------------------------------" if [ $FAILED -eq 0 ]; then echo "🚀 ALL SYSTEMS GO: Ready for automation." exit 0 else echo "🛑 STOP: Please fix the errors above before running tests." exit 1 fi