Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: raptor_demon on April 06, 2019, 04:36:04 PM

Title: Script edit help, M6 and MQTT
Post by: raptor_demon on April 06, 2019, 04:36:04 PM
Hi,

im new to the whole mach4 scripting and i am trying to setup a MQTT message when my job needs a tool change.

So far i have managed to get MQTT working from mach4, it has a line in the PLC and a function i can call from the screen load script.

ive set it up as per here: https://www.machsupport.com/forum/index.php?topic=36807.0

there is a function on the screen load script called SendMessage(msg) where i can send mqtt messages. however i have been unable to call this from the m6 macro script.

it just fails for whatever reason. what am i doing wrong here?

cheers
Raptor
Title: Re: Script edit help, M6 and MQTT
Post by: reuelt on April 06, 2019, 04:44:32 PM
follow this thread

https://www.machsupport.com/forum/index.php?topic=36807.10
Title: Re: Script edit help, M6 and MQTT
Post by: joeaverage on April 06, 2019, 04:50:46 PM
Hi,
the function in the screen load script is in the GUI Lua chunk. The macros are included in the Gcode interpreter chunk.
Only one chunk can run at a time. Thus a macro cannot call code from the GUI, in fact a macro cannot access variables
in the GUI either.

If you wish to share data between the two chunks use registers, that's what they're for.

You cannot share functionality with the GUI.

Your choices are to duplicate the functionality within your macro. It may be possible to put the function into a module
as modules can be accessed by either chunk.

Craig
Title: Re: Script edit help, M6 and MQTT
Post by: raptor_demon on April 07, 2019, 12:17:26 AM
thanks Craig

thats what i had wondered was going on. ill see if i can make it work with modules or a register