User Tools

Site Tools


Linux CNC data -> home network

two short scripts, a Python program and the corresponding HAL file, send important machine data to the local network.

This is the basis for all projects presented here, which receive this data from the network and then process it according their function.

Many projects are possible, such as:

  • CNC warning light
  • TFT display for e.g. handwheel
  • Web page for displaying the machine data in the browser (PC, cell phone, etc.)

Python program

a small Python program provides LinuxCNC pins. These can be linked with signals. These signals are transmitted from the Python program via UDP to the receiver (i.e. CNC warning light).

Copy the Python program into a folder of your choice. To load the Python program when LinuxCNC is started, the following entry must be made in the HAL file:

loadusr ~/linuxcnc/myPython/

The path must of course be changed to the actual path.

the Python program offers some PINs, which have to be connected to data sources:

Create a HAL file with the following content:

# send machine data to ext_UDP PINs
# XYZA position, absolute and relative (G54)
net km_xposabs halui.axis.x.pos-commanded => ext_UDP.in_x_abs
net km_yposabs halui.axis.y.pos-commanded => ext_UDP.in_y_abs
.... see file:

This new HAL file must of course be specified in the ini file to be loaded.

HALFILE = ext_UDP.hal

Here you simply link several machine pins to the pins of the Python program. Some of them are special for my machine and may have different names on other machines.

Function test

with a network monitor (i.e. wireshark) you can watch the traffic in the home network.

As soon as LinuxCNC is started, every 250ms an UDP message with machine data is sent. This is addressed as a broadcast message to everyone in the network, so you don't have to worry about IP addresses and can also operate several additional devices (multiple warning lights etc.) at the same time. If you prefer to use a fixed IP, you can of course also enter a fixed IP in the Python program.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
en/udp/overview.txt · Last modified: 2022/01/10 00:23 (external edit)