Skip to content
Snippets Groups Projects
Commit cc0acaad authored by BRONES Romain's avatar BRONES Romain
Browse files

Fix and improve the alignement sequence

* Make latches to get two consecutives identical values
* Fix the rollover computation
parent 2d45c101
No related branches found
No related tags found
No related merge requests found
......@@ -30,34 +30,62 @@ def align_ccn(nodename):
nodename: str
The target fofbnode, ie 'cellnode-c09' or 'centralnode'
"""
prx=FofbTool.Utils.get_prx_from_nodename(nodename)
if prx is None:
logger.error("Failed to align CCN on {}".format(nodename))
return
logger.debug("Latch two sequence numbers without offset")
logger.info("Trying to detect and align FA sequences")
logger.debug("Reset offsets on comlbp")
for n in range(4):
prx["comlbp{}_seqoffset".format(n)]=0
prx.ccnpack0_control=0
# Loop until two consecutives identical measures
N=[7,3]
while N[-2] != N[-1]:
logger.debug("Latch two sequence numbers without offset")
prx.ccnpack0_control=1 # let it roll a bit to collect data
time.sleep(2)
prx.ccnpack0_control=2
time.sleep(1)
N=prx.ccnpack0_latchedseq2-prx.ccnpack0_latchedseq1
prx.ccnpack0_control=2 # latch it
time.sleep(2)
N.append(prx.ccnpack0_latchedseq1-prx.ccnpack0_latchedseq2)
logger.debug("seq ({}, {}, {})".format(prx.ccnpack0_latchedseq1, prx.ccnpack0_latchedseq2, N[-1]))
if len(N) > 5:
logger.error("Could not measure sequence offset.")
return False
logger.debug("seq ({}, {}, {})".format(prx.ccnpack0_latchedseq2, prx.ccnpack0_latchedseq1, N))
N=N[-1]
if N in (-1, 0, 1):
logger.warning("Sequence offset measured = {}, something might be wrong".format(N))
# handle rollover
if N<0:
N+=65536
# handle diff going from 17 bits to 16bits offset
if N > 0x7FFF:
N=0xFFFF-N
N=N-0x10000
if -N > 0x8000:
N=N+0x10000
logger.info("Program sequence offset {} in {}".format(N, nodename))
for n in range(4):
prx["comlbp{}_seqoffset".format(n)]=-N
prx["comlbp{}_seqoffset".format(n)]=N
logger.debug("Perform autocheck")
logger.debug("Latch two sequence numbers without offset")
prx.ccnpack0_control=1
time.sleep(2)
prx.ccnpack0_control=2
time.sleep(2)
N=prx.ccnpack0_latchedseq2-prx.ccnpack0_latchedseq1
if not N in (-1, 1):
logger.warning("Corrected sequence offset measured = {}, something might be wrong. Run it again".format(N))
return False
return True
def stop_ccn(nodename):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment