Debian Codegraph @

docs/modbus_write_bits.md

raw symbols SCIP
1 # modbus_write_bits
2
3 ## Name
4
5 modbus_write_bits - write many bits
6
7 ## Synopsis
8
9 ```c
10 int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *src);
11 ```
12
13 ## Description
14
15 The *modbus_write_bits()* function shall write the status of the `nb` bits
16 (coils) from `src` at the address `addr` of the remote device. The
17 `src` array must contain bytes set to `TRUE` or `FALSE`.
18
19 The `src` array must be allocated with at least `nb` elements. It is the
20 caller's responsibility to ensure the buffer is large enough to hold all the
21 bits to be written.
22
23 The function uses the Modbus function code 0x0F (force multiple coils).
24
25 ## Return value
26
27 The function shall return the number of written bits if successful. Otherwise it
28 shall return -1 and set errno.
29
30 ## Errors
31
32 - *EINVAL*, the `ctx` or `src` argument is NULL, or `nb` is less than 1.
33 - *EMBXILVAL*, writing too many bits (nb > MODBUS_MAX_WRITE_BITS).
34
35 ## See also
36
37 - [modbus_read_bits](modbus_read_bits.md)
38 - [modbus_write_bit](modbus_write_bit.md)