Skip to content
Snippets Groups Projects
Commit 307b46bd authored by Gijs Schoonderbeek's avatar Gijs Schoonderbeek
Browse files

Added read packet count

parent 04bcebca
Branches
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ import sys ...@@ -31,6 +31,7 @@ import sys
import spidev import spidev
DEBUG=False DEBUG=False
CRC = False #True # CRC or packet counter
# We only have SPI bus 0 available to us on the Pi # We only have SPI bus 0 available to us on the Pi
bus = 0 bus = 0
...@@ -136,7 +137,7 @@ def read_link_status(): ...@@ -136,7 +137,7 @@ def read_link_status():
stri = "| " stri = "| "
for cnt_port in range(16): for cnt_port in range(16):
if ret[3] & (0x8000 >> cnt_port) : if ret[3] & (0x8000 >> cnt_port) :
stri += "U | " stri += "P | "
else: else:
stri += " | " stri += " | "
print(stri) print(stri)
...@@ -166,6 +167,9 @@ def read_link_status(): ...@@ -166,6 +167,9 @@ def read_link_status():
stri += "Rx: Er " stri += "Rx: Er "
if ret[2] & 0x40: if ret[2] & 0x40:
stri += "Rx FIFO Er " stri += "Rx FIFO Er "
# ret_err = read_switch(0x10+cnt,0x2E, pr_stri = False)
# stri += f"CRC errs: 0x{ret_err[1]:2x}"
# rest = write_switch_bytes(0x01,0x23, [0x40], pr_stri = False)
else: else:
stri += "link down " stri += "link down "
print(stri) print(stri)
...@@ -208,7 +212,7 @@ def read_link_status(): ...@@ -208,7 +212,7 @@ def read_link_status():
read_switch(0x10+cnt,0x2e) read_switch(0x10+cnt,0x2e)
if 1: if 1:
# alternative status read out, works better for SerDes lines. # alternative status read out, works better for SerDes lines.
for prt_cnt in [9, 10, 11,12, 13,14, 15]: for prt_cnt in [8, 9, 10, 11,12, 13,14, 15]:
ret = read_switch(0x10+prt_cnt,0x28, pr_stri = False) ret = read_switch(0x10+prt_cnt,0x28, pr_stri = False)
stri = "Port status of " + str(prt_cnt) + " " stri = "Port status of " + str(prt_cnt) + " "
if ret[1] & 0x02: if ret[1] & 0x02:
...@@ -235,6 +239,19 @@ def read_link_status(): ...@@ -235,6 +239,19 @@ def read_link_status():
stri += "Rx Fifo Err " stri += "Rx Fifo Err "
if ret[2] & 0x80: if ret[2] & 0x80:
stri += "Tx Fifo Err " stri += "Tx Fifo Err "
ret = read_switch(0x10+prt_cnt,0x2E, pr_stri = False)
if CRC:
rest = write_switch_bytes(0x10+prt_cnt,0x34, [0x20, 0x10], pr_stri = False)
rest = write_switch_bytes(0x10+prt_cnt,0x3e, [0x00, 0x00], pr_stri = False)
rest = write_switch_bytes(0x10+prt_cnt,0x20, [0xD0, 0x01], pr_stri = False)
stri += f"CRC err: {ret[0]} "
else:
rest = write_switch_bytes(0x10+prt_cnt,0x3e, [0x00, 0x00], pr_stri = False)
rest = write_switch_bytes(0x10+prt_cnt,0x20, [0xD0, 0x09], pr_stri = False)
stri += f"Rx packet count: {ret[0]} "
rest = write_switch_bytes(0x10+prt_cnt,0x22, [0x41, 0x41], pr_stri = False)
rest = write_switch_bytes(0x10+prt_cnt,0x3e, [0x00, 0x00], pr_stri = False)
rest = write_switch_bytes(0x10+prt_cnt,0x2E, [0x00, 0x00], pr_stri = False)
else: else:
stri += "Down " stri += "Down "
print(stri) print(stri)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment