Hello Guest it is October 20, 2019, 03:42:55 PM

Author Topic: Sending Info to a Database from a Script  (Read 666 times)

0 Members and 1 Guest are viewing this topic.

Offline smurph

*
  • *
  •  1,138 1,138
  • "That there... that's an RV."
    • View Profile
Re: Sending Info to a Database from a Script
« Reply #20 on: February 14, 2019, 05:12:58 PM »
That means that the luasql/mysql.dll can't find the libmysql.dll client file.  This goes back to putting the mySql dll files into the PATH environment variables.  Or, you can drop the libmysql.dll into the Mach directory. (Attached is my libmysql.dll file).

Then Start Mach.  Next, open the Zerobrane editor with the menu path "Operator -> Open Script Editor" and load the file I a previously attached.  You should be able to step through the code.

Steve



Offline smurph

*
  • *
  •  1,138 1,138
  • "That there... that's an RV."
    • View Profile
Re: Sending Info to a Database from a Script
« Reply #21 on: February 14, 2019, 11:48:55 PM »
I did a video that maybe explains things. 

In the video section of this forum:  https://www.machsupport.com/forum/index.php?topic=39466.0

or direct to youtube:  https://www.youtube.com/watch?v=BtzPPv1WNZQ

Steve

Re: Sending Info to a Database from a Script
« Reply #22 on: February 15, 2019, 12:45:42 PM »
Hello Smurph and Thank you!!

yes using the code you provided and the NEW installation of Mach4 4.20.0.4088 on my development box (forgot to put the path in the environment on the development box - just as you stated ..aaargh)  I was able to successfully step through the code.

I have the customer box setup in a VM [So I can do my testing with it - without messing them up) it is windows 7 embedded (ugh).

I added to the path environment and also added the luasql folder with its files (from .4088 build)  to the Mach4\Modules folder - so I have Mach4\Modules\luasql\
While I have added the libmysql.dll to the path I had also copied it to the Mach4 directory to be sure. This so far has not worked.  Same Errors.
So then I copied the root of the .4088 build (with lua53.dll) to my Mach4 3804 build folder - without overwriting the existing installation files - this produced a different error c0000005 (which seems to be a memory access violation error). So that tells me the driver has been located at this point and that some other file is an issue.


Do I need to upgrade the Mach4 software in order to accomplish this  - or is there some other folder / files I need to copy over in order for it to function?

I'am trying to avoid the upgrade route because MachMotion has their files loaded into it as well, and unfortunately what I am doing is also not my favorite route as I am doing a franken-version - but I am more willing to do this as I think I will be less prone to have something else in this application break.

 

Offline smurph

*
  • *
  •  1,138 1,138
  • "That there... that's an RV."
    • View Profile
Re: Sending Info to a Database from a Script
« Reply #23 on: February 15, 2019, 01:27:34 PM »
You can't use the Lua module files from the 4088 build in the 3804 build.  The reason is that the 4088 uses Lua 5.3 where 3804 uses Lua 5.2.  Copying the lua53.dll file into the 3804 directory didn't do much other than let the 5.3 module go a step further.  However, the Mach GUI and core are still Lua 5.2, which is causing the 0xc0000005 exception. 

So yes, you need to upgrade the Mach 4 software on the target machine to use the Lua 5.3 modules from 4088.  However, knowing that it is a Mach Motion Win 7 Embedded control, I would not do that.  It will break a TON of their screen scripts.  So I went looking for Lau 5.2 versions of the luasql modules and found them in a later build.  They are attached.

Steve

Re: Sending Info to a Database from a Script
« Reply #24 on: February 16, 2019, 02:49:04 AM »
The mcLuaEditor will successfully run the code but zerobranestudio will not - it wants machipc.dll, I copied that file in to the Mach4 directory using the machipc.dll from the 4088 build and when I do that - zerobranestudio says mclua52.exe crashed.

using mcluaeditor I can insert into my database - even using the MySQL 8 Server with a username and password  (I have the 32bit  c connector installed and have it in the path).

My only issue now seems to be the zerobranestudio crash.
Re: Sending Info to a Database from a Script
« Reply #25 on: February 16, 2019, 04:16:26 AM »
In my zerobrane studio I only have an issue if I have the Mach4 interpreter selected - found that in the preference.. so I need to find out about the interpreter and if I am pointed to he wrong one ... even with Mach4 .

Will my code still work if called from a Gcode file ?

Offline smurph

*
  • *
  •  1,138 1,138
  • "That there... that's an RV."
    • View Profile
Re: Sending Info to a Database from a Script
« Reply #26 on: February 16, 2019, 06:37:05 PM »
Mach Motion may not have included those files in their installation.  Attached are the complete set of Lua5.2 modules from 3804.  Don't overwrite your existing luasql thought, as the files you have now are newer.  Just get the modules you don't have. 

Use the Mach4 interpreter in ZeroBrane.  Always launch the Zerobrane editor from the Mach menus.  Otherwise, the paths will not be correct and it will not find the modules (machipc.dll, etc...).

As to if they will the run in the G code, yes.  Build a regular M code macro and put your DB code in there and it will be fine. 

Steve