]> pere.pagekite.me Git - homepage.git/blob - blog/data/2023-01-08-linuxcnc-mqtt.txt
Ny post om LinuxCNC.
[homepage.git] / blog / data / 2023-01-08-linuxcnc-mqtt.txt
1 Title: LinuxCNC MQTT publisher component
2 Tags: english, debian, linuxcnc, robot
3 Date: 2023-01-08 19:30
4
5 <p>I watched <a href="https://yewtu.be/watch?v=jmKUV3aNLjk">a 2015
6 video from Andreas Schiffler</a> the other day, where he set up
7 <a href="https://linuxcnc.org/">LinuxCNC</a> to send status
8 information to the MQTT broker IBM Bluemix. As I also use MQTT for
9 graphing, it occured to me that a generic MQTT LinuxCNC component
10 would be useful and I set out to implement it. Today I got the first
11 draft limping along and submitted as
12 <ahref="https://github.com/LinuxCNC/linuxcnc/pull/2253">a patch to the
13 LinuxCNC project</a>.</p>
14
15 <p>The simple part was setting up the MQTT publishing code in Python.
16 I already have set up other parts submitting data to my Mosquito MQTT
17 broker, so I could reuse that code. Writing a LinuxCNC component in
18 Python as new to me, but using existing examples in the code
19 repository, this was fairly straight forward. The hardest part was
20 creating a automated test for the component to ensure it was working.
21 Testing it in a simulated LinuxCNC machine proved very useful, as I
22 discovered features I needed that I had not thought of yet, and
23 adjusted the code quite a bit to make it easier to test without a
24 operational MQTT broker available.</p>
25
26 <p>The draft is ready and working, but I am unsure which LinuxCNC HAL
27 pins I should collect and publish by default (in other words, the
28 default set of information pieces published), and how to get the
29 machine name from the LinuxCNC INI file. The latter is a minor
30 detail, but I expect it would be useful in a setup with several
31 machines available. I am hoping for feedback from the experienced
32 LinuxCNC developers and users, to make the component even better
33 before it can go into the mainland LinuxCNC code base.</p>
34
35 <p>Since I started on the MQTT component, I came across
36 <a href="https://yewtu.be/watch?v=Bqa2grG0XtA">another video from Kent
37 VanderVelden where he combine LinuxCNC with a set of screen glasses
38 controlled by a Raspberry Pi</a>, and it occured to me that it would
39 be useful for such use cases if LinuxCNC also provided a REST API for
40 querying its status. I hope to start on such component once the MQTT
41 component is working well.</p>
42
43 <p>As usual, if you use Bitcoin and want to show your support of my
44 activities, please send Bitcoin donations to my address
45 <b><a href="bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b</a></b>.</p>