MODBUS_RTU_SET_CUSTO(3)

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

✨ modbus_rtu_set_custom_rts ✨

okay bestie, so this one lives in the libmodbus Manual, section 3, and it's literally all about making the RTS pin do your bidding. πŸ’…


🌸 NAME 🌸

modbus_rtu_set_custom_rts β€” set a function to be used for custom RTS implementation


πŸŽ€ SYNOPSIS πŸŽ€

int modbus_rtu_set_custom_rts(modbus_t *ctx, void (set_rts) (modbus_t ctx, int on))

πŸ¦‹ DESCRIPTION πŸ¦‹

so the modbus_rtu_set_custom_rts() function shall set a custom function to be called when the RTS pin is to be set before and after a transmission. by default this is set to an internal function that toggles the RTS pin using an ioctl call. no cap, that's the factory vibe. ✨

⚠️ note that this function adheres to the RTS mode, the values MODBUS_RTU_RTS_UP or MODBUS_RTU_RTS_DOWN must be used for the function to be called. like, your custom function literally will not get called without one of those, so don't come crying to me. 😭

and this function can only be used with a context using a RTU backend. that's the whole rule. 🫢


πŸ’– RETURN VALUE πŸ’–

the modbus_rtu_set_custom_rts() function shall return 0 if successful. πŸŽ‰

otherwise it shall return -1 and set errno to one of the values defined below. πŸ™ˆ


🌈 ERRORS 🌈

  • EINVAL β€” the libmodbus backend is not RTU. πŸ’€

πŸ‘‘ AUTHORS πŸ‘‘

Jimmy Bergstrâm <jimmy@ekontroll.com> 🧚

the libmodbus documentation was written by Stéphane Raimbault <stephane.raimbault@gmail.com> 🌸



and that's the whole page, bestie β€” libmodbus v3.1.6, dated 11/17/2025. go forth and toggle those pins responsibly πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from