I'm still trying to get real time XYZ and machine state out of my older Mach 4 and am taking another path. I watched a youtube video where somebody was doing some control by attaching to MachIPC.DLL from C#. I couldn't find any documentation on MachIPC.DLL but I did a dumpbin on it and it has many of the same symbols as MachCore.DLL including things like:
_mcAxisGetMachinePos@12
_mcAxisIsHoming@12
_mcAxisIsStill@12
_mcSpindleGetMotorRPM@8
_mcAxisGetPos@12
Based on nothing more than the names matching, I copied a few mappings out of one of the samples, hoping it would work the same:
[DllImport("Mach4IPC.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.I4)]
public static extern int mcAxisGetPos(
[param: MarshalAs(UnmanagedType.I4)] int mInst,
[param: MarshalAs(UnmanagedType.I4)] int axis,
[param: MarshalAs(UnmanagedType.R8), In(), Out()] ref double val);
[DllImport("Mach4IPC.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.I4)]
public static extern int mcAxisGetMachinePos(
[param: MarshalAs(UnmanagedType.I4)] int mInst,
[param: MarshalAs(UnmanagedType.I4)] int axis,
[param: MarshalAs(UnmanagedType.R8), In(), Out()] ref double val);
I don't know that is right, and I don't know that MachIPC.DLL is intended to be used this way, but based on the name it seems so. My goal here would be to create a standalone program that gets the info that I want out of running Mach4 and then sends it out over the network, probably via MQTT.
I do not know how to begin a 'session' either - mInst looks like it's some kind of handle that I need to obtain first.
Am I on the right path here?