Run Macro through UDP to select laser source

I have a tricky situation:

I’m working with the xtool F1 that has an IR and a Diode source. If I want to run the next job with the IR laser, I need to call a Macro with a single gcode line:

xTool-F1-V2.2.lbdev:

      "Macro0_Content": "M114S2\n",
      "Macro0_Label": "RED_LASER",
      "Macro1_Content": "M114S1\n",
      "Macro1_Label": "BLUE_LASER",

This works and I can engrave metal. However, I want to send the job directly to my laser so that I just have to press “Start” (or use my foot pedal that uses the udp-interface).

So my question is if there is a way to run this macro for the next job without using the mouse or keyboard. I looked at the network connection and Lightburn directly sends the M114S-gcode to the laser when the button is pressed. (X1 is connected via USB but creates a network interface, so it’s essentially tcp/ip).

I thought about sending that string myself via

netcat 201.234.3.1 8780 <<< M114S2

This changes the used laser, but lightburn does not like that someone else is using the same TCP-connection. If I afterwards start a laser job, lightburn sends the gcode for the job (and the laser runs), but it stays in “Busy”-mode and does not react to new commands. (‘start’ on the udp-connection returns with a ‘!’).

What I can do is close lightburn, send the M114S2-gcode, open lightburn and run the job. But that’s rather slow.

Any ideas how I can use an automated interface to run a macro or send gcode?

You might be able to use the device settings to select what gcode to send before and after a run.

This is the only way I know of to do what you want. You may have to create different devices for the led and 1064nM, so the gcode is correct for both of them.

Good luck

:smiley_cat:

Hey!

Thanks for the idea. But I need to quickly switch between both lasers.

I’m even thinking on engraving multi material jobs (e.g. metal cufflinks and a wooden box in the same job). In this case I want to start the full process once and have my script load first the drawing for IR, engrave it, change focus, move the slider, load second drawing and engrave the wood. (And the switch of the laser is the last component in this process that I can’t trigger from a script).

If the connection is actually like a network connection I don’t see how it would mind the source of the data. There’s likely something missing in the messaging.

Could it be that you need to explicitly include the newline character in the message content?

The connection from Lightburn to the XTool is TCP, so someone else opening a connection to the laser should break the connection to lightburn and maybe then Lightburn misses some expected return message.

> newline character in the message content?

Awesome idea, but I already tested that : )

You can have independent instances of Lightburn each with one laser, I don´t know if you can “call” them separately, likely you can because you have to set different names for each instance.

That makes sense after reconsidering the scenario. I’m surprised the netcat actually succeeds.

Thanks! But I’d need two Lightburn instances for a single laser. And I’m not sure if it’s possible to change the UDP-Port to receive commands and I rely on this to load and start some jobs.

The Ruida uses UDP/ip, so it doesn’t care who sends it a message… as long as it’s sent to the Ruida. With a Ruida, you can have more than one instantiation of Lightburn going to the same laser.

Ruida, great controller… it’s communication systems aren’t the best.

:smiley_cat:

Lightburn uses TCP to talk to the controller. This is defined in the lbdev:

        "Type": "TCP",
        "Width": 115

and is also confirmed through wireshark:

I tried to simply replace the TCP with UDP in the lbdev, but it’s not working:

201.234.3.2 is my machine, 201.234.3.1 is the xTool F1.

nmap -u 201.234.3.1 -p 1-65000
PORT STATE SERVICE
21/tcp open ftp
23/tcp open telnet
80/tcp open http
8080/tcp open http-proxy
8081/tcp open blackice-icecap
8084/tcp open unknown
8085/tcp open unknown
8087/tcp open simplifymedia
8780/tcp open unknown

8780 is used for communication, I haven’t looked into the other ports.

So far, I did not find any open UDP-ports.

The Ruida only speaks UDP as far as I know. I’ve connected to the same Ruida with Lightburn, simultaneously, on two different computers…

It was on my local lan.

:smiley_cat:

(post deleted by author)

(post deleted by author)