Page 1 of 2
Help with the c++ API
Posted:
Mon Jul 22, 2024 11:17 am
by TheButcher
Hi everyone,
I want to start a stepcraft d420 with a c++ code and tried to use the API which comes with the software. However I realized that the header File doesnt have a corresponding cpp file which defines the behaviour of the definitions. Can anyone help me with that problem? Are there other ways of starting a Process with c++?
Thanks in advance
Re: Help with the c++ API
Posted:
Mon Jul 22, 2024 1:19 pm
by cncdrive
Which UCCNC version are you using?
Re: Help with the c++ API
Posted:
Wed Jul 24, 2024 9:06 am
by TheButcher
Im currently using 1.2113
Re: Help with the c++ API
Posted:
Tue Jul 30, 2024 8:33 pm
by jdg26
Here's a simple C++ example that calls ListDevices from the DLL:
- Code: Select all
#include <stdio.h>
#include <windows.h>
typedef int (*ListDevicesFP)(int*);
int main() {
// load the UC100 DLL
HINSTANCE hGetProcLib = LoadLibrary(".\\UC100.dll");
if (!hGetProcLib) {
printf("could not load the dynamic library\n");
return 1;
}
// get the function we want, ListDevices in this example
ListDevicesFP func = (ListDevicesFP)GetProcAddress(hGetProcLib, "ListDevices");
if (!func) {
printf("could not locate the function\n");
return 1;
}
// call the DLL function
int x = 0;
int r = func(&x);
printf("%d\n", r);
return 0;
}
If you're running on a 32bit system, make sure you use the 32bit C++ compiler, and vice versa for a 64bit system.
Hope this helps
Re: Help with the c++ API
Posted:
Fri Aug 16, 2024 1:34 pm
by TheButcher
Thank you very much jdg26!
Nowim wondering if theres a command to start executing gcode. I can seem to find any sort of thing in the .h or .dll.
best,
TheButcher
Re: Help with the c++ API
Posted:
Fri Aug 16, 2024 3:18 pm
by cncdrive
You just have to add functions to the motion buffer and the controller will start optimising and executing them and you can call the stop command to empty the motion buffer and stop the code execution.
Re: Help with the c++ API
Posted:
Mon Aug 19, 2024 6:30 am
by TheButcher
How do i do that?
Re: Help with the c++ API
Posted:
Mon Aug 19, 2024 6:59 am
by TheButcher
ok im just too stupid to read, found the command:
- Code: Select all
extern "C" UC100API int AddLinearMove(double x,double y,double z,double a,double b,double c, double Feed, int ID); //Adds one linear movement to the motion buffer for execution.
It describes what you said! Thank you very much
Re: Help with the c++ API
Posted:
Mon Aug 19, 2024 7:56 am
by TheButcher
ok, ive played around a bit and came to the conclusion, that the program somehow isnt connected to the UC100 driver/the software.
What is the general workflow for using the machine via c++?
thanks in advance
Re: Help with the c++ API
Posted:
Wed Aug 21, 2024 12:58 am
by jdg26
Can you share your test code?