Commit a4b0a591 authored by Jan Pospisil's avatar Jan Pospisil

added version check

parent 03050f07
......@@ -41,6 +41,7 @@
## latency calibration (not working yet)
## 2016-09-05 1.3 Jan Pospisil Independent Trigger Latency for the two
## channels (issue 1389)
## added version check
##-----------------------------------------------------------------------------
# TODO: proper BUSY bits checking
......@@ -439,13 +440,38 @@ def Debug():
PrintBits(debug, 0, 2, "CH1 FSM state", ("Stop", "WaitForTrigger", "Generating", "Outputting"))
PrintBits(debug, 3, 5, "CH2 FSM state", ("Stop", "WaitForTrigger", "Generating", "Outputting"))
def Version():
def GetVersion():
version = WbRead('version')
major = (version >> 22) & ((2**10)-1)
minor = (version >> 12) & ((2**10)-1)
revision = version & ((2**12)-1)
return [major, minor, revision]
def PrintVersion():
[major, minor, revision] = GetVersion()
print('Gateware version: '+str(major)+'.'+str(minor)+'.'+str(revision))
# check actual version against provided version
# returns:
# 0 - versions are same
# 1 - actual version is newer than argument provided
# -1 - actual version is older than argument provided
def CheckVersion(major, minor, revision):
[actualMajor, actualMinor, actualRevision] = GetVersion()
if actualMajor > major:
return 1
if actualMajor < major:
return -1
if actualMinor > minor:
return 1
if actualMinor < minor:
return -1
if actualRevision > revision:
return 1
if actualRevision < revision:
return -1
return 0
###################################################################
## OneWire stuff - not working yet
###################################################################
......@@ -524,6 +550,7 @@ def OneWireReadRom(overdrive = 0):
###################################################################
def Init(memoryPart = -1):
assert CheckVersion(1, 2, 0) == 0, 'Bad gatewere version detected! Get the appropriate driver from http://www.ohwr.org/projects/fmc-del-1ns-2cha/repository/revisions/master/show/sw'
WbWrite('control', 0)
SelectClock(0)
SetRatio(2)
......@@ -628,7 +655,7 @@ TestPulse(1, polarity = 1)
Control()
Status()
Version()
PrintVersion()
Debug()
......
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