---
name: "modbus_get_slave"
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_get_slave"
---

# modbus\_get\_slave(3)

get slave number in the context

## NAME

modbus\_get\_slave - get slave number in the context

## SYNOPSIS

**int modbus\_get\_slave(modbus\_t \****ctx***);**

## DESCRIPTION

The **modbus\_get\_slave()** function shall get the slave number in the libmodbus context.

## RETURN VALUE

The function shall return the slave number if successful. Otherwise it shall return -1 and set errno to one of the values defined below.

## ERRORS

**EINVAL**

The libmodbus context is undefined.

## SEE ALSO

[**modbus\_set\_slave**(3)](/modbus_set_slave/3.md)

## AUTHORS

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