From ab26c0f6342d2f902745237e461888f0b56335f0 Mon Sep 17 00:00:00 2001 From: Lucas Herfurth Date: Wed, 7 Aug 2024 11:40:18 +0200 Subject: [PATCH] enc_err_counter: Added read and reset script wrappers fpr use without eb-mon. --- .../test/read-error-counter.sh | 51 +++++++++++++++++++ .../test/reset-error-counter.sh | 50 ++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100755 modules/enc_err_counter/test/read-error-counter.sh create mode 100755 modules/enc_err_counter/test/reset-error-counter.sh diff --git a/modules/enc_err_counter/test/read-error-counter.sh b/modules/enc_err_counter/test/read-error-counter.sh new file mode 100755 index 000000000..064638e46 --- /dev/null +++ b/modules/enc_err_counter/test/read-error-counter.sh @@ -0,0 +1,51 @@ +#!/bin/bash +dev=$1 +interface=$2 +addr="NULL" +vendor_id="0x00000651" +device_id="0x434e5452" + +function get_sensor_address() +{ + # Check address + addr=$(eb-find $dev $vendor_id $device_id) + if [ $? -ne 0 ]; then + echo "Error: Can't find device or module!" + exit 1 + else + echo "Info: Found device at $addr ..." + fi +} + +function read_enc_err_counter() +{ + if [ $interface -eq 1 ] + then + counterAddr=$addr + overflowAddr=$(($addr+4)) + else + counterAddr=$(($addr+8)) + overflowAddr=$(($addr+12)) + fi + counter=$(eb-read $dev $counterAddr/4) + overflowFlag=$(eb-read $dev $overflowAddr/4) + echo "Phy#1 counter: $counter overflow flag: $overflowFlag" +} + +if [ -z "$1" ] +then + echo "expecting non-optional argument: " + exit 1 +fi + +if [ -z "$2" ] +then + interface=1 +fi + +echo $interface + +get_sensor_address +read_enc_err_counter + +exit 0 diff --git a/modules/enc_err_counter/test/reset-error-counter.sh b/modules/enc_err_counter/test/reset-error-counter.sh new file mode 100755 index 000000000..3393b2aa1 --- /dev/null +++ b/modules/enc_err_counter/test/reset-error-counter.sh @@ -0,0 +1,50 @@ +#!/bin/bash +dev=$1 +interface=$2 +addr="NULL" +vendor_id="0x00000651" +device_id="0x434e5452" + +function get_sensor_address() +{ + # Check address + addr=$(eb-find $dev $vendor_id $device_id) + if [ $? -ne 0 ]; then + echo "Error: Can't find device or module!" + exit 1 + else + echo "Info: Found device at $addr ..." + fi +} + +function reset_enc_err_counter() +{ + if [ $interface -eq 1 ] + then + counterAddr=$addr + else + counterAddr=$(($addr+8)) + fi + eb-write $dev $counterAddr/4 0x00000001 + sleep 1 + eb-write $dev $counterAddr/4 0x00000000 + echo "Reset carried out. Check counter for confirmation." +} + +if [ -z "$1" ] +then + echo "expecting non-optional argument: " + exit 1 +fi + +if [ -z "$2" ] +then + interface=1 +fi + +echo $interface + +get_sensor_address +reset_enc_err_counter + +exit 0