CPI Library Dev Ref Manual
CPI Library Dev Ref Manual
July 2009
64-0458-01
www.dialogic.com
Dialogic Corporation
Revision history
Revision
Release date
1.0
Notes
GJG
1.2
March 1999
GJG
1.3
November 2000
1.5
August 2001
1.6
November 2003
1.7
April 2004
1.8
June 2008
64-0458-01
July 2009
Table Of Contents
Chapter 1: Introduction .................................................................................7
Chapter 2: Overview of the CPI library ..........................................................9
Development environment............................................................................ 9
CPI library definition ...................................................................................10
Accessing the TX device driver using Windows................................................11
Accessing the TX device driver using UNIX .....................................................11
Chapter 3: Function reference .....................................................................13
Function summary......................................................................................13
Using the function reference ........................................................................15
cpia_chkey ................................................................................................16
cpia_get_data............................................................................................17
cpia_intr ...................................................................................................18
cpia_open .................................................................................................19
cpia_rxnotify .............................................................................................20
cpia_send .................................................................................................21
cpia_txnotify .............................................................................................22
cpi_check_bs .............................................................................................23
cpi_close...................................................................................................24
cpi_cptoh_l ...............................................................................................25
cpi_cptoh_s ...............................................................................................26
cpi_force_bs ..............................................................................................27
cpi_get_board............................................................................................28
cpi_get_data .............................................................................................29
cpi_get_dev_info........................................................................................30
cpi_get_error_str .......................................................................................31
cpi_get_last_error ......................................................................................32
cpi_get_resources ......................................................................................33
cpi_htocp_l ...............................................................................................34
cpi_htocp_s ...............................................................................................35
cpi_init .....................................................................................................36
cpi_nmi ....................................................................................................37
cpi_open ...................................................................................................38
cpi_read_control ........................................................................................39
cpi_read_dpr .............................................................................................40
cpi_send ...................................................................................................41
cpi_set_cpid ..............................................................................................42
cpi_show_stats ..........................................................................................43
cpi_stats ...................................................................................................44
cpi_wait_msg ............................................................................................45
cpi_wait_obj ..............................................................................................46
cpi_write_control........................................................................................47
cpi_write_dpr ............................................................................................48
Dialogic Corporation
Introduction
Current terminology
NMS SS7
Natural Access
Dialogic Corporation
Development environment
The TX host application development environment (shown in the following
illustration) consists of libraries that enable you to configure and control the protocol
engines loaded on the TX board. This manual describes the CPI library.
Host application
T1/E1
library
H.100/H.110
library
TX SWI
library
Loader
library
CPI library
TX board resources
Dialogic Corporation
Source CP
Destination
channel
Destination
CP
Length
Data
1 byte
1 byte
1 byte
1 byte
2 bytes
TX boards are numbered 1 through 16. The host is assigned the CP number of 0. The
length field indicates the length of the entire data packet, including the header.
Channels are numbered 0 through 255, and channel 0 is reserved.
A channel number is assigned to a task on the TX board by a prior arrangement,
similar to the ports concept used in TCP/UDP. To minimize conflicts, NMS
recommends the following channel usage:
Channel
Usage
0 through 31
Reserved
32 through 127
Reserved
10
PT_MGR
PT_OACDRV
PT_SWI
PT_CONSOLE
PT_LOADER
PT_DEBUG
PT_MVIP
PT_T1E1C
PT_T1E1S
PT_INF
PT_SS7MON
PT_ARP
PT_SS7MON2
PT_ISUP
PT_MTP
PT_TCAP
PT_IUP
PT_TXMON
PT_TUP
PT_SCCP
0x00
0x01
0x03
0x06
0x07
0x08
0x09
0x0A
0x0B
0x0C
0x0F
0x12
0x13
0x14
0x15
0x17
0x18
0x19
0x1D
0x1E
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
Dialogic Corporation
The txcpi.h include file provides all CPI library function prototypes and literal
definitions. Always use the structure packing compile option when compiling source
code that uses functions from this library.
Dialogic Corporation
11
For example, to wait on both input and packets from a TX board, use poll on a UNIX
system as follows:
.
struct pollfd fds[2];
.
.
cpi_init(0, &str);
mode = CPIM_PORT;
port = PORT((S16)board, (S16)chan);
if ((txhandle = cpi_open(port, mode, NULL)) < 0)
{
< Error handling code >
}
fd = cpi_wait_obj (txhandle);
for (;;)
{
fds[0].fd = 0;
/* fd for standard input */
fds[0].events = POLLIN;
fds[0].revents = 0;
fds[1].fd = fd;
/* TX fd */
fds[1].events = POLLIN;
fds[1].revents = 0;
if (poll(fds, 2, -1) < 0)
{
< Error handling code >
}
for (i = 0; i < 2; i++)
{
if (fds[i].revents & (POLLERR | POLLHUP | POLLNVAL))
{
< Error handling code >
}
if (fds[i].revents & POLLIN)
{
/* TX receive */
if (fds[i].fd == fd)
{
len = sizeof (CPIPKT);
if (ret = cpi_get_data(txhandle,&inbuf,&len))
{
< Error handling code >
}
.
.
< Code to process data >
.
.
}
/* Terminal input */
else if (fds[i].fd == 0)
{
}
}
} /* for i */
} /* for ever */
12
Dialogic Corporation
Function reference
Function summary
The CPI library provides synchronous and asynchronous interfaces to the TX board:
Interface
Description
Synchronous
Can allow packet loss and can introduce data overload conditions.
Does not include a flow control mechanism, causing dropped packets and
resource depletion during heavy packet traffic, whether from host to TX board or
from TX board to host.
Asynchronous
Does not stall the calling application because all responses from the driver are
handled as independent events. For certain operating systems, multiple-threaded
applications must use an asynchronous interface. For operating systems that do
not impose this restriction, an asynchronous interface is still recommended.
Includes flow control mechanisms to ensure that no packets are dropped and no
depletion conditions are introduced due to host traffic.
Not all CPI library functions can handle asynchronous I/O and synchronous I/O
functions. Mixed-mode (synchronous and asynchronous) I/O on the same handle is
not allowed. The following table summarizes the CPI functions and their modality. An
asterisk (*) indicates a user-supplied function.
Function
Synchronous
Asynchronous
cpia_chkey
No
Yes
cpia_get_data
No
Yes
cpia_intr
No
Yes
cpia_open
No
Yes
cpia_rxnotify*
No
Yes
cpia_send
No
Yes
cpia_txnotify*
No
Yes
cpi_check_bs
Yes
Yes
cpi_close
Yes
Yes
cpi_cptoh_l
Yes
Yes
Dialogic Corporation
13
Function reference
Function
Synchronous
Asynchronous
cpi_cptoh_s
Yes
Yes
cpi_force_bs
Yes
Yes
cpi_get_board
Yes
Yes
cpi_get_data
Yes
No
cpi_get_dev_info
Yes
Yes
cpi_get_error_str
Yes
Yes
cpi_get_last_error
Yes
Yes
cpi_get_resources
Yes
Yes
cpi_htocp_l
Yes
Yes
cpi_htocp_s
Yes
Yes
cpi_init
Yes
Yes
cpi_nmi
Yes
Yes
cpi_open
Yes
No
cpi_read_control
Yes
Yes
cpi_read_dpr
Yes
Yes
cpi_send
Yes
No
cpi_set_cpid
Yes
Yes
cpi_show_stats
Yes
Yes
cpi_stats
Yes
Yes
cpi_wait_msg
Yes
No
cpi_wait_obj
Yes
Yes
cpi_write_control
Yes
Yes
cpi_write_dpr
Yes
Yes
14
Dialogic Corporation
Function reference
The prototype is shown followed by a listing of the function arguments. Dialogic data
types include:
U8 (8-bit unsigned)
S8 (8-bit signed)
The return value for a function is either CPI_SUCCESS or an error code. For asynchronous
functions, a return value of CPI_SUCCESS (zero) indicates that the function was initiated.
Subsequent events indicate the status of the operation.
Dialogic Corporation
15
Function reference
cpia_chkey
Returns the user-provided key associated with the specified handle.
Prototype
#include txcpi.h
void *cpia_chkey ( TX_HANDLE handle)
Argument
Description
handle
Return values
Return value
Description
NULL
Details
One of the parameters provided to cpia_open is a user-controlled key named
chkey. Applications can use cpia_chkey to get the key associated with the open.
For asynchronous receive and transmit complete notifications, it is not necessary to
call cpia_chkey since the users key is provided as a parameter to cpia_rxnotify
and cpia_txnotify.
16
Dialogic Corporation
Function reference
cpia_get_data
Obtains a packet of data from the specified channel.
Prototype
#include txcpi.h
S16 cpia_get_data ( TX_HANDLE handle, CPIPKT *buffer, S16*len)
Argument
Description
handle
buffer
len
Pointer to the size of the buffer on input and the length of the received packet on output.
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
CPI_INVALID_MODE
CPI_TRUNCATED
Details
cpia_get_data obtains a packet of data from the channel. On entry, the passed
length parameter is checked. If the length is less than the received message, then
len bytes of the message are copied to buffer and CPI_TRUNCATED is returned. The
length of the received packet is placed in len.
Call cpia_get_data from within cpia_rxnotify. Calling cpia_get_data from
outside cpia_rxnotify can result in communication errors.
Dialogic Corporation
17
Function reference
cpia_intr
Drains the asynchronous transmit acknowledgements and checks for any waiting
received packets.
Prototype
#include txcpi.h
CPI_ERR_TYPE cpia_intr ( TX_HANDLE handle)
Argument
Description
handle
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
CPI_INVALID_MODE
Details
Call cpia_intr when an I/O event is detected. Detecting such events is operating
system-specific (WaitForMultipleObjects for Windows or poll for UNIX).
Note: Asynchronous transmit complete messages are processed before received
messages.
18
Dialogic Corporation
Function reference
cpia_open
Opens a channel for asynchronous I/O on the host.
Prototype
#include txcpi.h
TX_HANDLE cpia_open ( void *chkey, U16 board, U16 channel, void
((*rxnotify)(TX_HANDLE handle, void *chkey)), void ((*txnotify)(TX_HANDLE
handle, void*chkey, CPIPKT *buffer, void*user_tx_key, CPI_ERR_TYPE,
ccode)))
Argument
Description
chkey
board
channel
rxnotify
txnotify
Return values
Return value
Description
CPI_INVALID_HANDLE
Details
Use cpia_open to open a channel for aynchronous I/O. Use cpi_open to open a
channel for synchronous I/O. Mixed mode I/O on a given channel is not possible,
either with a single TX_HANDLE or multiple TX_HANDLEs. If successful, TX_HANDLE
is returned.
See also
cpia_intr, cpia_rxnotify, cpia_txnotify
Dialogic Corporation
19
Function reference
cpia_rxnotify
Notifies upper layers of messages to be received.
Prototype
void cpia_rxnotify ( TX_HANDLE handle, void *chkey)
Argument
Description
handle
chkey
Details
Provide cpia_rxnotify as a parameter to cpia_open. The CPI library calls this
function as a result of a call to cpia_intr when receive packets are pending for the
given channel.
cpia_rxnotify calls cpia_get_data to receive the incoming message.
20
Dialogic Corporation
Function reference
cpia_send
Asynchronously sends a packet of data over the specified channel.
Prototype
#include txcpi.h
S16 cpia_send ( TX_HANDLE handle, CPIPKT *buffer, void *user_tx_key)
Argument
Description
handle
buffer
user_tx_key
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
CPI_INVALID_MODE
CPI_QUEUE_FULL
Details
The value returned by cpia_send reflects the result of enqueing the packet for
transmission. The ultimate disposition of the packet is passed back as a parameter to
cpia_txnotify.
Once sent, a packet cannot be unsent (that is, there is no cpia_cancel).
Final I/O result notification is handled by cpia_intr and cpia_txnotify callback.
The CPIPKT structure pointed to by the buffer parameter cannot be freed, re-used,
or re-allocated until the final disposition of the packet is determined with cpia_intr
and cpia_txnotify. Failure to adhere to this requirement causes unreliable and
unpredictable results.
See also
cpia_open
Dialogic Corporation
21
Function reference
cpia_txnotify
Processes an asynchronous transmit completion message received from the TX
board.
Prototype
void cpia_txnotify ( TX_HANDLE handle, void *chkey, CPIPKT *buffer, void
*user_tx_key, CPI_ERR_TYPE ccode)
Argument
Description
handle
chkey
Pointer to the channel key provided when the handle was opened.
buffer
user_tx_key
ccode
Details
Provide cpia_txnotify as a parameter to cpia_open. The CPI library calls this
function as a result of a call to cpia_intr when previously issued transmit requests
(with cpia_send) complete for the given channel. When cpia_txnotify is called, or
any time thereafter, the application can free the corresponding CPIPKT passed in on
cpia_send. Failure to adhere to this rule results in communications errors.
22
Dialogic Corporation
Function reference
cpi_check_bs
Determines whether the TX board specified by handle is in the boot state.
Prototype
#include txcpi.h
S16 cpi_check_bs ( TX_HANDLE handle, CPIBS *bsp)
Argument
Description
handle
bsp
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
The bsp.state is loaded with the boot state (low byte) and the CSR (high byte). The
boot state can be one of the following values:
State
Description
BS_BOOT
BS_READY
BS_INIT
KERNEL is initializing.
BS_DOWN
BS_BERR
BS_LOADING
BS_PREBOOTING
BS_WAIT_KERNEL
Dialogic Corporation
23
Function reference
cpi_close
Closes the channel associated with the specified handle.
Prototype
#include txcpi.h
S16 cpi_close ( TX_HANDLE handle)
Argument
Description
handle
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
Applications that open CPI channels must close all channels before the application
terminates. Failing to close a channel can leave resources in an indeterminate state.
24
Dialogic Corporation
Function reference
cpi_cptoh_l
Converts the src value from the TX board native format to the host format.
Prototype
#include txcpi.h
U32 cpi_cptoh_l ( U32 src)
Argument
Description
src
Details
The value of src is converted to the host format and placed in the return value.
Note: This function performs no operation on a host system that uses the same
native format as the TX board (TX boards use the Motorola native format). However,
for code portability, NMS recommends that you always use the conversion functions,
even with host systems that are already in Motorola format.
Dialogic Corporation
25
Function reference
cpi_cptoh_s
Converts the src value from the TX board native format to the host format.
Prototype
#include txcpi.h
U16 cpi_cptoh_s ( U16 src)
Argument
Description
src
Details
The value of src is converted to the host format and placed in the return value.
Note: This function performs no operation on a host system that uses the same
native format as the TX board (TX boards use the Motorola native format). However,
for code portability, NMS recommends that you always use the conversion functions,
even with host systems that are already in Motorola format.
26
Dialogic Corporation
Function reference
cpi_force_bs
Boots the TX device indicated by the specified handle. The board performs a
complete reset, including loading the operating system kernel from on-board flash
memory.
Prototype
#include txcpi.h
S16 cpi_force_bs ( TX_HANDLE handle)
Argument
Description
handle
TX handle number.
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
cpi_force_bs triggers the board to reboot from the TX operating system that is
stored in on-board flash memory. All current processing on the board is aborted.
When the board reset completes, cpi_check_bs returns a state of BS_READY.
Dialogic Corporation
27
Function reference
cpi_get_board
Returns the board number and channel number associated with the specified
handle.
Prototype
#include txcpi.h
S16 cpi_get_board ( TX_HANDLE handle, U8 *board, U8 *chan)
Argument
Description
handle
TX handle number.
board
chan
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
28
Dialogic Corporation
Function reference
cpi_get_data
Recovers received packets from the channel associated with the specified handle.
Prototype
#include txcpi.h
S16 cpi_get_data ( TX_HANDLE handle, CPIPKT *buffer, S16 *len)
Argument
Description
handle
buffer
len
Pointer to the length of the buffer on input and the length of the received packet on
output.
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
CPI_TRUNCATED
Details
Specify the length of the buffer in the len parameter in the call to cpi_get_data. If
there is no packet to receive, cpi_get_data returns CPI_SUCCESS and len is set to
zero. If there is a packet, cpi_get_data returns CPI_SUCCESS, the length is placed
in len, and the packet is copied into the specified buffer.
Dialogic Corporation
29
Function reference
cpi_get_dev_info
Retrieves device information for available TX boards.
Prototype
#include txcpi.h
CPI_ERR_TYPE cpi_get_dev_info ( CPI_DEV_INFO *devinfo, U16 *numdevs)
Argument
Description
devinfo
numdevs
Pointer to the number of entries in the devinfo array on input and the number of entries
populated on output (number of detected TX devices).
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
Use cpi_get_dev_info to determine the PCI bus and slot for each installed TX board
when assigning CP numbers to the detected boards.
See also
cpi_set_cpid
30
Dialogic Corporation
Function reference
cpi_get_error_str
Returns an ASCII string associated with the errnum passed to the function.
Prototype
#include txcpi.h
S8 *cpi_get_error_str ( CPI_ERR_TYPE errnum)
Argument
Description
errnum
Return values
Return value
Description
NULL
Details
When a CPI library function returns CPI_ERROR, use cpi_get_last_error to
determine the error code. Then use cpi_get_error_str to convert this errnum into
an ASCII string describing the error.
Dialogic Corporation
31
Function reference
cpi_get_last_error
Returns the error code for the most recent error that occurred in the library.
Prototype
#include txcpi.h
CPI_ERR_TYPE cpi_get_last_error()
Details
When a CPI library function returns CPI_ERROR, use cpi_get_last_error to
determine the error code. Then use cpi_get_error_str to convert this errnum into
an ASCII string describing the error.
32
Dialogic Corporation
Function reference
cpi_get_resources
Identifies the available TX boards.
Prototype
#include txcpi.h
S16 cpi_get_resources ( S16 max_cps, S32 *cps[])
Argument
Description
max_cps
cps
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
If a CP of the corresponding index does not exist, each element of the array cps is
filled with 0. If a CP for that index does exist, the array is filled with the TX board
types. The parameter max_cps indicates the number of CPs to check. The cps array
should have max_cps + 1 elements since the array is filled according to board
number. There is no board number 0 and this element is not used by this routine.
Dialogic Corporation
33
Function reference
cpi_htocp_l
Converts the src value from the host format to the TX board native format.
Prototype
#include txcpi.h
U32 cpi_htocp_l ( U32 src)
Argument
Description
src
Details
The value of src is converted to the TX board format and placed in the return value.
Note: This function performs no operation on a host system that uses the same
native format as the TX board (TX boards use the Motorola native format). However,
for code portability, NMS recommends that you always use the conversion functions,
even with host systems that are already in Motorola format.
34
Dialogic Corporation
Function reference
cpi_htocp_s
Converts the src value from the host format to the TX board native format.
Prototype
#include txcpi.h
U16 cpi_htocp_s ( U16 src)
Argument
Description
src
Details
The value of src is converted to the TX board format and placed in the return value.
Note: This function performs no operation on a host system that uses the same
native format as the TX board (TX boards use the Motorola native format). However,
for code portability, NMS recommends that you always use the conversion functions,
even with host systems that are already in Motorola format.
Dialogic Corporation
35
Function reference
cpi_init
Initializes the CPI library.
Prototype
#include txcpi.h
S16 cpi_init ( S16 dummy, S8 *idstring)
Argument
Description
dummy
idstring
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
Call cpi_init once per application.
36
Dialogic Corporation
Function reference
cpi_nmi
Controls the non-maskable interrupt (NMI) state on the TX board.
Prototype
#include txcpi.h
S16 cpi_nmi ( TX_HANDLE handle, U32 state)
Argument
Description
handle
TX handle number.
state
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
Use the NMI to halt all standard processing on the TX board and to place the board
into a state where diagnostic information can be read from the board. An application
should assert NMI first, and then deassert NMI to cause the TX board to begin
executing in this diagnostic state.
Dialogic Corporation
37
Function reference
cpi_open
Opens a channel for synchronous I/O on the host.
Note: NMS recommends that you use cpia_open to open all channels to TX boards.
Prototype
#include txcpi.h
TX_HANDLE cpi_open ( U16 port, S16 mode, S16 *rcvr (S16 handle, S16 len))
Argument
Description
port
Combination of the TX board number and the channel number. Use the PORT macro to
combine a board number and channel number into a port.
mode
rcvr
Return values
Return value
Description
CPI_INVALID_HANDLE
Details
TX_HANDLE is operating-system specific. Since this return value is passed back only
to other CPI calls, the type is not important to the application. When the handle is
required for a wait call (WaitForSingleObject in Windows, poll in UNIX), use
cpi_wait_obj (handle) to access the proper element for each operating system, as
follows:
WaitForSingleObject (cpi_wait_obj (handle), 0);
For multiple-threaded applications, the thread that opens a channel should be the
same thread that processes all I/O for that channel. Otherwise, unpredictable
behavior can result.
See also
cpi_get_data, cpi_wait_msg
38
Dialogic Corporation
Function reference
cpi_read_control
Reads a set of control registers from a TX board.
Prototype
#include txcpi.h
S16 cpi_read_control ( TX_HANDLE handle, U16 basereg, U16 numreg, U32
*regarray, U16 *actcnt)
Argument
Description
handle
TX handle number.
basereg
numreg
regarray
actcnt
Pointer to the location where the actual number of registers read are stored.
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
In addition to the dual-ported RAM shared between the host processor and the TX
board, a set of registers is used for communication control. Certain low-level
diagnostics on the TX board use the control registers to pass status information to
the host.
All control register access should be restricted to diagnostic applications. Do not use
this function for normal data transfer situations.
See also
cpi_write_control
Dialogic Corporation
39
Function reference
cpi_read_dpr
Reads from the dual-ported RAM of the TX board specified by handle.
Prototype
#include txcpi.h
S16 cpi_read_dpr ( TX_HANDLE handle, S8 *buffer, U32 off, S16 len)
Argument
Description
handle
TX handle number.
buffer
off
len
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
The read starts at off in the DPR and reads len number of bytes.
All dual-ported RAM is used for messaging and therefore should not be read directly.
Do not use this function for normal data transfer situations.
40
Dialogic Corporation
Function reference
cpi_send
Synchronously sends a packet of data over the channel indicated by the specified
handle.
Prototype
#include txcpi.h
S16 cpi_send ( TX_HANDLE handle, CPIPKT *buffer)
Argument
Description
handle
buffer
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
buffer should point to a properly formatted CP packet. The application sets the
destination board and channel number in the header portion of the buffer. The
function does not return until the board acknowledges the sent packet.
Dialogic Corporation
41
Function reference
cpi_set_cpid
Assigns a CP number to the TX board at the given PCI bus and slot number.
Prototype
#include txcpi.h
S16 cpi_set_cpid ( S16 type, U32 param1, U32 param2, U32 cpId)
Argument
Description
type
param1
Bus number.
param2
Slot number.
cpId
TX board number to associate with the board at the given bus and slot.
Return values
Return value
Description
CPI_SUCCESS
CP number successfully assigned to the given PCI bus and slot number.
CPI_ERROR
Details
cpi_set_cpid assigns a board number (CP number) to the TX board at the indicated
PCI bus and slot number. After a TX board is assigned a CP number, the board can
be accessed by other CPI functions.
42
Dialogic Corporation
Function reference
cpi_show_stats
Displays common statistics to stdout using a series of printf calls.
Prototype
#include txcpi.h
S16 cpi_show_stats ( TX_STATS_COMMON *stats)
Argument
Description
stats
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
cpi_show_stats enables an application to display all common statistics in a
standardized format. All statistics definitions can be found in the txstats.h include
file.
See also
cpi_stats
Dialogic Corporation
43
Function reference
cpi_stats
Obtains per-channel statistics synchronously.
Prototype
#include txcpi.h
CPI_ERR_TYPE cpi_stats ( TX_HANDLE handle, U32 options,
TX_STATS_COMMON *stats)
Argument
Description
handle
options
Statistics collection operation. Refer to the Details section for valid values.
stats
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
cpi_stats enables an application to collect the per-channel statistics maintained by
the CPI library. All statistics definitions can be found in the txstats.h include file.
The CPI layer maintains a set of common statistics and optionally a set of layerspecific statistics. The common statistics are defined by the TX_STATS_COMMON
structure. Use the TX_STATS_NAME operation to get ASCII names of the common
statistics.
Use the options parameter to describe the type of statistics to return. The following
table lists the valid values for the options parameter:
#include txstats.h
Use this value...
To return...
TX_STATS_GET
Current statistics.
TX_STATS_ZERO
TX_STATS_NAME
TX_STATS_NAME_LAYER
TX_STATS_DESC
TX_STATS_DESC_LAYER
See also
cpi_show_stats
44
Dialogic Corporation
Function reference
cpi_wait_msg
Waits a specified amount of time (in milliseconds) and returns a packet if one is
received.
Prototype
#include txcpi.h
S16 cpi_wait_msg ( TX_HANDLE handle, CPIPKT *buffer, S16*len, S32
millisecs)
Argument
Description
handle
buffer
len
Pointer to the length of the buffer on input and the length of the received packet on
output.
millisecs
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
CPI_TIMEOUT
No packet to receive.
CPI_TRUNCATED
Details
cpi_wait_msg recovers received packets from the channel associated with the
specified handle. Upon entry, len contains the size of the buffer. If there is a packet
to receive, the length is placed in len and the packet is placed in the specified buffer.
Dialogic Corporation
45
Function reference
cpi_wait_obj
Returns the wait object for the channel associated with the specified handle.
Prototype
#include txcpi.h
CPI_WAIT_TYPE cpi_wait_obj ( TX_HANDLE handle)
Argument
Description
handle
Return values
Return value
Description
CPI_INVALID_WAIT_HANDLE
Invalid TX handle.
Details
Use the wait object when calling the host operating system's native wait routine,
such as WaitForSingleObject in Windows or poll for UNIX.
46
Dialogic Corporation
Function reference
cpi_write_control
Writes a set of control registers to a TX board.
Prototype
#include txcpi.h
S16 cpi_write_control ( TX_HANDLE handle, U16 basereg, U16 numreg, U32
*regarray, U16 *actcnt)
Argument
Description
handle
TX handle number.
basereg
numreg
regarray
actcnt
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
In addition to the dual-ported RAM shared between the host processor and the TX
board, a set of registers is used for communication control. Certain low-level
diagnostics on the TX board use the control registers to control low-level, on-board
diagnostics.
All control register access should be restricted to diagnostic applications. Do not use
this function for normal data transfer situations.
See also
cpi_read_control
Dialogic Corporation
47
Function reference
cpi_write_dpr
Writes to the dual-ported RAM of the CP indicated by the specified handle.
Prototype
#include txcpi.h
S16 cpi_write_dpr ( TX_HANDLE handle, S8 *buffer, U32 off, S16 len)
Argument
Description
handle
TX handle number.
buffer
off
len
Return values
Return value
Description
CPI_SUCCESS
CPI_ERROR
Details
cpi_write_dpr writes from buffer for len number of bytes starting at off in the
DPR.
All dual-ported RAM is used for messaging and should not be written directly. Do not
use this function for normal data transfer situations.
48
Dialogic Corporation
Index
A
cpi_set_cpid 42
asynchronous functions 13
cpi_show_stats 43
cpi_stats 44
cpi_wait_msg 45
cpi_wait_obj 46
cpi_write_control 47
cpi_write_dpr 48
cpia_chkey 16
channel usage 10
cpia_get_data 17
close channel 24
cpia_intr 18
cpia_open 19
cpia_rxnotify 20
cpia_send 21
CP number 28, 42
cpia_txnotify 22
cpi_check_bs 23
cpi_close 24
de-multiplexing 10
cpi_cptoh_l 25
development environment 9
cpi_cptoh_s 26
device information 30
cpi_force_bs 27
DPR 40, 48
cpi_get_board 28
dpriface.h 10
cpi_get_data 29
cpi_get_dev_info 30
cpi_get_error_str 31
errors 31, 32
cpi_get_last_error 32
cpi_get_resources 33
flow control 11
cpi_htocp_l 34
function summary 13
cpi_htocp_s 35
cpi_init 36
cpi_nmi 37
cpi_open 38
cpi_read_control 39
cpi_read_dpr 40
cpi_send 41
logical port 10
Dialogic Corporation
49
Index
multiplexing 10
NMI state 37
statistics 43, 44
synchronous functions 13
TX_STATS_COMMON structure 44
TX_STATS_NAME structure 44
txcpi.h 10
txstats.h 44
port usage 10
UNIX 11
wait object 46
WaitForMultipleObjects 11, 18
resources 33
WaitForSingleObject 11, 46
Windows 11
50
Dialogic Corporation