diff --git a/motorHist.py b/motorHist.py index 309b11150c2bb6018d71d974594c603144878a70..adb51bfe6b07c740a0d34447774dee6d2153558a 100755 --- a/motorHist.py +++ b/motorHist.py @@ -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