Commit c2a76b5d authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

sw: Work on RS485 pulse test

parent 276f1d32
......@@ -133,6 +133,8 @@ if __name__ == '__main__':
# Scan the first barcode
while True:
sn1 = raw_input("--> Scan the 1st barcode: ")
if (not len(sn1)):
sn1 = "0"
m = re.search(r"[^a-z\-A-Z0-9_]+",sn1)
if m:
print "Bad character in barcode"
......
......@@ -95,16 +95,19 @@ def mux_sel(bus, sel):
if (sel & 0x2):
val |= (1 << CSR_TESTER_MUX_S1_OFS)
bus.vv_write(CSR, val)
time.sleep(0.1)
def en_pulse_gen(bus):
val = bus.vv_read(CSR)
val |= (1 << CSR_REAR_EN_OFS)
bus.vv_write(CSR, val)
time.sleep(0.1)
def dis_pulse_gen(bus):
val = bus.vv_read(CSR)
val &= ~(1 << CSR_REAR_EN_OFS)
bus.vv_write(CSR, val)
time.sleep(0.1)
def clear_counters(pc):
# Clear pulse counters for the TTL channels
......@@ -118,6 +121,7 @@ def check_counters(pc, inf, pel):
for i in range(11, 17):
ic_arr.append(pc.rd_in_cnt(i))
oc_arr.append(pc.rd_out_cnt(i))
for i in range(len(ic_arr)):
if (ic_arr[i] == oc_arr[i]):
msg = "Ch%d input counter (%d) matches the output counter (%d) - good\n" % (i+1,
......@@ -205,20 +209,27 @@ def main(bus, tname, inf, log):
val = bus.vv_read(CSR)
val |= (1 << CSR_TESTER_MUX_EN_OFS)
bus.vv_write(CSR, val)
time.sleep(1)
# Generate pulses from different outputs to inputs
msg = "Testing channel connections (term. OFF): O1 -> I"
msg = "Testing RS-485 fail-safe on short-circuit case (term. OFF)"
print(msg)
mux_sel(bus, 0x0)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
val = bus.vv_read(LSR)
val >>= LSR_REARFS_OFS
if (val == 0x3f):
msg = "RS-485 failsafe lines read as expected: 0x%02X\n" % val
inf.write(msg)
else:
msg = "ERROR: Failsafe lines readout (0x%02X) incorrect - expected 0x3F" % val
pel.set(msg)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
msg = "Testing channel connections (term. OFF): O2 -> I"
# Generate pulses from different outputs to inputs
msg = "Testing channel connections (term. OFF): O1 -> I"
print(msg)
mux_sel(bus, 0x1)
inf.write('\n')
......@@ -228,8 +239,9 @@ def main(bus, tname, inf, log):
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
msg = "Testing channel connections (term. OFF): O3 -> I"
msg = "Testing channel connections (term. OFF): O2 -> I"
print(msg)
mux_sel(bus, 0x2)
inf.write('\n')
......@@ -239,28 +251,26 @@ def main(bus, tname, inf, log):
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
msg = "Testing RS-485 fail-safe on short-circuit case (term. OFF)"
msg = "Testing channel connections (term. OFF): O3 -> I"
print(msg)
mux_sel(bus, 0x3)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
val = bus.vv_read(LSR)
val >>= LSR_REARFS_OFS
if (val == 0x3f):
msg = "RS-485 failsafe lines read as expected: 0x%02X\n" % val
inf.write(msg)
else:
msg = "ERROR: Failsafe lines readout (0x%02X) incorrect - expected 0x3F" % val
pel.set(msg)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
# Disable multiplexer
print("Disabling multiplexers")
val = bus.vv_read(CSR)
val &= ~(1 << CSR_TESTER_MUX_EN_OFS)
bus.vv_write(CSR, val)
time.sleep(1)
#--------------------------
# Test with terminations ON
......@@ -289,20 +299,27 @@ def main(bus, tname, inf, log):
val = bus.vv_read(CSR)
val |= (1 << CSR_TESTER_MUX_EN_OFS)
bus.vv_write(CSR, val)
time.sleep(1)
# Generate pulses from different outputs to inputs
msg = "Testing channel connections (term. ON): O1 -> I"
msg = "Testing RS-485 fail-safe on short-circuit case (term. ON)"
print(msg)
mux_sel(bus, 0x0)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
time.sleep(2)
val = bus.vv_read(LSR)
val >>= LSR_REARFS_OFS
if (val == 0x3f):
msg = "RS-485 failsafe lines read as expected: 0x%02X\n" % val
inf.write(msg)
else:
msg = "ERROR: Failsafe lines readout (0x%02X) incorrect - expected 0x3F" % val
pel.set(msg)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
msg = "Testing channel connections (term. ON): O2 -> I"
# Generate pulses from different outputs to inputs
msg = "Testing channel connections (term. ON): O1 -> I"
print(msg)
mux_sel(bus, 0x1)
inf.write('\n')
......@@ -312,8 +329,9 @@ def main(bus, tname, inf, log):
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
msg = "Testing channel connections (term. ON): O3 -> I"
msg = "Testing channel connections (term. ON): O2 -> I"
print(msg)
mux_sel(bus, 0x2)
inf.write('\n')
......@@ -323,22 +341,19 @@ def main(bus, tname, inf, log):
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
msg = "Testing RS-485 fail-safe on short-circuit case (term. ON)"
msg = "Testing channel connections (term. ON): O3 -> I"
print(msg)
mux_sel(bus, 0x3)
inf.write('\n')
inf.write(msg+'\n')
en_pulse_gen(bus)
val = bus.vv_read(LSR)
val >>= LSR_REARFS_OFS
if (val == 0x3f):
msg = "RS-485 failsafe lines read as expected: 0x%02X\n" % val
inf.write(msg)
else:
msg = "ERROR: Failsafe lines readout (0x%02X) incorrect - expected 0x3F" % val
pel.set(msg)
time.sleep(2)
dis_pulse_gen(bus)
check_counters(pc, inf, pel)
clear_counters(pc)
time.sleep(1)
# 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