File: modbus_strerror.md

package info (click to toggle)
libmodbus 3.1.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,112 kB
  • sloc: ansic: 5,495; javascript: 137; makefile: 90; sh: 26
file content (39 lines) | stat: -rw-r--r-- 854 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# modbus_strerror

## Name

modbus_strerror - return the error message

## Synopsis

```c
const char *modbus_strerror(int errnum);
```

## Description

The *modbus_strerror()* function shall return a pointer to an error message
string corresponding to the error number specified by the `errnum` argument. As
libmodbus defines additional error numbers over and above those defined by the
operating system, applications should use *modbus_strerror()* in preference to
the standard *strerror()* function.

## Return value

The *modbus_strerror()* function shall return a pointer to an error message
string.

## Errors

No errors are defined.

## Example

Display an error message when a Modbus connection cannot be established

```c
if (modbus_connect(ctx) == -1) {
    fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
    abort();
}
```