PREV TOC HOME INDEX NEXT


ipm_Open( )


Termination Events | Cautions | Errors | Example | See Also

Name: int ipm_Open(*szDevName, *pOpenInfo, usMode)
Inputs:

const char *szDeviceName

  • device name pointer

IPM_OPEN_INFO *pOpenInfo

  • set to NULL

unsigned short usMode

  • async or sync mode setting
Returns:

device handle if successful

-1 on failure

Includes:

srllib.h

ipmlib.h

Category:

System Control

Mode:

asynchronous or synchronous

Platform:

DM/IP, IPT, HMP

Description

The ipm_Open( ) function opens an IP channel device and returns a unique device handle to identify the physical device that performs the media transfer. All subsequent references to the opened device must be made using the handle until the device is closed.

The IP Media library allows ipm_Open( ) to be called either synchronously or asynchronously.

If ipm_Open( ) is called synchronously and no errors are received, the device handle that is returned is valid and may be used by the application.

If ipm_Open( ) is called asynchronously with valid arguments, a device handle is returned immediately. Before using this device handle in other function calls, the application must wait for an IPMEV_OPEN event indicating the handle is valid.

If ipm_Open( ) is called asynchronously and IPMEV_ERROR is returned, a device handle is also returned. The application must call ipm_Close( ) using the handle returned by ipm_Open( ).

Parameter

Description

szDeviceName pointer to device name to open. IP Media channel device: ipmBxCy where x is the unique logical board number and y is the media device channel number. board device: ipmBx where x is the unique logical board number.
pOpenInfo set to NULL; reserved for future use
usMode operation mode. Set to EV_ASYNC for asynchronous execution or to EV_SYNC for synchronous execution.

Termination Events

IPMEV_OPEN
indicates successful completion, that is, an IP channel was opened and the device handle is valid. This event does not return any data.
IPMEV_ERROR
indicates the function failed.

Cautions

Errors

If the function returns -1 to indicate failure, call ATDV_LASTERR( ) and ATDV_ERRMSGP( ) to return one of the following errors:

EINVAL
Invalid argument (system-level error)
ENOMEM
Memory allocation failure (system-level error)

Example

#include <stdio.h>
#include <srllib.h>
#include <ipmlib.h> 
typedef long int(*HDLR)(unsigned long);
void CheckEvent(); 
void main()
{
    char cDevName[10];
    int nDeviceHandle;
    // Register event handler function with srl
    sr_enbhdlr( EV_ANYDEV ,EV_ANYEVT ,(HDLR)CheckEvent);
    /*
    .
    .
    .
    . Create a Thread that waits on srl events, this
    . thread will execute the WorkerThread function
    .
    */
    /*
    Open IP channel ipmB1C1
    */
    sprintf(cDevName,"ipmB1C%d", 1);
        if((nDeviceHandle = ipm_Open(cDevName, NULL, EV_ASYNC)) == -1)
        {
            printf("ipm_Open failed for device name = %s\n", cDevName);
            /*
            .
            .
            Perform Error Processing
            .
            .
            */
        }
    /*
    .
    . continue Main Processing
    .
    */
} 
void CheckEvent()
{
    int nDeviceID = sr_getevtdev();
    int nEventType = sr_getevttype();
    switch(nEventType)
    {
    /*
    .
    .
    . Other events
    .
    .
        */
        /* Expected reply to ipm_Open */
    case IPMEV_OPEN:
        printf("Received IPMEV_OPEN for device = %s\n", ATDV_NAMEP(nDeviceID));
        break;
    default:
        printf("Received unknown event = %d for device = %s\n",
            nEventType, ATDV_NAMEP(nDeviceID));
        break;
    }
} 

See Also


PREV TOC HOME INDEX NEXT

Click here to contact Telecom Support Resources

Copyright 2002, Intel Corporation
All rights reserved
This page generated November, 2002