Skip to content

Commit

Permalink
enc_err_counter: Added read and reset script wrappers fpr use without
Browse files Browse the repository at this point in the history
eb-mon.
  • Loading branch information
lherfurth committed Aug 7, 2024
1 parent f92fdfc commit ab26c0f
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
51 changes: 51 additions & 0 deletions modules/enc_err_counter/test/read-error-counter.sh
Original file line number Diff line number Diff line change
@@ -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: <device>"
exit 1
fi

if [ -z "$2" ]
then
interface=1
fi

echo $interface

get_sensor_address
read_enc_err_counter

exit 0
50 changes: 50 additions & 0 deletions modules/enc_err_counter/test/reset-error-counter.sh
Original file line number Diff line number Diff line change
@@ -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: <device>"
exit 1
fi

if [ -z "$2" ]
then
interface=1
fi

echo $interface

get_sensor_address
reset_enc_err_counter

exit 0

0 comments on commit ab26c0f

Please sign in to comment.