Geany, it might be useful to see how Shawn is doing this since his Gcode System Commands plugin hooks into the queuing mechanism in OctoPrint right before they are sent to the RAMPS board for printing.
His init.py for the plugin includes hook_gcode_queuing() which is called for each command. Also notice at the bottom in plugin_load() where he is binding that hook.
From what I understand in researching this hooking mechanism, OctoPrint will not continue until after this plugin hook function has returned. Think of this as your gating mechanism as I discussed earlier.
If instead, you're really looking for the Z layer information, then I think I would research Display Layer Progress which does something similar, just with respect to layer information. Again, look for the hook(s) which are bound at the bottom of the file, find the function which matches up to that and see how he's processing in each case to get the layer information.
@OutsourcedGuru thank you for your answer again.
So, we agree, Octoprint sends each line in Gcode one by one ? Or it is the RAMP who controls each line ?
Yes, OctoPrint sends each GCODE command to the RAMPS board and controls it. If you hook into those same functions in the example, now YOU get to control (gate) the GCODE.
Hi @OutsourcedGuru
I have an another question:
Do you know in which pin of my atmega2590 I can know when I pass at the next line ? (In order to develop my program with pin on/off)
Where I can find this information given that I don't have the datasheet of the board in Scara Arm 3D Printer? In the library of firmware ?
(My firmware is Marlin)
The pins are in groups, depending upon what they were intended to be used for. Click on their tab called WiringPi which should highlight the pins that are good candidates for you. I'd use the first one highlighted but remember, you don't have to physically connect anything to it.
In fact, I don't understand how I go back information about the passage of next line. It is with the plugin which working on function "hook"?
I'm sorry I'm very confuse
The two plugins I suggested are so that you can see how you could write your own plugin. You'll need to write a plugin for all this to work.
The reason I chose those two is because they do almost what you want to do; they hook into the part of OctoPrint where lines of GCODE are going to the printer. And that's what you need to do, too.
And then, edit everything throughout so that it stops being the original plugin and starts being yours. All references to his names need to be changed. His code which looks for "OCTO" needs to be replaced with your own functionality.
Much later, you'll want to git init again in your folder to reintroduce another .git hidden folder so that you can manage changes better and to even have your own repository at github.
Thank you !
If I understand, I must work on init.py file of plugin OctoPrint-GCodeSystemCommands (you say two plugins what is the second ?) and to modify it to ? However, I must not modify setup.py file ?
In first step, I will try to do communication between 2 raspberry with GPIO port
I suggested the Display Layer Progress plugin as another candidate but go with Gcode System Commands as an example if you'd like.
Much of the work happens in __init__.py since that's the startup code. setup.py is what happens during the time when it's getting installed. So it would be a good idea to rename a few things so that it's your new plugin instead of being called "Gcode System Commands".