'\" t .\" Title: modbus_write_and_read_registers .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 02/28/2020 .\" Manual: libmodbus Manual .\" Source: libmodbus v3.1.6 .\" Language: English .\" .TH "MODBUS_WRITE_AND_REA" "3" "02/28/2020" "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_write_and_read_registers \- write and read many registers in a single transaction .SH "SYNOPSIS" .sp \fBint modbus_write_and_read_registers(modbus_t *\fR\fB\fIctx\fR\fR\fB, int \fR\fB\fIwrite_addr\fR\fR\fB, int \fR\fB\fIwrite_nb\fR\fR\fB, const uint16_t *\fR\fB\fIsrc\fR\fR\fB, int \fR\fB\fIread_addr\fR\fR\fB, int \fR\fB\fIread_nb\fR\fR\fB, const uint16_t *\fR\fB\fIdest\fR\fR\fB);\fR .SH "DESCRIPTION" .sp The \fBmodbus_write_and_read_registers()\fR function shall write the content of the \fIwrite_nb\fR holding registers from the array \fIsrc\fR to the address \fIwrite_addr\fR of the remote device then shall read the content of the \fIread_nb\fR holding registers to the address \fIread_addr\fR of the remote device\&. The result of reading is stored in \fIdest\fR array as word values (16 bits)\&. .sp You must take care to allocate enough memory to store the results in \fIdest\fR (at least \fInb\fR * sizeof(uint16_t))\&. .sp The function uses the Modbus function code 0x17 (write/read registers)\&. .SH "RETURN VALUE" .sp The function shall return the number of read registers if successful\&. Otherwise it shall return \-1 and set errno\&. .SH "ERRORS" .PP \fBEMBMDATA\fR .RS 4 Too many registers requested, Too many registers to write .RE .SH "SEE ALSO" .sp \fBmodbus_read_registers\fR(3) \fBmodbus_write_register\fR(3) \fBmodbus_write_registers\fR(3) .SH "AUTHORS" .sp The libmodbus documentation was written by Stéphane Raimbault