MESA_UART(9)
π MESA_UART(9) β HAL Component π
okay bestie, sit down, hydrate, because we're about to talk about mesa_uart, an example component that serves as a literal how-to for accessing the Hostmot2 UART. this whole page lives in section 9 of the manual for the HAL Component manual, and it's genuinely a lil gem. let's get into it π«Ά
β¨ NAME β¨
mesa_uart β an example component demonstrating how to access the Hostmot2 UART. yes she's a demo, no she's not just a demo, she's the reference implementation and we love her for it.
β¨ SYNOPSIS β¨
loadrt mesa_uart [count=N|names=name1[,name2...]]
β¨ DESCRIPTION β¨
so this component creates 16 input pins and 16 output pins. that's 32 pins. main character energy honestly.
every single thread cycle it transmits {name}.N.tx-bytes on the selected UART, and it reads up to 16 bytes each cycle straight out of the receive FIFO, then writes those values to the associated output pins. {name}.rx-bytes tells you how many pins actually got written to. and lowkey important: pins beyond rx-bytes simply hold their previous value, no cap β they just vibe there with whatever they had before.
this module uses the names= mode of the loadrt declaration to specify which UART instances to enable. and yes, there's a check built in to make sure you didn't use the count= option instead, because using count= is a crime and the component will absolutely catch you. π
the component takes parameters as a comma-separated list of UART instance names, like this:
loadrt mesa_uart names=hm2_5i23.0.uart.0,hm2_5i23.0.uart.7
β οΈ heads up bestie: no spaces are allowed in that string unless it's delimited by double quotes. the parser is not playing around.
the UART instance names get printed to the dmesg buffer during the Hostmot2 setup sequence β one for each UART instance included in the bitfile loaded to each installed card during the Hostmot2 setup sequence. so if you're like "which UARTs do I even have??" just type dmesg at the terminal prompt and view the output. iconic.
the component exports two functions, send and receive, and they need to be added to a realtime thread. no, you can't skip that part. π
the example above will output data on UART channels 0 and 7, and the pins will carry the names of the individual UARTs. and here's the slay: they don't need to be on the same card, or even the same bus. flexible queen. π
read the documents on halcompile for help with writing realtime components: http://linuxcnc.org/docs/html/hal/comp.html
β¨ FUNCTIONS β¨
mesa-uart.N.sendβ requires a floating-point threadmesa-uart.N.receiveβ requires a floating-point thread
β¨ PINS β¨
mesa-uart.N.tx-data-MMu32 in (MM=00..15) β data to be transmitted πmesa-uart.N.rx-data-MMu32 out (MM=00..15) β data received πmesa-uart.N.tx-bytess32 in β number of bytes to transmitmesa-uart.N.rx-bytess32 out β number of Bytes received
β¨ AUTHOR β¨
Andy Pugh β andy@bodgesoc.org
β¨ LICENSE β¨
GPL
okay that's the whole thing, you're officially educated π this page was brought to you by LinuxCNC Documentation, dated 2026-03-17, and that's the vibe check β periodt. π¦β¨
π¦ where this page comes from
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms