Hello Guest it is April 19, 2024, 07:16:23 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - KenSchnell

Pages: 1 2 »
1
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« 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 ?

2
Mach4 General Discussion / Re: Connecting to Mach4
« on: February 16, 2019, 03:07:22 AM »
@Rhtuttle thanks for posting that - I would like to call code from a database drop down with a simple interface.

3
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« 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.

4
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« 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.

 

5
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« on: February 14, 2019, 04:35:11 PM »
Hello - Smurph ..
Having an issue still - I tried my code and received an error - the module could not be found.
So I put your code in with no changes and I received the same result.
 I skipped the dynamics and set the path physically C:\Mach4Industrial\Modules\?.dll , also the same for the package.path  except ?.lua at the end
I have had the same results same error - the module is there in the path - the 4.20.0.4088 installer placed two files in the luasql folder mysql.dll and odbc.dll
When I try the odbc driver I get procedure not found. I tried running these form both mcLuaEditor and zerobrane with the exact same errors - respectively.

I checked folder permissions and so I set them for everyone - I am running zerobrane and mcluaeditor (Run As Administrator)  and I am still not passed this point. On my development machine I am running in demo mode, should not matter - but then again maybe..

Debugging session started in 'C:\Mach4Industrial\'.
error loading module 'luasql.mysql' from file 'C:\Mach4Industrial\Modules/luasql\mysql.dll':
   The specified module could not be found.

6
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« on: February 14, 2019, 08:01:42 AM »
Thank you.. I have downloaded the latest - I was checking the change log and 3139 - 3113 LuaSQL was added - however mine is 3804 and does not have it - so maybe it missed the files/folders inclusion in the build process. Anyway I have downloaded the Latest and Greatest .. hoping I can simply move the folders directory and do what I need to do as the current system is running -  - and I do not want to 'fix' it to broken. We will see how it performs thanks again! :)

7
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« on: February 12, 2019, 09:52:14 AM »
We have Mach 4.2.0.3804 Build 3804

I do not have a luasql directory ..

How can I install that ?

Can you zip that up and I can then install it ? - I assume luasql does not need to be registered in windows in order for it to work.

8
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« on: February 11, 2019, 05:12:46 PM »
When running the code below from the Zerobrane Studio:

package.path = package.path .. ";.\\Modules\\?.lua;.\\Modules\\?.mcs"

-- mysql.dll and odbc.dll are in the addons path so I included a direct reference search path of AddOns

package.cpath = package.cpath .. ";.\\Modules\\?.dll;.\\Modules\\AddOns\\?.dll"

-- load driver
local driver = require "luasql.odbc"
-- if I run this in the mcLUAEditor - debug the script exits with exit code -1 (I assume that means it could not find the driver
-- my macros are located here  ..       C:\Mach4\Profiles\Mill\Macros


-- create environment object
env = assert (driver.odbc())
-- connect to data source
con = assert (env:connect("mycnc_v1"))
-- reset our table


  res = assert (con:execute(string.format([[
    INSERT INTO operator
    VALUES ('Me', 'Myself')]], FirstName, LastName)
  ))

 
con:close()
env:close()



I get the Error output :

Program starting as '"C:\Mach4\ZeroBraneStudio\bin\lua52.exe" -e "io.stdout:setvbuf('no')" "C:\Users\MACHMO~1\AppData\Local\Temp\.3F36.tmp"'.
Program 'lua52.exe' started in 'C:\Mach4\Profiles\Mill\Macros' (pid: 3588).
C:\Mach4\ZeroBraneStudio\bin\lua52.exe: C:\Users\MACHMO~1\AppData\Local\Temp\.3F36.tmp:1: module 'machipc' not found:
   no field package.preload['machipc']
   no file 'C:\Mach4\Modules/machipc.lua'
   no file 'C:\Mach4\ZeroBraneStudio\bin\lua\machipc.lua'
   no file 'C:\Mach4\ZeroBraneStudio\bin\lua\machipc\init.lua'
   no file 'C:\Mach4\ZeroBraneStudio\bin\machipc.lua'
   no file 'C:\Mach4\ZeroBraneStudio\bin\machipc\init.lua'
   no file '.\machipc.lua'
   no file './machipc.lua'
   no file './machipc/init.lua'
   no file './lua/machipc.lua'
   no file './lua/machipc/init.lua'
   no file 'C:\Mach4\ZeroBraneStudio\lualibs/machipc/machipc.lua'
   no file 'C:\Mach4\ZeroBraneStudio\lualibs/machipc.lua'
   no file 'C:\Mach4\ZeroBraneStudio\lualibs/machipc/machipc/init.lua'
   no file 'C:\Mach4\ZeroBraneStudio\lualibs/machipc/init.lua'
   no file 'C:\Mach4\Modules/machipc.dll'
   no file 'C:\Mach4\ZeroBraneStudio\bin/clibs52/machipc.dll'
stack traceback:
   [C]: in function 'require'
   C:\Users\MACHMO~1\AppData\Local\Temp\.3F36.tmp:1: in main chunk
   [C]: in ?
Program completed in 0.19 seconds (pid: 3588).

9
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« on: February 08, 2019, 06:00:40 PM »
 :)AWESOME :) Thank you Smurph - this should now be plenty to get us going .. my first experience with Mach4, and Lua ...

Thanks for the explanation of the path variable..

10
Mach4 General Discussion / Re: Sending Info to a Database from a Script
« on: February 08, 2019, 02:47:01 PM »
Thank you Smurph.

understood wx is Graphical - like wxWidgets python etc

Yes I have Installed MySQL 8.0 , We installed all drivers except the c++ library ; since I will also access this database with .NET. and was not sure how Lua would connect - being new to mach4 I saw the python folders and said better to have more installed than less - while I try to make this work.

Because LuaSQL via Luarocks was not installing - maybe I did not need to do that ...
We went to the odbc driver for a MySQL connection and set up the connection in the windows ODBC connection.


I will double check to see if MySQL installer placed them in the %path% variable but I think that is correct - I try to point to the original rather than a copy located elsewhere - as upgrades may / will require that specific version. Just easier.


" I set one up and the script ran flawlessly. "
Did you run the script from with in Mach4 ? as a Macro or regular .LUA script  ?

I intend to call this with a MCode from a GCode script that our machinist wrote .

I meant to ask about this line of code
package.path = package.path .. ";.\\Modules\\?.lua;"

It seems to be a generic folder  where we point to .Lua files could you give a quick what it is , and that syntax represents ??



 

Pages: 1 2 »