New GUI for embedded systems

More
8 years 1 month ago #117422 by travis.gillin
andypugh - I may subscribe to the mailing list later on but I think I figured out a good solution.

grotius - I'm going to send you a PM, I don't want to use this forum to advertise my company.

I found a solution to my questions. I'm going to use the python library to execute python code from inside the C code of my GUI. It seems funny to go C GUI->python->C python bindings->LinuxCNC when I could just go C GUI->LinuxCNC but right now the python interface is pretty well documented so I'm going to go this route for now. It seems to be working well, I'll make the Github repository public once I have a GUI up and running.

Thanks!

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #117423 by andypugh
It would probably make more sense to make a thin shim layer between your C and the C++ API.

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #117425 by travis.gillin
I agree but the documentation is really hard to get through and come up with something that works. If you can come up with an example of c++ code that uses includes from /usr/include that initiates an NML interface and speaks of how to actually send commands across I'd love to see it but I've already spent 10 hours today digging and I'm empty handed. The python method is a little bulky and is now the only externally linked library my gui needs in order to compile, so I would love to ditch this method.

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago - 8 years 1 month ago #117434 by Grotius
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.
Last edit: 8 years 1 month ago by Grotius.

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #117456 by travis.gillin
Thanks for the link! The C++ code on that forum compiles and works!

The CC line they pointed to was for compiling it inside the linuxcnc source package. I used "g++ -o test test.cpp -lnml -llinuxcnc" and changed the includes from "emc.hh" and "emc_nml.h" to <linuxcnc/emc.hh> and <linuxcnc/emc_nml.hh> so it will compile against the linuxcnc that is already installed on the system. Also the nml file is at /usr/share/linuxcnc.nml

Hopefully, this information is useful for others as well!

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago - 8 years 1 month ago #117536 by Grotius
Hi,

Nice, i think when you are ready, you have to do changes to the makefile. During compiling it would follow your modified makefile file i think. I would be interested if you have succes with separating the halui commands. Then your hmi interface can be separeted from python code and be written full in C or C++ (i have only used c so far). I like that. Feel free to show your example.

Later on it is usefull to implement fpga connections. This is the future of embedded cnc systems.
Last edit: 8 years 1 month ago by Grotius.

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum