1
Mach4 General Discussion / Using modules from Mcodes
« on: June 03, 2020, 02:38:47 PM »
I know this question has been asked & answered, and I've found those forums posts already -- please read without dismissing, there's a nuance here.
I have a module I've written which connects to a serial device (a small pump). I wrote button for my screen set to use the module to communicate with the pump, and it works well. For simplicity, I put the "connect" function of my module in the screen load script.
I also want to be able to turn the pump on & off in m-code macros during movement operations, using the "load_modules.mcs" script which is floating around this forum. However, when I run the Mcode, the serial port is unavailable -- it's already open in a *separate* lua instance from the screen buttons! I removed the "connect" function from my screen load script and made a connect/disconnect button on my screen, but the operator will need to remember to disconnect from the pump before running any Gcode w/ macros.
How can I have the Mcode macros and my screen "share" an instance of a module? I can't find any documentation related to passing objets back and forth to macros outside of registers.
How can I make the screen and my macros
I have a module I've written which connects to a serial device (a small pump). I wrote button for my screen set to use the module to communicate with the pump, and it works well. For simplicity, I put the "connect" function of my module in the screen load script.
I also want to be able to turn the pump on & off in m-code macros during movement operations, using the "load_modules.mcs" script which is floating around this forum. However, when I run the Mcode, the serial port is unavailable -- it's already open in a *separate* lua instance from the screen buttons! I removed the "connect" function from my screen load script and made a connect/disconnect button on my screen, but the operator will need to remember to disconnect from the pump before running any Gcode w/ macros.
How can I have the Mcode macros and my screen "share" an instance of a module? I can't find any documentation related to passing objets back and forth to macros outside of registers.
How can I make the screen and my macros