1 Title: LinuxCNC MQTT publisher component
2 Tags: english, debian, linuxcnc, robot
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 <a href="https://github.com/LinuxCNC/linuxcnc/pull/2253">a patch to the
13 LinuxCNC project</a>.</p>
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 and the extensive documentation, this was fairly straight
20 forward. The hardest part was creating a automated test for the
21 component to ensure it was working. Testing it in a simulated
22 LinuxCNC machine proved very useful, as I discovered features I needed
23 that I had not thought of yet, and adjusted the code quite a bit to
24 make it easier to test without a operational MQTT broker
27 <p>The draft is ready and working, but I am unsure which LinuxCNC HAL
28 pins I should collect and publish by default (in other words, the
29 default set of information pieces published), and how to get the
30 machine name from the LinuxCNC INI file. The latter is a minor
31 detail, but I expect it would be useful in a setup with several
32 machines available. I am hoping for feedback from the experienced
33 LinuxCNC developers and users, to make the component even better
34 before it can go into the mainland LinuxCNC code base.</p>
36 <p>Since I started on the MQTT component, I came across
37 <a href="https://yewtu.be/watch?v=Bqa2grG0XtA">another video from Kent
38 VanderVelden</a> where he combine LinuxCNC with a set of screen glasses
39 controlled by a Raspberry Pi, and it occured to me that it would
40 be useful for such use cases if LinuxCNC also provided a REST API for
41 querying its status. I hope to start on such component once the MQTT
42 component is working well.</p>
44 <p>As usual, if you use Bitcoin and want to show your support of my
45 activities, please send Bitcoin donations to my address
46 <b><a href="bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b</a></b>.</p>