mb2hal(1)
π mb2hal β bestie edition π
okay so real talk, this is mb2hal(1), part of the LinuxCNC Documentation set, and it's the manual page for mb2hal β a HAL non-realtime component for Modbus. yes she's niche, yes she's iconic, and yes you're gonna understand her by the end of this. let's go π¦
β¨ NAME β¨
mb2hal β a HAL non-realtime component for Modbus. that's the whole name bestie, short and slay π
β¨ SYNOPSIS β¨
okay so there's two ways to load her, depending on whether you want the default name or a custom one:
Default component name:
loadusr -W mb2hal config=config_file.ini
Custom component name:
loadusr -Wn mymodule mb2hal config=config_file.ini
so if you don't care what she's called, take option one. if you do care (valid, we love a named girl), use -Wn and pick your own. π
β¨ DESCRIPTION β¨
MB2HAL is a generic, non-realtime HAL component whose whole job is talking to one or more Modbus devices. like, she's the social butterfly of your setup fr fr π«Ά
she supports both Modbus RTU and Modbus TCP. both of them. no cap. β¨
for even more info, go look at:
http://linuxcnc.org/docs/html/drivers/mb2hal.html
(yes the link is staying exactly as-is, that's just how manpages are π)
β¨ PINS β¨
okay this is the big section, get comfy, grab a snack π. the pins depend on which Modbus function you're using, so here's the full rundown, function by function:
fnct_01_read_coils:
mb2hal.m.n.bitβbit outmb2hal.m.n.bit-invβbit out
fnct_02_read_discrete_inputs:
mb2hal.m.n.bitβbit outmb2hal.m.n.bit-invβbit out
fnct_03_read_holding_registers:
mb2hal.m.n.floatβfloat outmb2hal.m.n.intβs32 out
fnct_04_read_input_registers:
mb2hal.m.n.floatβfloat outmb2hal.m.n.intβs32 out
fnct_05_write_single_coil:
mb2hal.m.n.bitβbit in
heads up bestie:NELEMENTSneeds to be1, orPIN_NAMESmust contain just one name. don't try to be cute with this one, she will not allow it. π
fnct_06_write_single_register:
mb2hal.m.n.floatβfloat inmb2hal.m.n.intβs32 in
ok so this one has rules too:NELEMENTSneeds to be1, orPIN_NAMESmust contain just one name. also β and this is the important part β both pin values are added and limited to65535(UINT16_MAX). so the move is to use one and let the other stay open (it reads as0). don't fight it, just vibe with it. πΈ
fnct_15_write_multiple_coils:
mb2hal.m.n.bitβbit in
fnct_16_write_multiple_registers:
mb2hal.m.n.floatβfloat inmb2hal.m.n.intβs32 in
same energy as before: both pin values are added and limited to65535(UINT16_MAX). use one, let the other open (read as0). periodt. β¨
Each transaction
mb2hal.m.num_errorsβu32 inβ this one's the error counter. she's keeping score, and honestly, mood. π₯
okay now the naming lore, because this is where people get confused and I refuse to let that be you:
m=HAL_TX_NAME, or the transaction number if that's not setn= the element number (NELEMENTS)
Example:
mb2hal.00.01.int (TRANSACTION_00, second register)
mb2hal.readStatus.01.bit (HAL_TX_NAME=readStatus, first bit)
see how it works? first one is just numbered because there's no HAL_TX_NAME, second one got a cute little name and now she's readStatus. main character naming energy fr fr πβ¨
β¨ AUTHOR β¨
Victor Rocco β the legend, the icon, the moment. we stan. π
β¨ LICENSE β¨
GPL β go forth and share, bestie. π«Ά
okay that's the whole page!! this one came from the Modbus to HAL docs, dated November 20, 2021, and it's page mb2hal(1) in the LinuxCNC Documentation set. go forth and Modbus responsibly, you absolute genius. slay π
β¨ππ¦
π¦ where this page comes from
- debian trixie: linuxcnc-uspace 1:2.9.4-2+deb13u1 Β· GFDL-1.1-or-later
- ubuntu questing: linuxcnc-uspace 1:2.9.4-2ubuntu2
- 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
- Copyright (c) 2016 Victor Rocco <victor_rocco AT hotmail DOT com>
- Copyright (C) 2009-2012 Les Newell <les@sheetcam.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms