ipm_Open( )
Termination Events | Cautions | Errors | Example | See Also
Name: int ipm_Open(*szDevName, *pOpenInfo, usMode) Inputs:
Returns: Includes: Category: Mode: Platform: 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( ).
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
- Two different applications (running in separate processes) cannot use the same IP media device (ipmBxCx). In other words, multiple calls to ipm_Open( ) on the same IP media device are not allowed.
- The pOpenInfo pointer is reserved for future use and must be set to NULL.
- If this function is called asynchronously and IPMEV_ERROR is received, the application must call ipm_Close( ) using the handle returned by ipm_Open( ).
- When using Intel® NetStructure DM/IP Series boards, you must call ipm_Open( ) in synchronous mode.
- When using Intel® NetStructure Host Media Processing (HMP) software, you must call ipm_Open( ) in synchronous mode.
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
Click here to contact Telecom Support Resources
Copyright 2002, Intel Corporation