---
name: "modbus_rtu_set_custom_rts"
section: "3"
platform: "linux"
package: "libmodbus-dev"
version: "3.1.6-2.1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/modbus_rtu_set_custom_rts"
---

# modbus\_rtu\_set\_custom\_rts(3)

set a function to be used for custom RTS implementation

## 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

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.

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.

This function can only be used with a context using a RTU backend.

## 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\>
