beautypg.com

ProSoft Technology MVI56E-LDM User Manual

Page 204

background image

CIP API Functions

ControlLogix Platform ♦ "C" Programmable

Developer's Manual

Linux Application Development Module

Page 198 of 264

ProSoft Technology, Inc.

March 12, 2014

OCXcip_GetSerialConfig

Syntax

int OCXcip_GetSerialConfig (OCXHANDLE apihandle,

OCXSPCONFIG * pSPConfig);

Parameters

apihandle

handle returned by previous call to OCXcip_Open

pSPConfig

Pointer to OCXSPCONFIG structure. The pSPConfig-
>port_num

member must be initialized to the desired port

number (1 for COM1/PRT1, 2 for COM2/PRT2, etc.)

Description

OCXcip_GetSerialConfig

retrieves the state of the configuration jumper(s) for the

selected serial port. Each port has 3 jumper positions available. Therefore,
there are potentially 8 combinations for each port. However, to maintain
backwards compatibility (and to match the jumper labeling), only 4 combinations
are defined; none, RS-232, RS-422, and RS-485. The application can choose to
define other combinations as needed.
The mode is returned in the

pSPConfig->port_cfg

member. The defined modes

are listed (from

ocxbpapi.h

):

#define SAM_SERIAL_CONFIG_NONE 0 // No jumper installed

#define SAM_SERIAL_CONFIG_RS232 1 // Port is configured for RS-232

#define SAM_SERIAL_CONFIG_RS422 2 // Port is configured for RS-422

#define SAM_SERIAL_CONFIG_RS485 4 // Port is configured for RS-485

The mode returned by this function does not necessarily mean that the port is
actually configured for that mode. The application can call

OCXcip_SetSerialConfig

to override the jumper settings and set the port to any

valid mode.

Return Value

OCX_SUCCESS

The jumper information was read successfully

OCX_ERR_NOACCESS

apihandle

does not have access

OCX_ERR_BADPARAM

Invalid port number

Example

OCXHANDLE hApi;
OCXSPCONFIG spCfg;
int rc;

/* Read configuration for first port */
spCfg.port_GetSerialConfig(hApi, &spCfg);

if (rc !=OCX_SUCCESS)