On 06/08/2017 06:44 AM, theman whosoldtheworld wrote:
So these is the basic struct for realize a non gui interface ... I think
the emcmodule.cc file is the basic basic approach. Is my thinking correct?
(these code become from emcmodule.cc)

struct CIniFile {
    IniFile *i;
};

struct CStatChannel {
    RCS_STAT_CHANNEL *c;
    EMC_STAT status;
};

struct CCommandChannel {
    RCS_CMD_CHANNEL *c;
    RCS_STAT_CHANNEL *s;
    int serial;    /********************************** where find the
serial number table? ... there is one? ***********************/
};

Yes, emcmodule.cc, and the python module named "linuxcnc" that it compiles into are good for writing custom GUIs.

Each message that goes through the NML channels is identified by a unique serial number. The serial numbers are managed by the NML infrastructure, the GUI developer doesn't need to worry about it. When the GUI sends an NML message, the NML infrastructure tells the GUI the serial number of the NML message, in case the GUI wants to refer to it later. The most common thing a GUI does with the serial number is to wait to hear that the message was received by LinuxCNC and/or processed by LinuxCNC.


Now, if you *did* want to worry about how the serial number is handled, here's the code path:

See how emcmodule.cc:emcSendCommand() takes an NML message (in the form of an RCS_CMD_MSG) and passes it to the command channel's RCS_CMD_CHANNEL::write() function (line 232):

https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/usr_intf/axis/extensions/emcmodule.cc#L231


The RCS_CMD_CHANNEL::write() function calls the underlying NML::write(), passing in a *pointer* to the message's serial number:

https://github.com/LinuxCNC/linuxcnc/blob/master/src/libnml/nml/cmd_msg.cc#L81


The NML::write() function calls the CMS::write() function:

https://github.com/LinuxCNC/linuxcnc/blob/master/src/libnml/nml/nml.cc#L1584


CMS::write() calls a buffer-type-specific main_access() function, in this case the shmem one:

https://github.com/LinuxCNC/linuxcnc/blob/master/src/libnml/buffer/shmem.cc#L454


shmem's main_access() calls, on line 564, the CMS internal_access() function:

https://github.com/LinuxCNC/linuxcnc/blob/master/src/libnml/cms/cms_in.cc#L81


The CMS internal_access() function calls (line 188) the CMS write_raw() function:

https://github.com/LinuxCNC/linuxcnc/blob/master/src/libnml/cms/cms_in.cc#L1315

The CMS write_raw() increments the CMS channel's internal serial number counter (line 1355), and *finally* copies it to the serial_number pointer that was passed in (line 1368).

The message is sent, the functions return back up the call chain, and the command that was passed in to emcSendCommand() has had its serial number set to match the serial number of the NML message generated from it. But note, crucially how the serial number was generated by the CMS/NML/RCS code, and returned to the caller. The caller doesn't generate it.


Hope this helps.


--
Sebastian Kuzminsky

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to