From f9263110a44c2e16087f68f1e6077f33825a2053 Mon Sep 17 00:00:00 2001 From: Stéphane Raimbault Date: Wed, 20 Jul 2011 20:50:30 +0200 Subject: [PATCH] Add documentation of modbus_rtu_[gs]et_rts functions --- doc/Makefile.am | 2 ++ doc/libmodbus.txt | 3 +++ doc/modbus_rtu_get_rts.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/modbus_rtu_set_rts.txt | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/modbus_strerror.txt | 2 +- 5 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 doc/modbus_rtu_get_rts.txt create mode 100644 doc/modbus_rtu_set_rts.txt diff --git a/doc/Makefile.am b/doc/Makefile.am index d34321a..594cc30 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -26,6 +26,8 @@ MAN3 = \ modbus_report_slave_id.3 \ modbus_rtu_get_serial_mode.3 \ modbus_rtu_set_serial_mode.3 \ + modbus_rtu_get_rts.3 \ + modbus_rtu_set_rts.3 \ modbus_send_raw_request.3 \ modbus_set_bits_from_bytes.3 \ modbus_set_bits_from_byte.3 \ diff --git a/doc/libmodbus.txt b/doc/libmodbus.txt index c40af9d..adb4ee8 100644 --- a/doc/libmodbus.txt +++ b/doc/libmodbus.txt @@ -70,6 +70,9 @@ Create a Modbus RTU context:: Set the serial mode:: linkmb:modbus_rtu_get_serial_mode[3] linkmb:modbus_rtu_set_serial_mode[3] + linkmb:modbus_rtu_get_rts[3] + linkmb:modbus_rtu_set_rts[3] + TCP (IPv4) Context diff --git a/doc/modbus_rtu_get_rts.txt b/doc/modbus_rtu_get_rts.txt new file mode 100644 index 0000000..cb87050 --- /dev/null +++ b/doc/modbus_rtu_get_rts.txt @@ -0,0 +1,48 @@ +modbus_rtu_get_rts(3) +===================== + + +NAME +---- +modbus_rtu_get_rts - get the current RTS mode in RTU + + +SYNOPSIS +-------- +*int modbus_rtu_get_rts(modbus_t *'ctx');* + + +DESCRIPTION +----------- + +The _modbus_rtu_get_rts()_ function shall get the current Request To Send mode +of the libmodbus context 'ctx'. The possible returned values are: + +* MODBUS_RTU_RTS_NONE +* MODBUS_RTU_RTS_UP +* MODBUS_RTU_RTS_DOWN + +This function can only be used with a context using a RTU backend. + + +RETURN VALUE +------------ +The _modbus_rtu_get_rts()_ function shall return the current RTS mode if +successful. Otherwise it shall return -1 and set errno. + + +ERRORS +------ +*EINVAL*:: +The libmodbus backend is not RTU. + + +SEE ALSO +-------- +linkmb:modbus_rtu_set_rts[3] + + +AUTHORS +------- +The libmodbus documentation was written by Stéphane Raimbault + diff --git a/doc/modbus_rtu_set_rts.txt b/doc/modbus_rtu_set_rts.txt new file mode 100644 index 0000000..51da488 --- /dev/null +++ b/doc/modbus_rtu_set_rts.txt @@ -0,0 +1,81 @@ +modbus_rtu_set_rts(3) +===================== + + +NAME +---- +modbus_rtu_set_rts - set the RTS mode in RTU + + +SYNOPSIS +-------- +*int modbus_rtu_set_rts(modbus_t *'ctx', int 'mode')* + + +DESCRIPTION +----------- +The _modbus_rtu_set_rts()_ function shall set the Request To Send mode to +communicate on a RS485 serial bus. By default, the mode is set to +MODBUS_RTU_RTS_NONE and no signal is issued before writing data on the wire. + +To enable the RTS mode, the values MODBUS_RTU_RTS_UP or MODBUS_RTU_RTS_DOWN must +be used, these modes enable the RTS mode and set the polarity at the same +time. When MODBUS_RTU_RTS_UP is used, an ioctl call is made with RTS flag +enabled then data is written on the bus after a delay of 1ms, then another ioctl +call is made with the RTS flag disabled and again a delay of 1ms occurs. +The MODBUS_RTU_RTS_DOWN mode applies the same procedure but with an inversed +RTS flag. + +This function can only be used with a context using a RTU backend. + + +RETURN VALUE +------------ +The _modbus_rtu_set_rts()_ function shall return 0 if successful. Otherwise it +shall return -1 and set errno to one of the values defined below. + + +ERRORS +------ +*EINVAL*:: +The libmodbus backend isn't RTU or the mode given in argument is invalid. + + +EXAMPLE +------- +.Enable the RTS mode with positive polarity +[source,c] +------------------- +modbus_t *ctx; +uint16_t tab_reg[10]; + +ctx = modbus_new_rtu("/dev/ttyS0", 115200, 'N', 8, 1); +modbus_set_slave(ctx, 1); +modbus_rtu_set_serial_mode(ctx, MODBUS_RTU_RS485); +modbus_rtu_set_rts(ctx, MODBUS_RTU_RTS_UP); + +if (modbus_connect(ctx) == -1) { + fprintf(stderr, "Connexion failed: %s\n", modbus_strerror(errno)); + modbus_free(ctx); + return -1; +} + +rc = modbus_read_registers(ctx, 0, 7, tab_reg); +if (rc == -1) { + fprintf(stderr, "%s\n", modbus_strerror(errno)); + return -1; +} + +modbus_close(ctx); +modbus_free(ctx); +------------------- + +SEE ALSO +-------- +linkmb:modbus_rtu_get_rts[3] + + +AUTHORS +------- +The libmodbus documentation was written by Stéphane Raimbault + diff --git a/doc/modbus_strerror.txt b/doc/modbus_strerror.txt index 6badc5d..6bd3397 100644 --- a/doc/modbus_strerror.txt +++ b/doc/modbus_strerror.txt @@ -34,7 +34,7 @@ No errors are defined. EXAMPLE ------- -.Displaying an error message when a Modbus connection cannot be established +.Display an error message when a Modbus connection cannot be established [source,c] ------------------- if (modbus_connect(ctx) == -1) { -- libgit2 0.21.4