ProSoft Technology MVI69-ADM User Manual

Page 312

Advertising
background image

Side-Connect API Library Functions

MVI-ADM ♦ 'C' Programmable

Developer's Guide

'C' Programmable Application Development Module

Page 312 of 342

ProSoft Technology, Inc.

February 20, 2013

MVIsc_RMWPLC

Syntax

int MVIsc_RMWPLC(HANDLE handle, WORD and_mask, WORD or_mask, WORD fileno, WORD
elemno, WORD subelemno);

Parameters

handle Handle

returned by previous call to MVIsc_Open

and_mask

Bits to be preserved in the data item

or_mask

Bits to be set in the data item

fileno

PLC-5 data table file number

elemno

PLC-5 data table element number

subelemno

PLC-5 data table subelement number

Description
MVIsc_RMWPLC reads a word from a PLC-5 data table, modifies some of the
bits, and then writes it back.

handle must be a valid handle returned from MVIsc_Open. and_mask specifies
the bits to be preserved in the data word. A "1' bit preserves the corresponding
bit in the data word; a "0' bit forces the corresponding bit to zero. or_mask
specifies the bits to be set in the data word. A "1' bit forces the corresponding bit
in the data word to 1; a '0' bit leaves the corresponding bit unchanged. The
or_mask
is applied after the and_mask.

fileno and elemno specify the data table file number and element number of the
data word to be modified. subelemno is used to address structured data. It
specifies the offset to a particular data word within a multi-word data structure,
such as a PID structure. For simple data files such as integer, subelemno must
be set to zero; otherwise, no data will be written and MVISC_ERR_XFERFAIL
will be returned. subelemno is specified as the word offset within the data
structure.

Note: For convenience, sub-element definitions for each of the data items within the various PLC-5

data structures are provided in the API include file MVISCAPI.H.

Notes: An attempt to access past the end of a data table file will result in a return code of
MVISC_ERR_XFERFAIL or MVISC_ERR_PCCCFAIL. If the PLC is in RUN mode when this

access is attempted, PLC-5 data will be corrupted and the PLC-5 will be faulted. Care should be

taken not to exceed the boundaries of the PLC-5 data tables. See MVIsc_GetPLCFileInfo to

determine valid data table boundaries.

Return Value

MVISC_SUCCESS

The data was written successfully

MVISC_ERR_NOACCESS

handle does not have access

MVISC_ERR_BADPARAM

Parameter contains invalid value

Advertising