ser_sr24_get_portmode


int   ser_sr24_get_portmode(
     ser_sr24 handle,   //serial board handle
     int port,   //serial board port whose configuration you want to read
     int property   //port property you want to know about
     );

Summary

The ser_sr24_get_portmode function is used to read the current state of a particular property of the specified port. For example, you can use this function to check if the 'direction' property of Port 2 is set to 'input' or 'output'; or you can determine if the buffer on Port 3 is enabled or disabled. Note that the serial board does not actually have a function which provides this information. Instead, the configuration data is simply read from the serial board data structure which is maintained by the API.

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 whose configuration you want to read. Valid range is 1 - 3.
property:
    Each port has several properties which can be configured and whose current state may be reported (e.g. buffer state, data direction, analog/digital). This parameter specifies which port property you want to know about. Pass a predefined constant for the desired property. See the API reference page for a list of constants.

Return Values

Returns the state of the specified property of the specified port. If an error occurs, an error code will be returned. Note that any error code will be a negative number. Possible error codes include:

Sample

Here is a small sample segment of code that determines the direction of Port 1:
int mode;

/* the board has already been opened, and the handle stored in 'handle' */

mode = ser_sr24_get_portmode(handle, 1, SR24_DIRECTION);

if(mode < 0) /* all error codes are negative */
{
	printf("Error getting portmode: %s\n", ser_sr24_error_string(mode));
}
else if(mode == SR24_DIRECTION_INPUT)
{
	printf("Port 1 is in input mode.\n");
}
else if(mode == SR24_DIRECTION_OUTPUT)
{
	printf("Port 1 is in output mode.\n");
}


Visual Basic Notes

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

Prototype:
object.GetPortMode(
     ByVal port As Long   'serial board port whose configuration you want to read
     ByVal property As PortProperty   'port property you want to know about
     ) As Long

Example
result = object.GetPortMode(3, SR24_DIRECTION)   'find out if Port 3 is in Input or Output mode



Back to Contents Winford Engineering (2000)