M291 issued from a plugin doesn't show anything on the PanelDue
-
I am creating a plugin which intercepts a certain M-code (M1000 in my case), and then performs a bunch of things with the machine. At some point, it needs to open a message box using M291. It does so using
CommandConnection.perform_simple_code('M291 ...')
.Depending on how the plugin is called, the message box doesn't get showed on the PanelDue. Here is what I have observed:
- When I call M1000 from the command console on the PanelDue, which triggers the plugin, the message box is shown, as expected.
- If M1000 is wrapped in a macro, which is ran from the PanelDue, the plugin is triggered, but the message box isn't shown on the PanelDue - only in the web interface.
Expected:
M291 should open the message box on the PanelDue in all cases, otherwise it is annoying because I need to open a web interface to run this macro. -
-
@Ant1 As a note, this issue happens with DSF 3.5.2. I tried to reproduce it with DSF 3.5.1, but the issue doesn't happen and the message gets shown properly on the PanelDue, so I think that the issue comes from the update.
-
@Ant1 Please share the code which intercepts M1000 and calls M291. Does
M409 K"state" F"d99fn"
show a propermessageBox
value when it is not displayed on PanelDue? -
@chrishamm Sorry for the later reply on this, I forgot about it and got no notifications!
Here is a minimal setup that reproduces my issue. In this setup, I use a separate connection to intercept and to send commands. If I use a single intercept connection, the issue still happens, but less often.
Also, note that the message box shows up on the PanelDue in about 50% of the cases when sending M2000. But in the the other cases, the message box only pops up in the web interface. I didn't manage to see if it was correlated to something else, as it seemed pretty random to me.
#!/usr/bin/python3 from dsf.connections import InterceptConnection, InterceptionMode, CommandConnection from dsf.object_model.messages import MessageType if __name__ == "__main__": try: intercept = InterceptConnection(InterceptionMode.PRE, filters=['M2000']) command = CommandConnection() command.connect() intercept.connect() while True: code = intercept.receive_code() try: if code.short_str() == 'M2000': command.perform_simple_code('M291 S2 P"Test" X1 Y1 Z1') print(command.perform_simple_code('M409 K"state" F"d99fn"')) intercept.resolve_code(MessageType.Success) except Exception as e: intercept.resolve_code(MessageType.Error, str(e)) finally: intercept.close() command.close()
The output of
M409 K"state" F"d99fn"
is the following:{"key":"state","flags":"d99fn","result":{"currentTool":2,"gpOut":[],"laserPwm":null,"msUpTime":646,"status":"idle","time":"2024-10-14T11:27:13","upTime":2238}}
I don't see any
messageBox
value inside it.