Hi,
Here a example how to :
emc-users.narkive.com/44bLaS4j/controlli...nally-with-c-program
Code:
Anyway, here's a complete program that uses the C++ interface to log the
position at about 10Hz:
#include "emc.hh"
#include "emc_nml.hh"
#include <unistd.h>
#include <iostream>
#include <cstdlib>
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<EMC_STAT*>(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;
}
Provided by the Bird, 5 years ago.
What i found important in this conversation :
If you want to dig into it, look at the sources for xemc, halui &
halcmd. They will uncover most of the calls and show how they are used
Halui will be the most usefull to start with i think.
The source code of Halui.cc :
github.com/michelwijnja/external_offsets...mc/usr_intf/halui.cc
If you change this file in your application, you can test your connection's quite easy.
Halui pins :
linuxcnc.org/docs/html/man/man1/halui.1.html
you can use them with the halcommand line for quick test's.
In you ini file :
[HAL]
HALUI = halui
For example i think when you copy and rename the halui source code to "test" and compile linuxcnc again.
Your ini can look like :
[HAL]
HALUI = test
Then your pin names are test.program.run and so on.
If this works, you can delete some linuxcnc part's step by step to make a c or c++ coded user interface.