Cip callback functions – ProSoft Technology MVI69-ADM User Manual

Page 278

Advertising
background image

CIP Messaging Library Functions

MVI-ADM ♦ 'C' Programmable

Developer's Guide

'C' Programmable Application Development Module

Page 278 of 342

ProSoft Technology, Inc.

February 20, 2013

10.6 CIP Callback Functions

Note: The functions in this section are not part of the CIP API, but must be implemented by the

application. The CIP API calls the connect_proc or service_proc functions when connection or

service requests are received for the registered object. The optional rxdata_proc function is called
when data is received on a connection. The optional fatalfault_proc function is called when the

backplane device driver detects a fatal fault condition. The optional resetrequest_proc function is

called when a reset request is received by the backplane device driver.

Special care must be taken when coding the callback functions, because these
functions are called directly from the backplane device driver. in particular, no
assumptions can be made about the segment registers DS or SS. Therefore, the
compiler options or directives used must disable stack probes and reload DS. For
convenience, the macro MVICALLBACK has been defined to include the
__loadds compiler directive, which forces the data segment register to be
reloaded upon entry to the callback function.

Stack probes (or stack checking) must be disabled using compiler command line
arguments or pragmas. Stack checking is off by default for the Borland compiler.

In general, the callback routines should be as short as possible, especially
rxdata_proc. Do not call any library functions from the rxdata_proc callback
routine. Stack size is limited, so keep stack variables to a minimum.

connect_proc

Syntax

MVICALLBACK connect_proc( MVIHANDLE objHandle, MVICIPCONNSTRUC *sConn );

Parameters

objHandle

handle of registered object instance

sConn

pointer to structure of type MVICIPCONNSTRUCT

Description
connect_proc is a callback function which is passed to the CIP API in the
MVIcip_RegisterAssemblyObj call. The CIP API calls the connect_proc function
when a Class 1 scheduled connection request is made for the registered object
instance specified by objHandle.

sConn is a pointer to a structure of type MVICIPCONNSTRUCT. this structure is
shown below:

typedef struct tagMVICIPCONNSTRUC
{
MVIHANDLE connHandle; // unique value which identifies this connection
DWORD reg_param; // value passed via MVIcip_Register AssemblyObj
WORD reason; // specifies reason for callback
WORD instance; // instance specified in open
WORD producerCP; // producer connection point specified in open
WORD consumerCP; // consumer connection point specified in open
DWORD *lOTApi; // pointer to originator to target packet interval
DWORD *lTOApi; // pointer to target to originator packet interval

Advertising