Hello Guest it is April 24, 2024, 02:01:31 PM

Author Topic: Socket support  (Read 1006 times)

0 Members and 1 Guest are viewing this topic.

Offline wz2b

*
  •  12 12
    • View Profile
Socket support
« on: October 30, 2021, 04:48:19 PM »
I have a machine that is running Mach4 version 4.0.1.2259 with some custom add-ons that were put in to control a laser.  It's an older version of Mach4, but it is a licensed version and unfortunately upgrading it is out of the question because of all the custom development that went into it.

I want to modify it to do something relatively simple (I think).  I want to write a lua script that runs either on a timer or creates its own thread with a timer.  I want it to get the mc object and periodically spit out some data via a UDP socket:

* What program (g-code file) is currently running
* Current spindle speeds
* Current X,Y,Z

I'm stuck trying to figure out how to do this.  I think an .mcs file is really just lua, so I thought I could download a copy of a luasockets dll and 'require' it, but that doesn't seem to work and I'm not sure why.

Is this approach even possible?  Or do I really need to develop a legitimate external plugin?  An .mcs file is just lua, right?  Is there any way to figure out what version of lua it is?

It does seem to have modbus included.  If what I'm trying to do won't work, then maybe there's a way to do the same thing by having it just push this data to a modbus device that happens to be my PC (running a tcp modbus server) rather than a PLC?
Re: Socket support
« Reply #1 on: November 08, 2021, 09:30:38 PM »
Someone please respond.
Re: Socket support
« Reply #2 on: November 09, 2021, 11:25:09 AM »
socket support is included with mach4:
C:\Mach4Hobby\Modules\socket.lua
C:\Mach4Hobby\Modules\socket\

so an advanced search of search the mach4 general discussion for socket.  There are several posts, specifically this one:
https://www.machsupport.com/forum/index.php?topic=32001.msg222766#msg222766

Offline wz2b

*
  •  12 12
    • View Profile
Re: Socket support
« Reply #3 on: November 09, 2021, 01:51:44 PM »
Thanks for that reference.  The sockets library is, however, not in my installation.  Could that be because of the older version I'm running?  Or can I download / install it?  The only lua sockets library I was able to find was in source form, I'm not exactly set up to build it.  I think a lua module is just a dll though so ifI could find one for win7/32 I could just use it.
Re: Socket support
« Reply #4 on: November 09, 2021, 05:09:31 PM »
It has been in the build for at least 2 years.  Automatically installed.  I remember that they have changed which lua version they are using sometime this year or last so you have to be careful not to mix old and new.   I would open a ticket with NFS.

Offline wz2b

*
  •  12 12
    • View Profile
Re: Socket support
« Reply #5 on: November 09, 2021, 05:11:55 PM »
Unfortunately, support told me my best best was to ask here haha.
Re: Socket support
« Reply #6 on: January 08, 2022, 03:00:47 AM »
you can use wxSockets but I didn't have the greatest success with it. Crashes the screen if you poll data too fast. https://www.machsupport.com/forum/index.php?topic=43283.msg279798#msg279798