ser_sr24_set_portmode


int   ser_sr24_set_portmode(
     ser_sr24 handle,   //serial board handle
     int port,   //serial board port to configure
     int property,   //property of the port to configure
     int mode   //value to set the property to
     );

Summary

The ser_sr24_set_portmode function enables you to configure a particular port on the serial board. It allows you to configure several properties of the port, such as buffer state, data direction, and analog/digital. You must call the function once for every property you wish to set.

Note 1: There is no tri-state buffer on Port 1, since this port can be used in both analog and digital modes. You can still pass the parameters to attempt to configure this buffer which does not exist, and no error will be generated. Just be aware that doing this will not produce any results on the serial board.

Note 2: Only Port 1 may be configured as either analog or digital. Ports 2 and 3 are always digital.

Parameters

handle:
    This is the handle to the serial board; it is actually a pointer to the data structure for the board.
port:
    This identifies the port on the serial board which is to be configured; valid range is 1 - 3.
property:
    Each port has several properties which can be configured (e.g. buffer state, data direction, analog/digital). This parameter specifies which port property to configure. Pass a predefined constant for the desired property. See the API reference page for a list of constants.
mode:
    This is the value that will be assigned to the property. For example, if you are setting the direction property of the port, then this parameter would specify whether the port will be set to 'input' or 'output' mode. Pass a predefined constant for the desired value. See the API reference page for a list of valid constants.

Return Values

Function returns 0 upon success. Possible error codes include:

Sample

This small code segment puts port 2 into a high-impedance state (disables the buffer):
/* Board has already been opened, and the handle has been stored into 'handle' */

ser_sr24_set_portmode(handle, 2, SR24_BUFFER, SR24_BUFFER_DISABLED);

Visual Basic Notes

The Visual Basic equivalent of this function is the SetPortMode method. Return values are listed above.

Prototype:
object.SetPortMode(
     ByVal port As Long   'serial board port to configure
     ByVal property As PortProperty   'property of the port to configure
     ByVal mode As PortMode   'value to set the property to
     ) As Long

Example
result = object.SetPortMode(3, SR24_DIRECTION, SR24_DIRECTION_OUTPUT)   'configure Port 3 as an output port



Back to Contents Winford Engineering (2000)