Hello Guest it is January 28, 2020, 08:41:10 AM

Author Topic: LUA Debugging Challenges  (Read 794 times)

0 Members and 1 Guest are viewing this topic.

LUA Debugging Challenges
« on: October 30, 2016, 04:42:07 PM »
Guys,

I have been playing with LUA this weekend in an attempt to get my pendant to work.  I am getting some strange behavior..

If I add some code to the Screen Load section it all goes in and seems fine.  I even try to compile it and it compiles successful.  Then I try to go into Debug and get the follow error?

Compilation successful!
Output: "C:\Users\Russ\AppData\Local\Temp\leEBAB.mcc"
Compilation successful!
Output: "C:\Users\Russ\AppData\Local\Temp\leEBAB.mcc"
Waiting for client connection...
Debug server disconnected.
Debugger socket not created. Debugger EvaluateExpr
Killed debuggee process 4800.
Debug session finished.

I decide to try to debug again and it opens and steps into the first line of the Screen Load script I hit the F11 hit and step in several lines.  All looks good...
If I hover of any of the lines in the top of the code after I have stepped by them I can see their actual value, just what I want... However, as I get down into the Signal Library area I start to get something else.

pageId = 0
screenId = 0
testcount = 0
machState = 0
machStateOld = -1
machEnabled = 0
machWasEnabled = 0
inst = mc.mcGetInstance()

---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
    machEnabled = state;
    ButtonEnable()
end,

[mc.ISIG_INPUT0] = function (state)
   
end,

As I try to check any input by hovering over it after I have stepped past that line of code I get the following.
string : Lua : Syntax error during pre-compilation

Strange thing is some of the code I had in the Screen Load script that worked before I added some more inputs still works.  For example hitting a key to enter feedhold is another input and that still works?


This is some of the new code I added but this is pretty standard stuff, not sure where to start to figure out what is causing the issue.
[mc.ISIG_INPUT40] = function (state)
SRO()
--Spindle RPM Rate switch pokeys pin 47
end,
[mc.ISIG_INPUT41] = function (state)
SRO()
--Spindle RPM Rate switch pokeys pin 50
end,
[mc.ISIG_INPUT42] = function (state)

The function SRO is defined below all the inputs just like a few other sample functions but it not even getting to the function because of the lack on input data?


Thanks
Russ








Re: LUA Debugging Challenges
« Reply #1 on: October 30, 2016, 06:12:03 PM »
For anyone else who might run into this issue.  He is what fixed the issue for me.

I had added new inputs in MACH4 config that were coming from a POKEYS device.  I new these inputs worked using the POKEYS plugin diagnostic, however I failed to let MACH4 map them.

In Mach4, go to Inputs, then you have to check MACH4 Mapping Enabled, which is right next to the input.  What happens is MACH is not made aware of the new INPUTS even if you put them in MACH4, they are not mapped to INPUTs inside of MACH4.  Do this my updated LUA code worked perfect, I have not even tried the debug function, but my guess is that will now work as well.

Russ