Hello Guest it is May 13, 2021, 01:34:58 AM

Author Topic: Script edit help, M6 and MQTT  (Read 456 times)

0 Members and 1 Guest are viewing this topic.

Script edit help, M6 and MQTT
« on: April 06, 2019, 04:36:04 PM »

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?


Offline reuelt

  •  487 487
    • View Profile
Re: Script edit help, M6 and MQTT
« Reply #1 on: April 06, 2019, 04:44:32 PM »
"the gift of God is eternal life through Jesus Christ our Lord"
Re: Script edit help, M6 and MQTT
« Reply #2 on: April 06, 2019, 04:50:46 PM »
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.

My wife left with my best friend...
     and I miss him!
Re: Script edit help, M6 and MQTT
« Reply #3 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