Hello Guest it is March 28, 2024, 05:26:26 PM

Author Topic: mcCntlGetGcodeFileName ...Crashes M4  (Read 3923 times)

0 Members and 1 Guest are viewing this topic.

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: mcCntlGetGcodeFileName ...Crashes M4
« Reply #10 on: January 03, 2017, 08:49:10 PM »
An explanation on the lower case M code functions:

When the interpreter reads a line/block of G code, it first converts the whole line to lower case.  It then removes all of the spaces in the block.  So

G00 X1
S2000 M03

becomes

g00x1
s2000m03

So when the M3 macro is called, the core will look for a macro named "m3.mcs" and look for a function named "m3()" within it.  On Windows, the filenames are NOT case sensitive and it will find a file named "M3.mcs" or "M3.MCS" or any other combination of upper and lower case letters.  However, it will still look for a lower case function name!!!  Because that is what is fed to LUA and LUA is case sensitive. 

So the convention is now to use lower case names for both files AND functions to maintain cross platform compatibility. 

Steve
Re: mcCntlGetGcodeFileName ...Crashes M4
« Reply #11 on: January 03, 2017, 10:09:27 PM »
Hi smurph,
tried that out and it works exactly as you said it would. The gcode probe job is constructed/written by another program
which calls my macros M40() and M41() and so that's how I named them.

Following your post I renamed them m40() and m41() and the job ran fine or even calling from the MDI line.

Still thinking about filenames. I record the path and filename of the probe job in a register with:
mc.mcRegSetValueString(hreg,pathCode); ie as its not read by the interpreter the string stored retains both
upper and lowercase of the original filename. At the end of the probe job m41() is called which among other things
opens the gcode file with:
   local pathCode=mc.mcRegGetValueString(hreg);
   local hcode=assert(io.open(pathCode,"r")); ie LUA is searching for a file. Would it succeed on a Windows platform if the
filename was correct but all in lowercase say?

I guess I can try it to see!

At the current time I believe M4 only runs on Windows platforms. Is it realistic to believe that it will run on other platforms
in the near future?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: mcCntlGetGcodeFileName ...Crashes M4
« Reply #12 on: January 03, 2017, 10:44:50 PM »
We have an old build that runs on Linux.  In fact, we demoed Mach 4 at IMTS 6 years ago on a Linux machine.  So yeah, it will run on other platforms.  But Linux is not where the majority of our customers are at the moment.  So we have been concentrating on the Windows platform.  I hope to have a Linux build by the end of the year though.  Once we get that going, we'll keep it in sync with the Windows build from that point on.  However, the Linux build will be more for OEMs and such and run on a dedicated distribution of Linux.  We simply can't get into the world of supporting all of the flavors of Linux.  We will probably choose a CentOS distribution.  We may make it available to end users on a strictly "you are on your own" kind of thing with ZERO support from our ticketing system or phone support (meaning only forum based support from other users).

And from Linux to Mac.  I can't imagine a Mac being used as a dedicated machine controller, but we do get questions asking if we support Macs all of the time.  I have a Mac, so I might just make it run on it just for the fun of it.  :)

As to your case question, I would use the LUA string.lower() function to lcase the string returned into pathCode.  e.g.
Code: [Select]
local pathCode=mc.mcRegGetValueString(hreg);
pathCode = string.lower(pathCode);
...

But only IF you WANT to convert it to lower case.  It will not matter for Windows.  But it will matter for Linux and Mac.  So if you put the filename into the register with the correct case, then I would suggest NOT converting it to lower case in the event you ever run the code on a Linux or Mac machine in the future. 

Steve

« Last Edit: January 03, 2017, 10:47:30 PM by smurph »