Debian Codegraph @

docs/modbus_read_bits.md

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