Is it possible to get the length of M291 queue
-
Is there a way, in a macro, to determine the number of messages in the
state.messageBox
object?I am wrestling with using M291 messages. DuetLapse3 allows remote control using several techniques, one of which is M291 messages. Typically, these will be used in start/end gcode or in a startup macro.
I previously used blocking messages and DuetLapse3, on seeing the message issued the appropriate M292.
That works fine so long as DuetLapse3 is running. I'm looking for a "safe" way to allow the same M291 messages (or alternative) - even if DuetLapse3 is not running.Timeouts on blocking messages do not help since the timeout is seen as a "cancel" and will abort macro / print job (as of 3.5.0-beta.4, I believe).
Using non-blocking messages with timeout is not a good alternative due to the possibility of over-running the message queue (and missing a message).
Is there is a blocking M291 with timeout = "OK" in the pipelene?
I think I can work around this with a macro that issues non-blocking messages. If the message queue is full (8 messages), wait a while before sending the message. Granted, this approach (if doable) would be blocking if the message queue is full but would also be self clearing.
-
After doing some more tests - I think I'm snookered. It appear that state.messageBox only ever contains what it believes to be that oldest (?) M291. I had not looked closely for a while ...
Is there any way to get at the message queue?
The behavior was kinda OK prior to beta.4 (clear the message, get the next one rinse and repeat) but alas, no longer because clear = cancel.
-
Having spent some more time at this, I'm pretty sure I can implement a queue-like mechanism using a global variable array. I've knocked together a quick POT and its encouraging.
The downside is that it will require the user to install a macro instead of using a "native" command. The upside is (1) that its independent of the Duet3d dev cycle which has more than enough to be going on with , (2) I'm not trying to shoehorn a mechanism into doing something that was not intended. (3) it can be kept independent of other programs / plugins.
I'll report back / share the macro when I have a reasonable V0.