Commit f9263110a44c2e16087f68f1e6077f33825a2053
1 parent
c010593c
Add documentation of modbus_rtu_[gs]et_rts functions
Showing
5 changed files
with
135 additions
and
1 deletions
doc/Makefile.am
| @@ -26,6 +26,8 @@ MAN3 = \ | @@ -26,6 +26,8 @@ MAN3 = \ | ||
| 26 | modbus_report_slave_id.3 \ | 26 | modbus_report_slave_id.3 \ |
| 27 | modbus_rtu_get_serial_mode.3 \ | 27 | modbus_rtu_get_serial_mode.3 \ |
| 28 | modbus_rtu_set_serial_mode.3 \ | 28 | modbus_rtu_set_serial_mode.3 \ |
| 29 | + modbus_rtu_get_rts.3 \ | ||
| 30 | + modbus_rtu_set_rts.3 \ | ||
| 29 | modbus_send_raw_request.3 \ | 31 | modbus_send_raw_request.3 \ |
| 30 | modbus_set_bits_from_bytes.3 \ | 32 | modbus_set_bits_from_bytes.3 \ |
| 31 | modbus_set_bits_from_byte.3 \ | 33 | modbus_set_bits_from_byte.3 \ |
doc/libmodbus.txt
| @@ -70,6 +70,9 @@ Create a Modbus RTU context:: | @@ -70,6 +70,9 @@ Create a Modbus RTU context:: | ||
| 70 | Set the serial mode:: | 70 | Set the serial mode:: |
| 71 | linkmb:modbus_rtu_get_serial_mode[3] | 71 | linkmb:modbus_rtu_get_serial_mode[3] |
| 72 | linkmb:modbus_rtu_set_serial_mode[3] | 72 | linkmb:modbus_rtu_set_serial_mode[3] |
| 73 | + linkmb:modbus_rtu_get_rts[3] | ||
| 74 | + linkmb:modbus_rtu_set_rts[3] | ||
| 75 | + | ||
| 73 | 76 | ||
| 74 | 77 | ||
| 75 | TCP (IPv4) Context | 78 | TCP (IPv4) Context |
doc/modbus_rtu_get_rts.txt
0 → 100644
| 1 | +modbus_rtu_get_rts(3) | ||
| 2 | +===================== | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +NAME | ||
| 6 | +---- | ||
| 7 | +modbus_rtu_get_rts - get the current RTS mode in RTU | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +SYNOPSIS | ||
| 11 | +-------- | ||
| 12 | +*int modbus_rtu_get_rts(modbus_t *'ctx');* | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +DESCRIPTION | ||
| 16 | +----------- | ||
| 17 | + | ||
| 18 | +The _modbus_rtu_get_rts()_ function shall get the current Request To Send mode | ||
| 19 | +of the libmodbus context 'ctx'. The possible returned values are: | ||
| 20 | + | ||
| 21 | +* MODBUS_RTU_RTS_NONE | ||
| 22 | +* MODBUS_RTU_RTS_UP | ||
| 23 | +* MODBUS_RTU_RTS_DOWN | ||
| 24 | + | ||
| 25 | +This function can only be used with a context using a RTU backend. | ||
| 26 | + | ||
| 27 | + | ||
| 28 | +RETURN VALUE | ||
| 29 | +------------ | ||
| 30 | +The _modbus_rtu_get_rts()_ function shall return the current RTS mode if | ||
| 31 | +successful. Otherwise it shall return -1 and set errno. | ||
| 32 | + | ||
| 33 | + | ||
| 34 | +ERRORS | ||
| 35 | +------ | ||
| 36 | +*EINVAL*:: | ||
| 37 | +The libmodbus backend is not RTU. | ||
| 38 | + | ||
| 39 | + | ||
| 40 | +SEE ALSO | ||
| 41 | +-------- | ||
| 42 | +linkmb:modbus_rtu_set_rts[3] | ||
| 43 | + | ||
| 44 | + | ||
| 45 | +AUTHORS | ||
| 46 | +------- | ||
| 47 | +The libmodbus documentation was written by Stéphane Raimbault | ||
| 48 | +<stephane.raimbault@gmail.com> |
doc/modbus_rtu_set_rts.txt
0 → 100644
| 1 | +modbus_rtu_set_rts(3) | ||
| 2 | +===================== | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +NAME | ||
| 6 | +---- | ||
| 7 | +modbus_rtu_set_rts - set the RTS mode in RTU | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +SYNOPSIS | ||
| 11 | +-------- | ||
| 12 | +*int modbus_rtu_set_rts(modbus_t *'ctx', int 'mode')* | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +DESCRIPTION | ||
| 16 | +----------- | ||
| 17 | +The _modbus_rtu_set_rts()_ function shall set the Request To Send mode to | ||
| 18 | +communicate on a RS485 serial bus. By default, the mode is set to | ||
| 19 | +MODBUS_RTU_RTS_NONE and no signal is issued before writing data on the wire. | ||
| 20 | + | ||
| 21 | +To enable the RTS mode, the values MODBUS_RTU_RTS_UP or MODBUS_RTU_RTS_DOWN must | ||
| 22 | +be used, these modes enable the RTS mode and set the polarity at the same | ||
| 23 | +time. When MODBUS_RTU_RTS_UP is used, an ioctl call is made with RTS flag | ||
| 24 | +enabled then data is written on the bus after a delay of 1ms, then another ioctl | ||
| 25 | +call is made with the RTS flag disabled and again a delay of 1ms occurs. | ||
| 26 | +The MODBUS_RTU_RTS_DOWN mode applies the same procedure but with an inversed | ||
| 27 | +RTS flag. | ||
| 28 | + | ||
| 29 | +This function can only be used with a context using a RTU backend. | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +RETURN VALUE | ||
| 33 | +------------ | ||
| 34 | +The _modbus_rtu_set_rts()_ function shall return 0 if successful. Otherwise it | ||
| 35 | +shall return -1 and set errno to one of the values defined below. | ||
| 36 | + | ||
| 37 | + | ||
| 38 | +ERRORS | ||
| 39 | +------ | ||
| 40 | +*EINVAL*:: | ||
| 41 | +The libmodbus backend isn't RTU or the mode given in argument is invalid. | ||
| 42 | + | ||
| 43 | + | ||
| 44 | +EXAMPLE | ||
| 45 | +------- | ||
| 46 | +.Enable the RTS mode with positive polarity | ||
| 47 | +[source,c] | ||
| 48 | +------------------- | ||
| 49 | +modbus_t *ctx; | ||
| 50 | +uint16_t tab_reg[10]; | ||
| 51 | + | ||
| 52 | +ctx = modbus_new_rtu("/dev/ttyS0", 115200, 'N', 8, 1); | ||
| 53 | +modbus_set_slave(ctx, 1); | ||
| 54 | +modbus_rtu_set_serial_mode(ctx, MODBUS_RTU_RS485); | ||
| 55 | +modbus_rtu_set_rts(ctx, MODBUS_RTU_RTS_UP); | ||
| 56 | + | ||
| 57 | +if (modbus_connect(ctx) == -1) { | ||
| 58 | + fprintf(stderr, "Connexion failed: %s\n", modbus_strerror(errno)); | ||
| 59 | + modbus_free(ctx); | ||
| 60 | + return -1; | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +rc = modbus_read_registers(ctx, 0, 7, tab_reg); | ||
| 64 | +if (rc == -1) { | ||
| 65 | + fprintf(stderr, "%s\n", modbus_strerror(errno)); | ||
| 66 | + return -1; | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +modbus_close(ctx); | ||
| 70 | +modbus_free(ctx); | ||
| 71 | +------------------- | ||
| 72 | + | ||
| 73 | +SEE ALSO | ||
| 74 | +-------- | ||
| 75 | +linkmb:modbus_rtu_get_rts[3] | ||
| 76 | + | ||
| 77 | + | ||
| 78 | +AUTHORS | ||
| 79 | +------- | ||
| 80 | +The libmodbus documentation was written by Stéphane Raimbault | ||
| 81 | +<stephane.raimbault@gmail.com> |
doc/modbus_strerror.txt
| @@ -34,7 +34,7 @@ No errors are defined. | @@ -34,7 +34,7 @@ No errors are defined. | ||
| 34 | 34 | ||
| 35 | EXAMPLE | 35 | EXAMPLE |
| 36 | ------- | 36 | ------- |
| 37 | -.Displaying an error message when a Modbus connection cannot be established | 37 | +.Display an error message when a Modbus connection cannot be established |
| 38 | [source,c] | 38 | [source,c] |
| 39 | ------------------- | 39 | ------------------- |
| 40 | if (modbus_connect(ctx) == -1) { | 40 | if (modbus_connect(ctx) == -1) { |