MODBUS_WRITE_BIT(3)

πŸ“¦
version 3.1.6 Β· 3 versions
, in debian bookworm

✨ 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 1 if successful ⭐
  • otherwise it shall return -1 and set errno πŸ’€

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