I found on GMANE these old post of Jepler that reply to someone I think ... the 
code is attach (code + comment).

The question actually for perform the same or similar result not find xemc.cc 
(because from 2.5 to 2.8 is disappear or because I'm very bad detective...) so 
I think is possible to use other command .. can anyone report this to me in 
courtesy?


I'm looking for the time to better study the Lcnc 2.8 code to try to arrange me 
with these things ... but I find it difficult.

Thanks Again.

regards
giorgio


#include "emc.hh"
#include "emc_nml.hh"
#include 
#include 
#include 

int main(int argc, char **argv) {
    if(argc < 2) { std::cerr << "Usage: " << argv[0] << " NMLFILE\n";
abort(); }
    const char *nmlfile = argv[1];
    RCS_STAT_CHANNEL *stat = new RCS_STAT_CHANNEL(emcFormat, "emcStatus",
"xemc", nmlfile);
    while(1) {
        usleep(100*1000);
        if(!stat->valid()) continue;
        if(stat->peek() != EMC_STAT_TYPE) continue;
        EMC_STAT *emcStatus = static_cast(stat->get_address());
        std::cout << emcStatus->motion.traj.position.tran.x << " "
            << emcStatus->motion.traj.position.tran.y << " "
            << emcStatus->motion.traj.position.tran.z << "\n";
    }
    return 0;
}

In a run-in-place version of v2.5_branch it builds with this commandline:
    g++ -o nml-position-logger nml-position-logger.cc -Iinclude -Llib -lnml
-llinuxcnc
(and probably it will build from the package version if you have the -dev
package installed, but I didn't test this)

in master branch it looks like we have a regression so the commandline
required is:
    g++ -o nml-position-logger nml-position-logger.cc -Iinclude
-Isrc/emc/rs274ngc  -Llib -lnml -llinuxcnc
and a -dev package will not include at least one of the required headers.

To use this program you would start linuxcnc with a traditional UI and
then execute the program with the path to linuxcnc.nml.  For example
if you're at the top dirctory of a run-in-place linuxcnc:
    ./nml-position-logger configs/common/linuxcnc.nml
.. press ctrl-c to exit.

To send commands you will use an RCS_CMD_CHANNEL:
    // command channel
    RCS_CMD_CHANNEL *cmd =
             new RCS_CMD_CHANNEL(emcFormat, "emcCommand", "xemc", file);
    int emcCommandSerialNumber = 0;
and sending a command consists of something like
    EMC_TASK_ABORT m;
    m.serial_number = ++emcCommandSerialNumber;
    // most commands have other fields that must be initialized
    // such as EMC_TASK_SET_MODE::mode
    cmd->write(m);
    // at this point, many UIs have logic to "wait for task to receive
    // the command", though xemc does not

To recieve error notices create an error connection
    // error channel
    NML *error = new NML(emcFormat, "emcError", "xemc", file);
and poll it like yo usee in xemc.cc:updateError().  Note that when
multiple UIs exist which poll for errors, only one of them will receive
the error.

The string "xemc" which occurs in several places is a magic string; you
will just want to leave it unchanged.

------------------------------------------------------------------------------
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