Sending own G-Code directly from a selfbuilt software?

Hello there,
i want to send single G-Code lines automatically from my software (over the serial port for example) to the snapmaker 2.0 A350. Is there an API for the device? Or could i use the G-Code Terminal and sending the G-Code to the Terminal for steering the snapmaker directly.
Because of the precision of the snapmaker, i want to use the machine to calibrate a camera (with an laserline projected into the picture).
Thanks for every hint i can get…

There’s a wireless API you can use, I use it for starting files remotely, or sending individual gcode lines. I’ve documented them here;

Specifically the “send gcode” section,

@echo off
:a
set /p code=gcode to send:
curl -X POST "http://[IP HERE]:8080/api/v1/connect?token=[TOKEN HERE]"
curl -X POST "http://[IP HERE]:8080/api/v1/execute_code?token=[TOKEN HERE]&code=%code%"
goto :a

You just need the two curl lines and the proper information, the first post of that thread describes how to get the token for your machine. The machine should also take standard USB serial commands.

1 Like

OK. Danke erstmal für die Meldung.
Kann ich das auch direkt über die serielle Schnittstelle schicken? Weil immer ein batch File generieren ist unpraktisch.

You don’t always have to generate the batch file, you just save it once and when you open it, it asks what to send.

Or if you’re writing the software yourself, implement the curl lines and their variables.

Do you know, where to find the code for the curl commands? Which code i have to implement? Is there only python code or is there somewhere C++ Code, too?

I listed them above.

curl -X POST "http://[IP HERE]:8080/api/v1/connect?token=[TOKEN HERE]"
curl -X POST "http://[IP HERE]:8080/api/v1/execute_code?token=[TOKEN HERE]&code=%code%"

The first line, you input your snapmaker IP in the [IP HERE] area (no brackets) and the token from your luban settings [TOKEN HERE]. The first line connects to the machine, which makes it ready to receive a command. The second line is the one that sends a command, using %code% as the variable.

I don’t know any C++ or python, this was done in a windows batch file. However, the curl commands can be ran from pretty much everything, even just a command/bash window.

ok,…thank you very much…!