| 1 | # modbus_rtu_get_serial_mode |
| 2 | |
| 3 | ## Name |
| 4 | |
| 5 | modbus_rtu_get_serial_mode - get the current serial mode |
| 6 | |
| 7 | ## Synopsis |
| 8 | |
| 9 | ```c |
| 10 | int modbus_rtu_get_serial_mode(modbus_t *ctx); |
| 11 | ``` |
| 12 | |
| 13 | ## Description |
| 14 | |
| 15 | The *modbus_rtu_get_serial_mode()* function shall return the serial mode |
| 16 | currently used by the libmodbus context: |
| 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. EIA-485, |
| 25 | also known as TIA/EIA-485 or RS-485, is a standard defining the electrical |
| 26 | characteristics of drivers and receivers for use in balanced digital |
| 27 | multipoint systems. This standard is widely used for communications in |
| 28 | industrial automation because it can be used effectively over long distances |
| 29 | and in electrically noisy environments. This function is only available on |
| 30 | Linux kernels 2.6.28 onwards and can only be used with a context using a RTU |
| 31 | backend. |
| 32 | |
| 33 | ## Return value |
| 34 | |
| 35 | The function shall return `MODBUS_RTU_RS232` or `MODBUS_RTU_RS485` if |
| 36 | successful. Otherwise it shall return -1 and set errno to one of the values |
| 37 | defined below. |
| 38 | |
| 39 | ## Errors |
| 40 | |
| 41 | - *EINVAL*, the current libmodbus backend is not RTU. |