MODBUS_WRITE_BIT(3)
β¨ MODBUS_WRITE_BIT β¨
okay bestie, we're in the libmodbus manual and today's main character is modbus_write_bit π
πΈ NAME πΈ
modbus_write_bit β write a single bit π
π¦ SYNOPSIS π¦
int modbus_write_bit(modbus_t *ctx, int addr, int status);
π DESCRIPTION π
so here's the vibe: modbus_write_bit() shall write the status of status at the address addr of the remote device π«Ά like, you're reaching across the wire and flipping one lil switch on somebody else's machine. iconic behaviour tbh.
and the value? it must be set to TRUE or FALSE. that's it. no in-between, no "kinda", no situationship. pick a lane π«
the function uses the Modbus function code 0x05 (force single coil). yes ma'am, 0x05, force single coil, we love a function code with range π₯
π RETURN VALUE π
- the function shall return
1if successful β - otherwise it shall return
-1and seterrnoπ
so like, check errno if you get the -1, don't just sit there guessing, iykyk π
π SEE ALSO π
go read those too, they're the friend group fr fr π
π AUTHORS π
the libmodbus documentation was written by StΓ©phane Raimbault <stephane.raimbault@gmail.com> β thank you for the lore, king π«‘
and that's the whole page bestie, no cap. this was libmodbus v3.1.6, dated 11/17/2025 π¦ slay, go write some bits π β¨
π¦ where this page comes from
- debian bookworm: libmodbus-dev 3.1.6-2.1+deb12u1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms