Commit 35b1a2e1 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

sw: Changes in rs485_pulse_rtm.py

Added the repetitive stuff for the pulse test itself to a function that gets
called with the necessary parameters. Then, some small changes were made to the
pulse test (like clearing the counters before enabling the pulse repetition) to
make the pulse test work.

It now almost works, but we're still not there yet, to be determined if this is
a hardware issue or still script problems (most likely the former).

The pulse test should also have better output (like tell on ERROR on which phase
it fails)
parent 6393a08e
......@@ -109,13 +109,15 @@ def dis_pulse_gen(bus):
bus.vv_write(CSR, val)
time.sleep(0.1)
def clear_counters(pc):
def clear_counters(bus):
pc = CPulseCounter(bus, PULSE_CNT_BASE)
# Clear pulse counters for the TTL channels
for i in range(11, 17):
pc.wr_out_cnt(i, 0)
pc.wr_in_cnt(i, 0)
def check_counters(pc, inf, pel):
def check_counters(bus, inf, pel):
pc = CPulseCounter(bus, PULSE_CNT_BASE)
ic_arr = []
oc_arr = []
for i in range(11, 17):
......@@ -132,6 +134,18 @@ def check_counters(pc, inf, pel):
ic_arr[i], oc_arr[i])
pel.set(msg)
def pulse_test(bus, inf, pel, output, term):
msg = "Testing channel connections (term. %s): Out%d -> In" % (term, output)
print(msg)
mux_sel(bus, output)
clear_counters(bus)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(bus, inf, pel)
time.sleep(1)
##-------------------------------------------------------------------------------------------------
## main --
......@@ -161,10 +175,8 @@ def main(bus, tname, inf, log):
pel.set(msg)
return pel.get()
# Initialize a pulse counter object
pc = CPulseCounter(bus, PULSE_CNT_BASE)
clear_counters(pc)
# First, clear the pulse counters
clear_counters(bus)
# Ask the user to make the daisy-chain
print("Connect the LEMO cable as follows:")
......@@ -193,10 +205,15 @@ def main(bus, tname, inf, log):
#---------------------------
# Test with terminations OFF
#---------------------------
term = "OFF"
inf.write('\n')
# Read out fail-safe lines -- should now be high, since the MUXes are
# powered but not enabled
msg = "Testing RS-485 fail-safe on open-connection case (term. %s)" % term
print(msg)
inf.write('\n')
inf.write(msg+'\n')
val = bus.vv_read(LSR)
val >>= LSR_REARFS_OFS
if (val == 0x3f):
......@@ -213,12 +230,12 @@ def main(bus, tname, inf, log):
bus.vv_write(CSR, val)
time.sleep(1)
msg = "Testing RS-485 fail-safe on short-circuit case (term. OFF)"
# Fail-safe test
msg = "Testing RS-485 fail-safe on short-circuit case (term. %s)" % term
print(msg)
mux_sel(bus, 0x0)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
val = bus.vv_read(LSR)
val >>= LSR_REARFS_OFS
if (val == 0x3f):
......@@ -227,45 +244,14 @@ def main(bus, tname, inf, log):
else:
msg = "ERROR: Failsafe lines readout (0x%02X) incorrect - expected 0x3F" % val
pel.set(msg)
dis_pulse_gen(bus)
time.sleep(1)
# Generate pulses from different outputs to inputs
msg = "Testing channel connections (term. OFF): Out1 -> In"
print(msg)
mux_sel(bus, 0x1)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
# Generate pulses & test correct reception
pulse_test(bus, inf, pel, 1, term)
msg = "Testing channel connections (term. OFF): Out2 -> In"
print(msg)
mux_sel(bus, 0x2)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
pulse_test(bus, inf, pel, 2, term)
msg = "Testing channel connections (term. OFF): Out3 -> In"
print(msg)
mux_sel(bus, 0x3)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
pulse_test(bus, inf, pel, 3, term)
# Disable multiplexer
print("Disabling multiplexers")
......@@ -277,10 +263,21 @@ def main(bus, tname, inf, log):
#--------------------------
# Test with terminations ON
#--------------------------
term = "ON"
inf.write('\n')
msg = "Enabling input and output terminations"
print(msg)
inf.write(msg + '\n')
bus.vv_write(TER, (0x3f << TER_OTERM_OFS) | (0x3f << TER_ITERM_OFS))
time.sleep(2)
# Read out fail-safe lines -- should now be high, since the MUXes are
# powered but not enabled
msg = "Testing RS-485 fail-safe on open-connection case (term. %s)" % term
print(msg)
inf.write('\n')
inf.write(msg+'\n')
val = bus.vv_read(LSR)
val >>= LSR_REARFS_OFS
if (val == 0x3f):
......@@ -292,12 +289,6 @@ def main(bus, tname, inf, log):
inf.write('\n')
msg = "Enabling input and output terminations"
print(msg)
inf.write(msg + '\n')
bus.vv_write(TER, (0x3f << TER_OTERM_OFS) | (0x3f << TER_ITERM_OFS))
time.sleep(2)
# Enable multiplexer
print("Enabling multiplexers")
val = bus.vv_read(CSR)
......@@ -305,12 +296,12 @@ def main(bus, tname, inf, log):
bus.vv_write(CSR, val)
time.sleep(1)
msg = "Testing RS-485 fail-safe on short-circuit case (term. ON)"
# Fail-safe test
msg = "Testing RS-485 fail-safe on short-circuit case (term. %s)" % term
print(msg)
mux_sel(bus, 0x0)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
val = bus.vv_read(LSR)
val >>= LSR_REARFS_OFS
if (val == 0x3f):
......@@ -319,45 +310,14 @@ def main(bus, tname, inf, log):
else:
msg = "ERROR: Failsafe lines readout (0x%02X) incorrect - expected 0x3F" % val
pel.set(msg)
dis_pulse_gen(bus)
time.sleep(1)
# Generate pulses from different outputs to inputs
msg = "Testing channel connections (term. ON): Out1 -> In"
print(msg)
mux_sel(bus, 0x1)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
# Generate pulses & test correct reception
pulse_test(bus, inf, pel, 1, term)
msg = "Testing channel connections (term. ON): Out2 -> In"
print(msg)
mux_sel(bus, 0x2)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
pulse_test(bus, inf, pel, 2, term)
msg = "Testing channel connections (term. ON): Out3 -> In"
print(msg)
mux_sel(bus, 0x3)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
pulse_test(bus, inf, pel, 3, term)
# Disable multiplexer
print("Disabling multiplexers")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment