Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions platform/jetson/scripts/check_cameras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@
# Logic lifted from the jetson_test.sh check_cameras() function.
# Usage: ./check_cameras.sh [num_cameras] (default 4)
# Returns: 0 if every camera streams, 1 if any camera fails.
# Per camera prints one parseable line: "/dev/videoN: OK - <fps>" or "/dev/videoN: FAILED: <reason>".

TOTAL_CAMERAS="${1:-4}" # number of CSI cameras to test
STREAM_COUNT=25 # frames to capture per camera

status=0
for ((i = 0; i < TOTAL_CAMERAS; i++)); do
echo "Testing /dev/video$i:"
# Capture frames to /dev/null and analyze what v4l2-ctl reports.
# Capture frames to /dev/null and parse what v4l2-ctl reports for this device.
output=$(v4l2-ctl --device=/dev/video$i --stream-mmap --stream-count=$STREAM_COUNT --stream-to=/dev/null 2>&1)

if [[ $output == *'VIDIOC_STREAMON returned -1'* ]]; then
echo "Camera /dev/video$i: ERROR detected."
echo "$output" | grep -i error # surface the error lines
if [ ! -e "/dev/video$i" ] || [[ $output == *'Cannot open device'* ]] || [[ $output == *'No such file'* ]]; then
echo "/dev/video$i: FAILED: not found"
status=1
elif [[ $output == *'fps'* ]]; then
echo "Camera /dev/video$i: SUCCESS - $(echo "$output" | grep -o '[0-9]*\.[0-9]* fps')"
echo "/dev/video$i: OK - $(echo "$output" | grep -o '[0-9]*\.[0-9]* fps' | head -1)"
else
echo "Camera /dev/video$i: FAILED to confirm status."
echo "/dev/video$i: FAILED: no frames"
status=1
fi
done
Expand Down
21 changes: 19 additions & 2 deletions platform/jetson/scripts/check_fan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ check_fan() {
echo "Fan set to 100% PWM (255)"
else
echo "Failed to set fan to 100% - insufficient privileges"
FAIL_REASON="cannot set pwm (privileges)"
fan_status=1
return $fan_status
fi
Expand All @@ -71,18 +72,21 @@ check_fan() {
# Critical check: RPM must be > 0 for fan to be considered working
if [ "$rpm_value" -eq 0 ]; then
echo "CRITICAL FAILURE: Fan RPM is 0 at 100% speed - Fan may be unplugged or broken!"
FAIL_REASON="rpm 0 at full speed"
fan_status=1
return $fan_status
elif [ "$rpm_value" -lt 500 ]; then
echo "WARNING: Fan RPM is very low ($rpm_value) at 100% speed - possible hardware issue"
fi
else
echo "FAILURE: Cannot read RPM sensor"
FAIL_REASON="cannot read rpm sensor"
fan_status=1
return $fan_status
fi
else
echo "FAILURE: RPM sensor not found"
FAIL_REASON="no rpm sensor"
fan_status=1
return $fan_status
fi
Expand Down Expand Up @@ -119,6 +123,7 @@ check_fan() {
# Critical check: RPM must always be > 0 during operation
if [ "$current_rpm" -eq 0 ]; then
echo "✗ CRITICAL FAILURE: RPM dropped to 0 - Fan disconnected or failed!"
FAIL_REASON="rpm dropped to 0 during ramp"
fan_status=1
break
fi
Expand Down Expand Up @@ -174,6 +179,7 @@ check_fan() {
# Critical check: RPM must always be > 0 during operation
if [ "$current_rpm" -eq 0 ]; then
echo "✗ CRITICAL FAILURE: RPM dropped to 0 - Fan disconnected or failed!"
FAIL_REASON="rpm dropped to 0 during ramp"
fan_status=1
break
fi
Expand All @@ -200,6 +206,7 @@ check_fan() {
echo "Maximum speed test WARNING - Fan RPM is $current_rpm (may be thermally limited)"
else
echo "Maximum speed test FAILED - Fan RPM is 0, fan disconnected!"
FAIL_REASON="rpm 0 at full speed"
fan_status=1
fi
fi
Expand Down Expand Up @@ -239,24 +246,34 @@ check_fan() {
fi
else
echo "Fan check FAILED - Invalid PWM value: $pwm_value"
FAIL_REASON="invalid pwm value"
fan_status=1
fi
else
echo "Fan check FAILED - PWM control file not found"
FAIL_REASON="no pwm1 control"
fan_status=1
fi
else
echo "Fan check FAILED - hwmon directory not found"
FAIL_REASON="no hwmon device"
fan_status=1
fi
else
echo "Fan check FAILED - PWM fan device not found"
FAIL_REASON="no pwm-fan device"
fan_status=1
fi

return $fan_status
}

# Run the fan check
# Run the fan check and emit a single parseable result line for the bench test to read.
check_fan
exit $?
result=$?
if [ "$result" -eq 0 ]; then
echo "fan: OK"
else
echo "fan: FAILED: ${FAIL_REASON:-check failed}"
fi
exit $result
Loading