Skip to content
Snippets Groups Projects
Commit d891a93e authored by kpetersn's avatar kpetersn
Browse files

Better handle starting values.

parent e4652e31
No related branches found
No related tags found
No related merge requests found
......@@ -47,8 +47,13 @@ motor_dict = {}
def msta_diff(last_msta, current_msta):
if last_msta == -1:
print "\t1st MSTA, No comparison possible"
return current_msta
# Display starting state
for index in range(15):
bit = 1 << index
if (current_msta & bit):
bit_state = 1
print "\t%s bit (0x%X) starting value is \"%s\" (0x%X)" % (msta_dict[bit][0], bit, msta_dict[bit][1][bit_state], bit_state)
else:
# XOR shows changed bits
changed_bits = last_msta ^ current_msta
......@@ -65,8 +70,13 @@ def msta_diff(last_msta, current_msta):
def mip_diff(last_mip, current_mip):
if last_mip == -1:
print "\t1st MIP, No comparison possible"
return current_mip
# Display starting state
for index in range(15):
bit = 1 << index
if (current_mip & bit):
bit_state = 1
print "\t%s bit (0x%X) starting value is \"%s\" (0x%X)" % (mip_dict[bit][0], bit, mip_dict[bit][1][bit_state], bit_state)
else:
# XOR shows changed bits
changed_bits = last_mip ^ current_mip
......@@ -127,7 +137,10 @@ def main(log_file):
# Catch error here?
current_msta = int(value)
last_msta = motor_dict[name]["MSTA"]
print "[%s %s] %s's %s field changed from %i (0x%X) to %i (0x%X)" % (date, time, name, field, last_msta, last_msta, current_msta, current_msta)
if last_msta == -1:
print "[%s %s] %s's %s field starts at %i (0x%X)" % (date, time, name, field, current_msta, current_msta)
else:
print "[%s %s] %s's %s field changed from %i (0x%X) to %i (0x%X)" % (date, time, name, field, last_msta, last_msta, current_msta, current_msta)
msta_diff(last_msta, current_msta)
motor_dict[name]["MSTA"] = current_msta
print
......@@ -137,7 +150,10 @@ def main(log_file):
# Catch error here?
current_mip = int(value)
last_mip = motor_dict[name]["MIP"]
print "[%s %s] %s's %s field changed from %i (0x%X) to %i (0x%X)" % (date, time, name, field, last_mip, last_mip, current_mip, current_mip)
if last_mip == -1:
print "[%s %s] %s's %s field starts at %i (0x%X)" % (date, time, name, field, current_mip, current_mip)
else:
print "[%s %s] %s's %s field changed from %i (0x%X) to %i (0x%X)" % (date, time, name, field, last_mip, last_mip, current_mip, current_mip)
mip_diff(last_mip, current_mip)
motor_dict[name]["MIP"] = current_mip
print
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment