Hello Guest it is March 29, 2024, 09:11:13 AM

Author Topic: MACH4 - Modbus  (Read 80299 times)

0 Members and 1 Guest are viewing this topic.

Re: MACH4 - Modbus
« Reply #60 on: May 15, 2014, 09:51:13 AM »
I recon not.  ::)
Would have assumed it would be though.

Seems most thing are quite specific in this programming stuff.
Is this an exception ?

Thanks,
Russ

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: MACH4 - Modbus
« Reply #61 on: May 15, 2014, 10:17:36 AM »
HIYA Russ, From what I can tell EVERYTHING in LUA is case sensitive and it adds to the complexity of programming it.

(;-) TP
Re: MACH4 - Modbus
« Reply #62 on: May 15, 2014, 10:32:36 AM »
That's what I assumed as well Tery.
I notice in Craig's example, they are all the same case wise.
 Russ
Re: MACH4 - Modbus
« Reply #63 on: May 15, 2014, 10:34:21 AM »
write a script under a button and test by stepping thru it

CASE = "yes";
case = "no"
Case =1
CasE =2
a=a

you bet it is case sensitive
Re: MACH4 - Modbus
« Reply #64 on: May 15, 2014, 11:07:01 AM »
Thanks Craig.
 So then I'd assume Steve's script as posted in Reply #55 would not have run with intended results.
Maybe not the main problem, but a problem none the less.

Just observin',
Russ

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #65 on: May 15, 2014, 11:35:11 AM »
Ya Nvr No,

I just double checked and I have exactly the same lines in my Screen Load Script.

Overloaded,

Good eye for catching that. You posted the case sensitivity question earlier and of course you are dead right. I have already changed that so that all of the var names match exactly. C is generally case sensitive in all flavors that I have used, so typos and also the dreaded 'cut and paste' typos can be hell. MS C helps a lot with that by popping up the var names as you type. At first it is an annoyance, but you learn to embrace it before long.

If you look at the image on post #58 you will notice that the debugger blew up on line 2. After your post, I fixed the case issue and no joy. I went a step further and as you see on line 2, the var content is hard coded into the argument and it still blew up at the same place. That exact var is used in the now infamous M40 and it works fine, so it is not the argument causing the problem either. 

It is a mystery to me, but for now the 'Vaudeville solution' seems like the best course:

Patient: "Doctor, it hurts when I do this"
Doctor: "Then don't do that, NEXT!"

Badda BING!


Everybody,

I think it may be an issue with this computer. One of the images I posted (I think) showed Lua unhappy about something and calling out the IP of this computer.

There are a co0uple more things to try. One is to turn off the firewall and the other of course is to try the same procedure on my CNC computer (less complex and 32 bit). But the CNC computer is doing its job at the moment, so I can't mess with it.

It is good to know that it does work so the problem is on my end. I'm doing something stupid and obvious and just missing it completely -or- there is something in the OS of this computer that is blocking the calls.

As I mentioned, it's not something I plan to use right away  . .  if ever . .  so knowing it works is enough for now. I can play with MACH4 using self contained scripts for now. I'm posting the issue here as the final resolution, if any, might be valuable. For example, I discovered that MACH4 has to be 'run as administrator' (at least on this computer) or the OS blocks the IP traffic. So . . that would be a good thin g to add into the install instructions. Certainly can't hurt and it may save some hair pulling down the road.

Once again thanks for the responses!
« Last Edit: May 15, 2014, 11:44:13 AM by simpson36 »
Re: MACH4 - Modbus
« Reply #66 on: May 15, 2014, 12:49:16 PM »
That's my point if you don't post your code, we are just guessing what your issue might be.

Sharing brings to light issues other might want to learn from too.

If ya don't want to share, pull your own hair.  ;D

its just a joke... chill  8)

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: MACH4 - Modbus
« Reply #67 on: May 15, 2014, 01:15:28 PM »
I think I have mentioned it before, but it is worth mentioning it again.  There are two instances of LUA.  One in the GUI and one in the mcLua plugin.  The mcLUA plugin is there so that M codes will run regardless of what GUI is driving the core.  It is NOT connected to the Mach4GUI in any way.  However, communication between the two LUA instances is possible with Mach registers.  But mcLua plugin based scripts and functions cannot see the Screen scripts as the screen scripts are imbedded into the screen set.

Mach 4 is written so that any developer can write their own GUI for the core.  It can be written in C++, C#, VB, or any other language that supports loading of DLLs.  We have two GUIs at the moment as an example of this.  Mach4GUI and the wxMach "static" GUI.  The static GUI is just that, static and not changeable.  I do have a sample GUI written in C# that I played with.  wxMach does not have a configurable screen and has no screen based scripting functions.  It does, however, have a PLC script.  So that is the reason for the separate LUA instances.

So on to global functions...  

If you want a global function that can be called from any screen object script, put the functions in the screen load script.  Then they will be available to all screen object scripts.

If you want a global function to be available to all M code "macro" scripts, put a file in the macro directory containing the global script functions.  The file can be named anything as long as the extension is ".mcs".  Say you named the file "myGlobalScripts.mcs".  You can write this file using the mcLuaEditor.  It is prudent to test the scripts (debug) and "compile" the file inside the mcLuaEditor to check for syntax errors.  The act of compiling the *.msc file will generate a *.mcc binary file.  Then when you press cycle start the first time, ALL of the *.mcc files in the macros directory will be combined into one LUA program called wxLua.mcc.  This is the chunk that gets loaded.

What if you want the same global functions in the screen and macro scripts?  You can duplicate the code in the screen load and the macros directory or you can "include" the code from the file system in each LUA instance.  This "shared" code should be put in a global directory.  Meaning not a profile's macro directory.  Something more along the lines of a "Modules" directory in the Mach4 installation.  That way all profiles or screens in you installation can access it regardless of if you happen to delete a profile or two.  But I won't get into how to do all of this.  The LUA manuals cover it.  

Oh another thing...  DO NOT expect any scripts that Brian or I post to just work.  They are hand typed generalized examples of how to get something done.  They are usually typed on-the-fly as we answer a post and they may not be perfect.  They are close.  But the only way to ensure they are perfect is to put them into the LUA editor, compile them, and tests them.  That is not something we have time to do when answering a posts.  It is an exercise for the user to make them work. 

Steve

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #68 on: May 15, 2014, 03:17:48 PM »
I think I have mentioned it before, but it is worth mentioning it again.  There are two instances of LUA.

You may have mentioned it before, but this is the first I've read it . . . and it explains a LOT.  I don't have much time these days for general perusing of any forums, so if it was not in my tunnel vision (i.e. this thread) then I would have missed it.  What this is leading to is a big  :-* for taking the time to repost here.

Quote
Oh another thing...  DO NOT expect any scripts that Brian or I post to just work. 

My bad for not catching the case and spelling typos.  On the case sensitive issue, I know better, just missed it. On the spelling, I actually thought it might be a reserved word. Programmers do that stuff, sometimes just to be funny, sometimes with good reason. The basic public code I use to drive the Modbus is actually called Mudbus . . . to keep libraries from overwriting each other. Nobody is worse at typos than myself and I don't point them out just to bring attention to them. I was just asking if one of them was actually a keyword. 

In any case, FWIW, I am trying not to waste anyone's time on Modbus 101 or to post code for others to troubleshoot. I have no way to analyze (what I thought were) MACH4 error messages, so I post them in case there is some value to that. Otherwise, I am quite willing to do my homework and plug away until I am out of options.

Brian already put us on notice that modbus is not the focus for the demo release and speaking for myself, your time spent on this topic is greatly appreciated.  I am trying to be careful not to waste it and only ask MACH4 specific questions that only you can answer (until the docs catch up).  If I post a question that is not MACH4 specific, it will be out of ignorance of Lua, so please feel free to tell me to RTFM, because I do have them and I'm happy to do the homework.

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #69 on: May 15, 2014, 04:14:47 PM »
That's my point if you don't post your code, we are just guessing what your issue might be.

Generous offer, thanks. The code we are each using came from the same source; a post be a developer earlier in this thread. Save a few typos that have since been corrected, we are using, or at least starting with the same code. Of course our registers have different names, but that would not  cause the kind of systemic problems that are occurring on my machine.

Win7 Pro 64bit, firewall, all manner of resident drivers (Render Farm, Raid arrays, a ridiculously long list of NIC features, Various .NET extensions and who knows what MS adds with their suites). It is not important the MACH4 demo work perfectly on this creature under my desk and I don't want to waste anyone's time unless I have a fail on the CNC computer as well. Steve just dumped a ton of new (to me) info on how the modules interact and where to put stuff. That one post has cleared up a lot of the mystery for me, but it will take some time to dig thru it and test everything he mentioned. I understand about 85% of what he said, but I'll need to crack a book to get the rest of it.

If you say the global calls are working on your computer, that's good enough for me. Most likely it will work first try on the very basic CNC computer. If so, then I'll just grab a similar PC from around here or build a new one to work on MACH4 development. I have a huge investment in MACH, so one new computer is peanuts in the grand scheme. No problemo.