| 1 | # modbus_rtu_set_serial_mode |
| 2 | |
| 3 | ## Name |
| 4 | |
| 5 | modbus_rtu_set_serial_mode - set the serial mode |
| 6 | |
| 7 | ## Synopsis |
| 8 | |
| 9 | ```c |
| 10 | int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode); |
| 11 | ``` |
| 12 | |
| 13 | ## Description |
| 14 | |
| 15 | The *modbus_rtu_set_serial_mode()* function shall set the selected serial |
| 16 | mode: |
| 17 | |
| 18 | - **MODBUS_RTU_RS232**, the serial line is set for RS-232 communication. RS-232 |
| 19 | (Recommended Standard 232) is the traditional name for a series of standards |
| 20 | for serial binary single-ended data and control signals connecting between a |
| 21 | DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating Equipment). |
| 22 | It is commonly used in computer serial ports. |
| 23 | |
| 24 | - **MODBUS_RTU_RS485**, the serial line is set for RS-485 communication. |
| 25 | EIA-485, also known as TIA/EIA-485 or RS-485, is a standard defining the |
| 26 | electrical characteristics of drivers and receivers for use in balanced |
| 27 | digital multipoint systems. This standard is widely used for communications |
| 28 | in industrial automation because it can be used effectively over long |
| 29 | distances and in electrically noisy environments. |
| 30 | |
| 31 | This function is only supported on Linux kernels 2.6.28 onwards. |
| 32 | |
| 33 | ## Return value |
| 34 | |
| 35 | The function shall return 0 if successful. Otherwise it shall return -1 and set |
| 36 | errno to one of the values defined below. |
| 37 | |
| 38 | ## Errors |
| 39 | |
| 40 | - *EINVAL*, the current libmodbus backend is not RTU. |
| 41 | - *ENOTSUP*, the function is not supported on your platform. |
| 42 | |
| 43 | If the call to `ioctl()` fails, the error code of ioctl will be returned. |