ProSoft Technology MVI69-ADM User Manual

Page 316

Advertising
background image

Side-Connect API Library Functions

MVI-ADM ♦ 'C' Programmable

Developer's Guide

'C' Programmable Application Development Module

Page 316 of 342

ProSoft Technology, Inc.

February 20, 2013

MVIsc_PLCMsgWrite

Syntax

int MVIsc_PLCMsgWrite(HANDLE handle, void *buf, WORD datatype, WORD size, BYTE
msgnum, WORD timeout);

Parameters

handle

Handle returned by previous call to MVIsc_Open

buf

Pointer to user buffer to receive data written by PLC-5

datatype

Type of data (MVISC_DTYP_WORD or MVISC_DTYP_FLOAT)

size

Number of items of type datatype to be transferred. The total size
cannot exceed 240 bytes.

msgnum

PLC-5 message number (0 to 31)

timeout

Maximum number of milliseconds to wait for message-write

Description
MVIsc_PLCMsgRead handles a PLC-5 message-write instruction. This function
should be called before the PLC-5 issues the message-write instruction.

handle must be a valid handle returned from MVIsc_Open. timeout indicates the
number of milliseconds to wait for the message-write instruction from the PLC-5.
A value of zero will cause the function to register the message handler and return
immediately, without waiting for the message-write instruction. In this case, the
MVIsc_PLCMsgWait function must be used to determine if the instruction has
been completed.

Return Value

MVISC_SUCCESS

The command completed without error (Note: If timeout was set
to zero, this does not mean that the message-write instruction
has completed, but only that the message handler was
successfully registered. See MVIsc_PLCMsgWait).

MVISC_ERR_NOACCESS

handle does not have access

MVISC_ERR_PLCTIMEOUT

The timeout expired before the message-write instruction
occurred.

Example

HANDLE Handle;
int N;
/* Setup message-write handler for msg 2, wait 5 seconds */
rc = MVIsc_PLCMsgWrite(Handle, &N, MVISC_DTYP_WORD, 1, 2, 5000);
if (rc != MVISC_SUCCESS)
printf("ERROR: MVIsc_PLCMsgWrite failed");

Advertising