Commit 0aeea688 authored by Gaia Grosso's avatar Gaia Grosso
Browse files

Update main.py

parent e73aaa8a
......@@ -46,9 +46,9 @@ config_dict = {
actions = ["get", "set"]
def ReadProperty(device, location, offset, width, verbose=False):
def ReadProperty(device, location, offset, width, verbose=0):
read_32bits = ctypes.c_uint(0);
isRead = reg.read_bits(device, location, ctypes.byref(read_32bits))
isRead = reg.read_bits(device, location, ctypes.byref(read_32bits), ctypes.c_uint(verbose))
if isRead == -1:
print("An error occured while executing C function read_bits")
return -1
......@@ -58,14 +58,14 @@ def ReadProperty(device, location, offset, width, verbose=False):
print("Read: %s"%(string_32bits))
string_32bits = "{:032b}".format(read_32bits.value>>offset)
string_out = string_32bits[-1*width:] # remove masked bits
output = int(string_out, 2) # convert selected string to integer
output = int(string_out, 2) # convert selected string to integer
if verbose:
print("Unmasked result: %i"%(output))
print("Unmasked result: %i (%s)"%(output, string_out))
return output
def WriteProperty(device, location, offset, width, write_value, verbose=False):
def WriteProperty(device, location, offset, width, write_value, verbose=0):
read_value = ctypes.c_uint(0);
isRead = reg.read_bits(device, location, ctypes.byref(read_value))
isRead = reg.read_bits(device, location, ctypes.byref(read_value), ctypes.c_uint(verbose))
if isRead == -1:
print("An error occured while executing C function read_bits")
return -1
......@@ -77,12 +77,12 @@ def WriteProperty(device, location, offset, width, write_value, verbose=False):
string_write = string_read[:-1*(offset+width)] + string_write[-1*(offset+width):-1*offset] + string_read[-1*offset:]
output = int(string_write, 2)
isWritten = reg.write_bits(device, location, output)
isWritten = reg.write_bits(device, location, output, ctypes.c_uint(verbose))
if isWritten == -1:
print("An error occured while executing C function write_bits.")
return -1
# Readback as checkout
isReadcheck = ctypes.c_uint(reg.read_bits(device, location, ctypes.byref(read_value))).value
isReadcheck = ctypes.c_uint(reg.read_bits(device, location, ctypes.byref(read_value), ctypes.c_uint(verbose) )).value
if isReadcheck == -1:
print("An error occured while executing C function read_bits")
return -1
......@@ -100,7 +100,7 @@ if __name__ == '__main__':
parser.add_argument('-a','--action', type=str, help="control action", required=True, choices=actions)
parser.add_argument('-p','--property', type=str, help="control property", required=True)
parser.add_argument('-v','--value', type=str, help="new value", required=False)
parser.add_argument('-d','--dump', type=bool,help="dump messages", required=False, default=False)
parser.add_argument('-d','--dump', type=int ,help="dump messages", required=False, default=0)
args = parser.parse_args()
board = args.board
......
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