Help with the c++ API

Post anything you want to discuss with others about the software.

Help with the c++ API

Postby TheButcher » Mon Jul 22, 2024 11:17 am

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 :)
TheButcher
 
Posts: 11
Joined: Mon Jul 22, 2024 11:12 am

Re: Help with the c++ API

Postby cncdrive » Mon Jul 22, 2024 1:19 pm

Which UCCNC version are you using?
cncdrive
Site Admin
 
Posts: 4874
Joined: Tue Aug 12, 2014 11:17 pm

Re: Help with the c++ API

Postby TheButcher » Wed Jul 24, 2024 9:06 am

Im currently using 1.2113
TheButcher
 
Posts: 11
Joined: Mon Jul 22, 2024 11:12 am

Re: Help with the c++ API

Postby jdg26 » Tue Jul 30, 2024 8:33 pm

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
jdg26
 
Posts: 11
Joined: Wed Oct 25, 2023 1:58 pm
Location: USA

Re: Help with the c++ API

Postby TheButcher » Fri Aug 16, 2024 1:34 pm

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
TheButcher
 
Posts: 11
Joined: Mon Jul 22, 2024 11:12 am

Re: Help with the c++ API

Postby cncdrive » Fri Aug 16, 2024 3:18 pm

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.
cncdrive
Site Admin
 
Posts: 4874
Joined: Tue Aug 12, 2014 11:17 pm

Re: Help with the c++ API

Postby TheButcher » Mon Aug 19, 2024 6:30 am

How do i do that?
TheButcher
 
Posts: 11
Joined: Mon Jul 22, 2024 11:12 am

Re: Help with the c++ API

Postby TheButcher » Mon Aug 19, 2024 6:59 am

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 :)
TheButcher
 
Posts: 11
Joined: Mon Jul 22, 2024 11:12 am

Re: Help with the c++ API

Postby TheButcher » Mon Aug 19, 2024 7:56 am

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
TheButcher
 
Posts: 11
Joined: Mon Jul 22, 2024 11:12 am

Re: Help with the c++ API

Postby jdg26 » Wed Aug 21, 2024 12:58 am

Can you share your test code?
jdg26
 
Posts: 11
Joined: Wed Oct 25, 2023 1:58 pm
Location: USA

Next

Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: No registered users and 4 guests