Commit dd4f69a1 authored by Gaia Grosso's avatar Gaia Grosso
Browse files


parent a684f56f
......@@ -41,6 +41,19 @@ config_dict = {
actions = ["get", "set"]
def CheckMask(mask_32bits):
list_32mask = [int(bit) for bit in mask_32bits]
variations = [x[i]-x[i+1] for i in range(len(list_32mask)-1)]
n_variations = sum([abs(x) for x in variations])
if n_variations > 2:
return False
elif n_variations == 2:
for x in variantions:
if x<0: return True
if x>0: return False
else: return True
def ReadProperty(device, location, mask_32bits, verbose=False):
read_32bits = ctypes.c_uint(reg.read_bits(device, location))
string_32bits = "{:032b}".format(read_32bits.value)
......@@ -83,7 +96,7 @@ def WriteProperty(device, location, string_mask, write_value):
# Readback as checkout
read_value_new = ctypes.c_uint(reg.read_bits(device, location))
if read_value_new == read_value: return True
if read_value_new == output: return True
else: return False
......@@ -113,6 +126,12 @@ if __name__ == '__main__':
bitmask = config_dict[board]["property"][prop]["bitmask"]
action = args.action
value = args.value
isMaskContiguous = CheckMask(bitmask)
if not isMaskContiguous:
print("Bit mask %s for property %s at location (%s) is not valid. Check the configuration file"%(bitmask, prop, location, board))
if action == "set":
if value == None:
print("action 'set' requires the optional argument --value (-v).")
......@@ -130,6 +149,7 @@ if __name__ == '__main__':
print('Set property %s from location %s on %s: %i'%(property, location, board, writevalue.value))
print('The value could not be updated. Check the reading permission for property %s in board %s'%(prop, board))
elif action == "get":
readvalue = ReadProperty(device, location, bitmask)
Supports Markdown
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