'\" t .\" Title: modbus_read_bits .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/15/2022 .\" Manual: libmodbus Manual .\" Source: libmodbus v3.1.6 .\" Language: English .\" .TH "MODBUS_READ_BITS" "3" "10/15/2022" "libmodbus v3\&.1\&.6" "libmodbus Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" modbus_read_bits \- read many bits .SH "SYNOPSIS" .sp \fBint modbus_read_bits(modbus_t *\fR\fB\fIctx\fR\fR\fB, int \fR\fB\fIaddr\fR\fR\fB, int \fR\fB\fInb\fR\fR\fB, uint8_t *\fR\fB\fIdest\fR\fR\fB);\fR .SH "DESCRIPTION" .sp The \fBmodbus_read_bits()\fR function shall read the status of the \fInb\fR bits (coils) to the address \fIaddr\fR of the remote device\&. The result of reading is stored in \fIdest\fR array as unsigned bytes (8 bits) set to TRUE or FALSE\&. .sp You must take care to allocate enough memory to store the results in \fIdest\fR (at least \fInb\fR * sizeof(uint8_t))\&. .sp The function uses the Modbus function code 0x01 (read coil status)\&. .SH "RETURN VALUE" .sp The function shall return the number of read bits if successful\&. Otherwise it shall return \-1 and set errno\&. .SH "ERRORS" .PP \fBEMBMDATA\fR .RS 4 Too many bits requested .RE .SH "SEE ALSO" .sp \fBmodbus_write_bit\fR(3) \fBmodbus_write_bits\fR(3) .SH "AUTHORS" .sp The libmodbus documentation was written by Stéphane Raimbault