How are managed comments in Gcode


Hi there

I simply wish to know how the Gcode comments (lines bigining with ; ) are managed by octoprint ?

I ask this because I use Octolapse plugin triggered by a GCode command, at first I wanted to use " ; SNAP" as the trigger but it don't work. Using "SNAP" without the comment works as excpected, but then the printer makes a little pause at each one of this unknown command (that is normal), making a ugly seam on my prints

This let me think that GCode comments are stripped out from the flow and, more important, not passed to plugins

Am I wrong ?

Depending on the answer, I'll open a ticket either on octoprint or on octolapse tracker :slight_smile:




I believe there is a plugin to add your own custom gcode commands. That's how stuff like @SPEAK work. IIRC, they aren't in comments, they are actual gcode that OctoPrint recognizes and acts on. Depending on what you want to do with it, I know there's the GCode System Commands plugin for defining gcode that runs scripts on the OctoPrint server. Not sure where the other custom stuff is or if it requires you write your own plugin.



Actually I don't need this plugin, I use Octolapse witch triggers a snapshot when a certain keyword appears in the GCode (this keyword is inserted using a post processing script with Slic3r) (more info here if you're interested)

Fact is, if I use a keyword with a semi-colon (so it don't bother the firmware), it is ignored by the plugin OR not transmitted by octoprint

That's why I wish to know if it's ignored by Octoprint (and stripped out the normal flow of GCode lines without being passed to the plugins)

I'm pretty sure only @foosel could answer to this question :smiley:


That is exactly the case.



OK that's logic after all, thank you


Can I ask why you want the gcode to be within a comment? Is it so you can run the code without Octolapse?

I was thinking I could add a feature to suppress the snapshot command even if octolapse isn't running. I'm also wondering what would happen if we send a bogus command to the printer (snap). It's pretty crazy to think I haven't run into this yet. Maybe I'll look into it this weekend.


Perhaps you could do:



@foosel -- not wanting to hijack the thread, but this would explain why, when I tried to copy a file from my PC, using OctoPrint, to the printers' SD card, the file on the SD card was written with all of the comments removed.

In effect, the 'Copy to SD' is actually better described as 'Print to SD' as it would appear that OctoPrint would process each line in the source file, like it was about to print and strip out the comments, and write each line to the printers' SD card.



I want to use a commented trigger to avoid sending unwanted stuff to the printer, but I didn't think that Octoprint would not pass the comments to the plugins

I tried adding a @ before the Gcode trigger, it works (I mean, snapshot is taken) but there is still the little delay, a bit hack-ish though because @ commands are not supposed to work this way

I realized it's the delay before snapshot in octolapse, used to stabilize the hotend, but even set to 0, there is still a little pause during the snapshot, shorter, but still here (I still need to see how bad it affect the print)

@OutsourcedGuru could work, but I prefer to not use an actual GCode for that, to avoid any unwanted effect. Maybe the M240 Gcode (only supported by Marlin AFAIK) witch is used to trigger a digital camera connected on the board driving the printer (not the pi)
Ideally, the trigger should not be sent to the printer to avoid wasting processing time


M117 is just the message command. In many cases, it will just send a popup message to the OctoPrint screen. In my mind, that's the easiest way to have low impact and still include a valid GCODE command. I'd be careful with GCODE commands that only work on a subset of firmware.

And then again, have you heard of the GCode Systems Commands plugin?

Add that then create an OCTO411 which will do something benign like echo OCTO411. If this code is seen in the stream, it will invoke your custom system command which does very little. Finally, you can then trigger off this GCODE when seen.


Oh I though M117 was to display something on the printer's LCD, well then it could be a good option

About GCode systems commands, actually, Octolapse already do this but only for timelapse purpose, with a bunchfull of options


If you have Marlin firmware, M118 would probably work as well.


If you are running Octolapse the snapshot command
is not sent to the printer anyway. Octolapse intercepts the command, recognizes it as the snapshot command and takes a snapshot if the gcode trigger is enabled, but does not allow it to actually reach the printer.


I forgot to comment on the delay. Octolapse waits to acquire the image before continuing (up to .. 5 seconds I think). The 'Snapshot Delay' is done BEFORE requesting the image to give the camera a chance to stabilize. The printer continues printing immediately after the snapshot is saved to disk (all post-processing is done in the background). My guess is that there is a slight delay in acquiring the image. Are you using auto focus or auto white balance? It might be worth a shot to switch all settings to manual.

Also, my asynchronous snapshot routine is not very good. Some of the delay is probably due to my ignorance about threading in python. I'm working on this issue right now.


Good to know that octolapse isn't passing the snapshot command to the printer

I tried using manual settings for brightness, autofocus and so but there is still a little delay on the trigger (something like a tenth of a second) so yeah, the snapshot routine seems to be a good culprit here :slight_smile: