Fully-featured version of the masterMACS driver
This commit is contained in:
81
utils/decodeError.py
Executable file
81
utils/decodeError.py
Executable file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
The R11 error read command returns an integer, which needs to be interpreted
|
||||
bitwise for various error flags. This script prints out these status flags in
|
||||
human-readable formatting.
|
||||
|
||||
To read the manual, simply run this script without any arguments.
|
||||
|
||||
Stefan Mathis, January 2025
|
||||
"""
|
||||
|
||||
from decodeCommon import interactive, decode, print_decoded
|
||||
|
||||
# List of tuples which encodes the states given in the file description.
|
||||
# Index first with the bit index, then with the bit value
|
||||
interpretation = [
|
||||
("Not specified", "Not specified"), # Bit 0
|
||||
("Ok", "Short circuit"), # Bit 1
|
||||
("Ok", "Encoder error"), # Bit 2
|
||||
("Ok", "Following error"), # Bit 3
|
||||
("Ok", "Communication error"), # Bit 4
|
||||
("Ok", "Feedback error"), # Bit 5
|
||||
("Ok", "Positive limit switch hit"), # Bit 6
|
||||
("Ok", "Negative limit switch hit"), # Bit 7
|
||||
("Ok", "Positive software limit hit"), # Bit 8
|
||||
("Ok", "Negative software limit hit"), # Bit 9
|
||||
("Ok", "Over-current"), # Bit 10
|
||||
("Ok", "Over-temperature drive"), # Bit 11
|
||||
("Ok", "Over-voltage"), # Bit 12
|
||||
("Ok", "Under-voltage"), # Bit 13
|
||||
("Not specified", "Not specified"), # Bit 14
|
||||
("Ok", "STO fault (STO input is on disable state)"), # Bit 15
|
||||
]
|
||||
|
||||
if __name__ == "__main__":
|
||||
from sys import argv
|
||||
|
||||
if len(argv) == 1:
|
||||
# Start interactive mode
|
||||
interactive()
|
||||
else:
|
||||
|
||||
number = None
|
||||
try:
|
||||
number = int(float(argv[1]))
|
||||
|
||||
except:
|
||||
print("""
|
||||
Decode R11 message of MasterMACs
|
||||
------------------
|
||||
|
||||
MasterMACs returns its error message (R11) as a floating-point number.
|
||||
The bits of this float encode different states. These states are stored
|
||||
in the interpretation variable.
|
||||
|
||||
This script can be used in two different ways:
|
||||
|
||||
Option 1: Single Command
|
||||
------------------------
|
||||
|
||||
Usage: decodeError.py value
|
||||
|
||||
'value' is the return value of a R11 command. This value is interpreted
|
||||
bit-wise and the result is printed out.
|
||||
|
||||
Option 2: CLI Mode
|
||||
------------------
|
||||
|
||||
Usage: decodeError.py
|
||||
|
||||
A prompt will be opened. Type in the return value of a R11 command, hit
|
||||
enter and the interpretation will be printed in the prompt. After that,
|
||||
the next value can be typed in. Type 'quit' to close the prompt.
|
||||
""")
|
||||
|
||||
|
||||
if number is not None:
|
||||
print("Motor error")
|
||||
print("============")
|
||||
(bit_list, interpreted) = decode(number, interpretation)
|
||||
print_decoded(bit_list, interpreted)
|
Reference in New Issue
Block a user