'\" t .\" Title: modbus_mask_write_register .\" 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_MASK_WRITE_RE" "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_mask_write_register \- mask a single register .SH "SYNOPSIS" .sp \fBint modbus_mask_write_register(modbus_t *\fR\fB\fIctx\fR\fR\fB, int \fR\fB\fIaddr\fR\fR\fB, uint16_t \fR\fB\fIand\fR\fR\fB, uint16_t \fR\fB\fIor\fR\fR\fB);\fR .SH "DESCRIPTION" .sp The \fBmodbus_mask_write_register()\fR function shall modify the value of the holding register at the address \fIaddr\fR of the remote device using the algorithm: .sp .if n \{\ .RS 4 .\} .nf new value = (current value AND \*(Aqand\*(Aq) OR (\*(Aqor\*(Aq AND (NOT \*(Aqand\*(Aq)) .fi .if n \{\ .RE .\} .sp The function uses the Modbus function code 0x16 (mask single register)\&. .SH "RETURN VALUE" .sp The function shall return 1 if successful\&. Otherwise it shall return \-1 and set errno\&. .SH "SEE ALSO" .sp \fBmodbus_read_registers\fR(3) \fBmodbus_write_registers\fR(3) .SH "AUTHORS" .sp Martijn de Gouw The libmodbus documentation was written by Stéphane Raimbault