DSF Python with pausing, macros and /opt/dsf/sd permissions
-
I've used DSF-Python to create some custom-m-codes that have dynamic function (checking entries in a database and executing different movements based on them). This has been working well, except I've crashed the machine several times due to hitting pause/resume when the macros are in a larger gcode file. It's unclear at what point the machine is pausing, and often some moves (like a necessary clearance) are skipped during resume.
I've been using this code to run movements from within theInterceptConnection
loop:
cmd_conn.perform_simple_code(cmds, channel=CodeChannel.File)
Sometimes cmds is a single command, and sometimes a few commands separated by newline.
I'm also using this code to run macros:
(perform_simple_code('M98 P"/macros/test.g"', channel=CodeChannel.File)
The issue i'm experiencing with pauses might be coming from any of these three ways to execute codes, so I'm thinking it would be best to compartmentalize each set of commands into a dynamically written macro. Then I could implement the normal macroM98 R1/0
to achieve predictable pausing results. I'm wondering if this is the ideal way to go about this, or if anyone has any better ideas.This brings me to my second question of writing macro files dynamically. I get a lot of errors when trying to write files in the
/opt/dsf/sd/macros/
folder. In the past I made somechmod
changes which allowed me to read/write in those folders, but it filled DWC with red errors about incorrect permissions. I'm on a fresh install now and would rather not do that again.I could make some post requests to upload/delete a macro but it seems simpler to just write the files with python if I can get the permissions right. What would be the recommended way of freeing up the permissions of those files and folders? Would it be best to create a DSF plugin instead?
Thanks,
T -
@tristanryerparke Some notes:
- Do you need to be able to pause during your injected moves?
- Pausable macros are terminated when a job is actually paused and they don't resume at the same position. AFAIR the documentation also states that your macro should be able to recover from a pause on its own, so I don't think you gain much by changing to them
- If you don't need to be able to pause while your custom codes are being executed, consider executing them on the default
SBC
code channel once all pending codes are gone onFile
(see Flush command). Codes sent to this channel are not affected by pause/resume. When those codes have been executed, you may resolve your custom code and resume regular file execution - DSF generally runs as
dsf
user. If you turn your script into a plugin, just make sure it has SD write permissions set (see here). If your plugin runs asdsf
, it should not require any custom permissions in/opt/dsf/sd
either.
-
This post is deleted!