MODBUS_MASK_WRITE_RE(3)

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

πŸ’– MODBUS_MASK_WRITE_RE(3) πŸ’–

okay so bestie, welcome to the libmodbus Manual page for MODBUS_MASK_WRITE_RE(3). This is the one where we mask a single register. Not mask as in hiding your feelings, mask as in bit-math. πŸ’…


✨ NAME ✨

modbus_mask_write_register β€” mask a single register. That's it. That's the name. One register, getting the mask treatment. πŸŽ€


✨ SYNOPSIS ✨

Here's the signature, no cap:

int modbus_mask_write_register(modbus_t *ctx, int addr, uint16_t and,
       uint16_t or);

✨ DESCRIPTION ✨

The modbus_mask_write_register() function shall modify the value of the holding register at the address addr of the remote device using this algorithm:

new value = (current value AND 'and') OR ('or' AND (NOT 'and'))

It uses the Modbus function code 0x16 (mask single register). iconic. This is giving bit-mask main character energy, periodt. ✨


✨ RETURN VALUE ✨

The function shall return 1 if successful. Otherwise it shall return -1 and set errno. ngl, 1 is the slay, -1 is the "check errno bestie" moment. 😭


✨ SEE ALSO ✨


✨ AUTHORS ✨

  • Martijn de Gouw <martijn.de.gouw@prodrive.nl>
  • The libmodbus documentation was written by StΓ©phane Raimbault <stephane.raimbault@gmail.com>

and that's the whole vibe. This page is from libmodbus v3.1.6, dated 11/17/2025. mwah πŸ’‹

πŸ“¦ where this page comes from