@oozeBot I suggest first to update to dsf-python 3.4.6 as I fixed CodeParameter.is_expression in that version.
In your exemple cde is an instance of dsf.commands.code.Code.
The Code class has a parameters attributes (eg : cde.parameters) which is a List containing the GCode parameters.
The class dsf.commands.code_parameter.CodeParameter has the following attributes :
letter : which contains the letter of the Gcode (eg : H) is_expression : which return either if the parameter value is an expression or not string_value : The value of the gcode as a stringIf you want to parse an expression, you have to use the generic function evaluate_expression over the string_value
As an example :
from dsf.connections import InterceptConnection, InterceptionMode from dsf.commands.code import CodeType def start_intercept(): filters = ["M1234"] intercept_connection = InterceptConnection(InterceptionMode.PRE, filters=filters, debug=True) intercept_connection.connect() try: while True: # Wait for a code to arrive cde = intercept_connection.receive_code() # Check for the type of the code if cde.type == CodeType.MCode and cde.majorNumber == 1234: # Go through all the Gcode parameters for parameter in cde.parameters: if parameter.is_expression: print(intercept_connection.evaluate_expression(parameter.string_value)) # Resolve it so that DCS knows we took care of it intercept_connection.resolve_code() else: # We did not handle it so we ignore it and it will be continued to be processed intercept_connection.ignore_code() except Exception as e: print("Closing connection: ", e) traceback.print_exc() intercept_connection.close() if __name__ == "__main__": start_intercept()