---
name: "modbus_rtu_get_serial_mode"
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_get_serial_mode"
---

# modbus\_rtu\_get\_serial\_mode(3)

get the current serial mode

## NAME

modbus\_rtu\_get\_serial\_mode - get the current serial mode

## SYNOPSIS

**int modbus\_rtu\_get\_serial\_mode(modbus\_t \****ctx***);**

## DESCRIPTION

The **modbus\_rtu\_get\_serial\_mode()** function shall return the serial mode currently used by the libmodbus context:

**MODBUS\_RTU\_RS232**

the serial line is set for RS232 communication. RS-232 (Recommended Standard 232) is the traditional name for a series of standards for serial binary single-ended data and control signals connecting between a DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating Equipment). It is commonly used in computer serial ports

**MODBUS\_RTU\_RS485**

the serial line is set for RS485 communication. EIA-485, also known as TIA/EIA-485 or RS-485, is a standard defining the electrical characteristics of drivers and receivers for use in balanced digital multipoint systems. This standard is widely used for communications in industrial automation because it can be used effectively over long distances and in electrically noisy environments.

This function is only available on Linux kernels 2.6.28 onwards and can only be used with a context using a RTU backend.

## RETURN VALUE

The function shall return MODBUS\_RTU\_RS232 or MODBUS\_RTU\_RS485 if successful. Otherwise it shall return -1 and set errno to one of the values defined below.

## ERRORS

**EINVAL**

The current libmodbus backend is not RTU.

## AUTHORS

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