#!/bin/bash
#./xilinx-reg-read-reader $DEV

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

if [ -z "$1" ]
then
    echo "No device specified. use xilinx0 as deault."
    DEV="xilinx0"
else
    DEV="$1"
fi

if [ -z "$2" ]
then
    echo "No show specified. use sh $DIR/table -15 -red,-green,-blue as deault."
    SHOW="sh $DIR/table -15 -red,-green,-blue"
else
    SHOW="$2"
fi

echo -e "~~~~~~~~~~~~~~~~~~~~~ Version Info ~~~~~~~~~~~~~~~~~~~~~
Ver Compile Date                                 \t 0x0005  \t $(printf '%x' $($DIR/reg-read $DEV 0x0005))
Ver Compile Version                              \t 0x0004  \t $(printf '%x' $($DIR/reg-read $DEV 0x0004))
~~~~~~~~~~~~~~~~~~~~~ Fiber State Info ~~~~~~~~~~~~~~~~~~~~~
Fiber State                                      \t 0x2030  \t $(printf '%x' $($DIR/reg-read $DEV 0x2030))
Enter optical port 0 full packet statistics      \t 0x12000 \t $($DIR/reg-read $DEV 0x12000)
Enter optical port 0 UDP packet statistics       \t 0x12001 \t $($DIR/reg-read $DEV 0x12001)
Enter optical port 0 shfe2ps packet statistics   \t 0x12002 \t $($DIR/reg-read $DEV 0x12002)
Enter optical port 0 ine2ps packet statistics    \t 0x12003 \t $($DIR/reg-read $DEV 0x12003)
Enter optical port 0 shfe4ps packet statistics   \t 0x12004 \t $($DIR/reg-read $DEV 0x12004)
Enter optical port 0 ine4ps packet statistics    \t 0x12005 \t $($DIR/reg-read $DEV 0x12005)
Enter optical port 1 full packet statistics      \t 0x12006 \t $($DIR/reg-read $DEV 0x12006)
Enter optical port 1 UDP packet statistics       \t 0x12007 \t $($DIR/reg-read $DEV 0x12007)
Enter optical port 1 shfe2ps packet statistics   \t 0x12008 \t $($DIR/reg-read $DEV 0x12008)
Enter optical port 1 ine2ps packet statistics    \t 0x12009 \t $($DIR/reg-read $DEV 0x12009)
Enter optical port 1 shfe4ps packet statistics   \t 0x1200a \t $($DIR/reg-read $DEV 0x1200a)
Enter optical port 1 ine4ps packet statistics    \t 0x1200b \t $($DIR/reg-read $DEV 0x1200b)
Enter optical port 2 full packet statistics      \t 0x22000 \t $($DIR/reg-read $DEV 0x22000)
Enter optical port 2 UDP packet statistics       \t 0x22001 \t $($DIR/reg-read $DEV 0x22001)
Enter optical port 2 shfe2ps packet statistics   \t 0x22002 \t $($DIR/reg-read $DEV 0x22002)
Enter optical port 2 ine2ps packet statistics    \t 0x22003 \t $($DIR/reg-read $DEV 0x22003)
Enter optical port 2 shfe4ps packet statistics   \t 0x22004 \t $($DIR/reg-read $DEV 0x22004)
Enter optical port 2 ine4ps packet statistics    \t 0x22005 \t $($DIR/reg-read $DEV 0x22005)
Enter optical port 3 full packet statistics      \t 0x22006 \t $($DIR/reg-read $DEV 0x22006)
Enter optical port 3 UDP packet statistics       \t 0x22007 \t $($DIR/reg-read $DEV 0x22007)
Enter optical port 3 shfe2ps packet statistics   \t 0x22008 \t $($DIR/reg-read $DEV 0x22008)
Enter optical port 3 ine2ps packet statistics    \t 0x22009 \t $($DIR/reg-read $DEV 0x22009)
Enter optical port 3 shfe4ps packet statistics   \t 0x2200a \t $($DIR/reg-read $DEV 0x2200a)
Enter optical port 3 ine4ps packet statistics    \t 0x2200b \t $($DIR/reg-read $DEV 0x2200b)
~~~~~~~~~~~~~~~~~~~~~ Configuration Status Info ~~~~~~~~~~~~~~~~~~~~~
Port 0 destination IP -- future 2p/s            \t 0x11100 \t $($DIR/reg-read $DEV 0x11100)
Port 0 destination IP -- energy 2p/s            \t 0x11101 \t $($DIR/reg-read $DEV 0x11101)
Port 0 UDP destination port -- future 2p/s       \t 0x11102 \t $($DIR/reg-read $DEV 0x11102)
Port 0 UDP destination port -- energy 2p/s       \t 0x11103 \t $($DIR/reg-read $DEV 0x11103)
Port 1 destination IP -- future 2p/s             \t 0x11104 \t $($DIR/reg-read $DEV 0x11104)
Port 1 destination IP -- energy 2p/s             \t 0x11105 \t $($DIR/reg-read $DEV 0x11105)
Port 1 UDP destination port -- future 2p/s       \t 0x11106 \t $($DIR/reg-read $DEV 0x11106)
Port 1 UDP destination port -- energy 2p/s       \t 0x11107 \t $($DIR/reg-read $DEV 0x11107)
Port 0 destination IP -- future 4p/s             \t 0x21100 \t $($DIR/reg-read $DEV 0x21100)
Port 0 destination IP -- energy 4p/s             \t 0x21101 \t $($DIR/reg-read $DEV 0x21101)
Port 0 UDP destination port -- future 4p/s       \t 0x21102 \t $($DIR/reg-read $DEV 0x21102)
Port 0 UDP destination port -- energy 4p/s       \t 0x21103 \t $($DIR/reg-read $DEV 0x21103)
Port 1 destination IP -- future 4p/s             \t 0x21104 \t $($DIR/reg-read $DEV 0x21104)
Port 1 destination IP -- energy 4p/s             \t 0x21105 \t $($DIR/reg-read $DEV 0x21105)
Port 1 UDP destination port -- future 4p/s       \t 0x21106 \t $($DIR/reg-read $DEV 0x21106)
Port 1 UDP destination port -- energy 4p/s       \t 0x21107 \t $($DIR/reg-read $DEV 0x21107)
Update shfe2ps packet_no                         \t 0x11110 \t $($DIR/reg-read $DEV 0x11110)
Update ine2ps packet_no                          \t 0x11111 \t $($DIR/reg-read $DEV 0x11111)
packet_no out-of-order timeout 2p/s              \t 0x11112 \t $($DIR/reg-read $DEV 0x11112)
Update shfe4ps packet_no                         \t 0x21110 \t $($DIR/reg-read $DEV 0x21110)
Update ine4ps packet_no                          \t 0x21111 \t $($DIR/reg-read $DEV 0x21111)
packet_no out-of-order timeout 4p/s              \t 0x21112 \t $($DIR/reg-read $DEV 0x21112)
Business logic enable signal indication          \t 0x1120 \t $($DIR/reg-read $DEV 0x1120)
~~~~~~~~~~~~~~~~~~~~~ 2ps Statistics Info ~~~~~~~~~~~~~~~~~~~~~
Mux0 received a valid UDP packet from MAC0       \t 0x12010 \t $($DIR/reg-read $DEV 0x12010)
Mux0 received a valid UDP packet from MAC1       \t 0x12011 \t $($DIR/reg-read $DEV 0x12011)
MIRP message sent by mux0                        \t 0x12012 \t $($DIR/reg-read $DEV 0x12012)
The latest MAC0 packet_no received by mux0       \t 0x12013 \t $($DIR/reg-read $DEV 0x12013)
The latest MAC1 packet_no received by mux0       \t 0x12014 \t $($DIR/reg-read $DEV 0x12014)
Mux0 optimized packet_no                         \t 0x12015 \t $($DIR/reg-read $DEV 0x12015)
Mux1 received a valid UDP packet from MAC0       \t 0x12016 \t $($DIR/reg-read $DEV 0x12016)
Mux1 received a valid UDP packet from MAC1       \t 0x12017 \t $($DIR/reg-read $DEV 0x12017)
MIRP message sent by mux1                        \t 0x12018 \t $($DIR/reg-read $DEV 0x12018)
The latest MAC0 packet_no received by mux1       \t 0x12019 \t $($DIR/reg-read $DEV 0x12019)
The latest MAC1 packet_no received by mux1       \t 0x1201a \t $($DIR/reg-read $DEV 0x1201a)
Mux1 optimized packet_no                         \t 0x1201b \t $($DIR/reg-read $DEV 0x1201b)
Mux0 optimizes the num of MAC0                   \t 0x1201c \t $($DIR/reg-read $DEV 0x1201c)
Mux0 optimizes the num of MAC1                   \t 0x1201d \t $($DIR/reg-read $DEV 0x1201d)
Mux1 optimizes the num of MAC0                   \t 0x1201e \t $($DIR/reg-read $DEV 0x1201e)
Mux1 optimizes the num of MAC1                   \t 0x1201f \t $($DIR/reg-read $DEV 0x1201f)
Mux0 optimization future 2p/s num                \t 0x12020 \t $($DIR/reg-read $DEV 0x12020)
Mux0 optimization energy 2p/s num                \t 0x12021 \t $($DIR/reg-read $DEV 0x12021)
Mux0 received a valid UDP packet from MAC2       \t 0x12022 \t $($DIR/reg-read $DEV 0x12022)
Mux0 received a valid UDP packet from MAC3       \t 0x12023 \t $($DIR/reg-read $DEV 0x12023)
The latest MAC2 packet_no received by mux0       \t 0x12024 \t $($DIR/reg-read $DEV 0x12024)
The latest MAC3 packet_no received by mux0       \t 0x12025 \t $($DIR/reg-read $DEV 0x12025)
Mux0 optimizes MAC2 num                          \t 0x12026 \t $($DIR/reg-read $DEV 0x12026)
Mux0 optimizes MAC3 num                          \t 0x12027 \t $($DIR/reg-read $DEV 0x12027)
Mux1 received a valid UDP packet from MAC2       \t 0x12028 \t $($DIR/reg-read $DEV 0x12028)
Mux1 received a valid UDP packet from MAC3       \t 0x12029 \t $($DIR/reg-read $DEV 0x12029)
The latest MAC2 packet_no received by mux1       \t 0x1202a \t $($DIR/reg-read $DEV 0x1202a)
The latest MAC3 packet_no received by mux1       \t 0x1202b \t $($DIR/reg-read $DEV 0x1202b)
Mux1 optimizes MAC2 num                          \t 0x1202c \t $($DIR/reg-read $DEV 0x1202c)
Mux1 optimizes MAC3 num                          \t 0x1202d \t $($DIR/reg-read $DEV 0x1202d)
~~~~~~~~~~~~~~~~~~~~~ 4ps Statistics Info ~~~~~~~~~~~~~~~~~~~~~
Mux2 received a valid UDP packet from MAC0       \t 0x22010 \t $($DIR/reg-read $DEV 0x22010)
Mux2 received a valid UDP packet from MAC1       \t 0x22011 \t $($DIR/reg-read $DEV 0x22011)
MIRP message sent by mux2                        \t 0x22012 \t $($DIR/reg-read $DEV 0x22012)
The latest MAC0 packet_no received by mux2       \t 0x22013 \t $($DIR/reg-read $DEV 0x22013)
The latest MAC1 packet_no received by mux2       \t 0x22014 \t $($DIR/reg-read $DEV 0x22014)
Mux2 optimized packet_no                         \t 0x22015 \t $($DIR/reg-read $DEV 0x22015)
Mux3 received a valid UDP packet from MAC0       \t 0x22016 \t $($DIR/reg-read $DEV 0x22016)
Mux3 received a valid UDP packet from MAC1       \t 0x22017 \t $($DIR/reg-read $DEV 0x22017)
MIRP message sent by mux3                        \t 0x22018 \t $($DIR/reg-read $DEV 0x22018)
The latest MAC0 packet_no received by mux3       \t 0x22019 \t $($DIR/reg-read $DEV 0x22019)
The latest MAC1 packet_no received by mux3       \t 0x2201a \t $($DIR/reg-read $DEV 0x2201a)
Mux3 optimized packet_no                         \t 0x2201b \t $($DIR/reg-read $DEV 0x2201b)
Mux2 optimizes MAC0 num                          \t 0x2201c \t $($DIR/reg-read $DEV 0x2201c)
Mux2 optimizes MAC1 num                          \t 0x2201d \t $($DIR/reg-read $DEV 0x2201d)
Mux3 optimizes MAC0 num                          \t 0x2201e \t $($DIR/reg-read $DEV 0x2201e)
Mux3 optimizes MAC1 num                          \t 0x2201f \t $($DIR/reg-read $DEV 0x2201f)
Mux2 optimization future 2p/s num                \t 0x22020 \t $($DIR/reg-read $DEV 0x22020)
Mux2 optimization energy 2p/s num                \t 0x22021 \t $($DIR/reg-read $DEV 0x22021)
Mux2 received a valid UDP packet from MAC2       \t 0x22022 \t $($DIR/reg-read $DEV 0x22022)
Mux2 received a valid UDP packet from MAC3       \t 0x22023 \t $($DIR/reg-read $DEV 0x22023)
The latest MAC2 packet_no received by mux2       \t 0x22024 \t $($DIR/reg-read $DEV 0x22024)
The latest MAC3 packet_no received by mux2       \t 0x22025 \t $($DIR/reg-read $DEV 0x22025)
Mux2 optimizes MAC2 num                          \t 0x22026 \t $($DIR/reg-read $DEV 0x22026)
Mux2 optimizes MAC3 num                          \t 0x22027 \t $($DIR/reg-read $DEV 0x22027)
Mux3 received a valid UDP packet from MAC2       \t 0x22028 \t $($DIR/reg-read $DEV 0x22028)
Mux3 received a valid UDP packet from MAC3       \t 0x22029 \t $($DIR/reg-read $DEV 0x22029)
The latest MAC2 packet_no received by mux3       \t 0x2202a \t $($DIR/reg-read $DEV 0x2202a)
The latest MAC3 packet_no received by mux3       \t 0x2202b \t $($DIR/reg-read $DEV 0x2202b)
Mux3 optimizes MAC2 num                          \t 0x2202c \t $($DIR/reg-read $DEV 0x2202c)
Mux3 optimizes MAC3 num                          \t 0x2202d \t $($DIR/reg-read $DEV 0x2202d)
~~~~~~~~~~~~~~~~~~~~~ Global Data Statistics Info ~~~~~~~~~~~~~~~~~~~~~
HBM FIFO0 storage data count                     \t 0x2000  \t $($DIR/reg-read $DEV 0x2000)
HBM FIFO1 storage data count                     \t 0x2001  \t $($DIR/reg-read $DEV 0x2001)
HBM FIFO2 storage data count                     \t 0x2002  \t $($DIR/reg-read $DEV 0x2002)
HBM FIFO3 storage data count                     \t 0x2003  \t $($DIR/reg-read $DEV 0x2003)
HBM FIFO4 storage data count                     \t 0x2004  \t $($DIR/reg-read $DEV 0x2004)
HBM FIFO5 storage data count                     \t 0x2005  \t $($DIR/reg-read $DEV 0x2005)
HBM FIFO6 storage data count                     \t 0x2006  \t $($DIR/reg-read $DEV 0x2006)
HBM FIFO7 storage data count                     \t 0x2007  \t $($DIR/reg-read $DEV 0x2007)
Upload Channel 0 Contract Packet Loss Statistics \t 0x2010  \t $($DIR/reg-read $DEV 0x2010)
Upload Channel 1 Contract Packet Loss Statistics \t 0x2011  \t $($DIR/reg-read $DEV 0x2011)
Upload Channel 2 Contract Packet Loss Statistics \t 0x2012  \t $($DIR/reg-read $DEV 0x2012)
Upload Channel 3 Contract Packet Loss Statistics \t 0x2013  \t $($DIR/reg-read $DEV 0x2013)
Upload Channel 0 Contract Upload Statistics      \t 0x2014  \t $($DIR/reg-read $DEV 0x2014)
Upload Channel 1 Contract Upload Statistics      \t 0x2015  \t $($DIR/reg-read $DEV 0x2015)
Upload Channel 2 Contract Upload Statistics      \t 0x2016  \t $($DIR/reg-read $DEV 0x2016)
Upload Channel 3 Contract Upload Statistics      \t 0x2017  \t $($DIR/reg-read $DEV 0x2017)
MAC0 channel data upload statistics              \t 0x2018  \t $($DIR/reg-read $DEV 0x2018)
MAC1 channel data upload statistics              \t 0x2019  \t $($DIR/reg-read $DEV 0x2019)
MAC2 channel data upload statistics              \t 0x201a  \t $($DIR/reg-read $DEV 0x201a)
MAC3 channel data upload statistics              \t 0x201b  \t $($DIR/reg-read $DEV 0x201b)" | ${SHOW}
