How do GCode and MCU interact?

How to call the function in mcu.py after processing the gcode command with the _process_command function of gcode.py?

I’m not entirely sure what you’re trying to do, but if you’re trying to run GCode commands from a Klippy extra, here is a tutorial. If you’re trying to run a function when a certain GCode command is run, here is an example of how.

1 Like

The complete process of calling gcode commands and how do gcode threads interact with serial threads?

When the GCode command is parsed if it matches your registered command, then it will call your method for it.
Like this…

So when ACCEPT is called from the console, or gcode, then it will call the cmd_ACCEPT function.

It’s up to this function to decide whether it will call one of the pre-configured mcu commands. If it does decide to send something to the MCU, it would do it like this…

Or it might just call a higher level function like the i2c read/write stuff… or the spi stuff… which will in turn call its own mcu interfacing commands.