
Description | Cautions | Example | Errors | See Also
Name: |
int dt_rundiag(devh,tmo,diagbufp) | |
Inputs: |
int devh |
|
int tmo |
| |
char *diagbufp |
| |
Returns: |
0 on success | |
Includes: |
srllib.h | |
Category: |
Diagnostic | |
Mode: |
synchronous/asynchronous | |
The dt_rundiag( ) function runs diagnostics on the Network firmware. The function can operate in synchronous (blocking) or asynchronous (non-blocking) mode.
Please note the following guidelines when using this function:
Parameter |
Description |
devh: |
Specifies the valid Digital Network Interface board device handle returned by a call to dt_open( ) |
tmo: |
When operating the function in synchronous mode, specifies the length of time in seconds the function will block while waiting for a response from the device |
diagbufp: |
Pointer to a one-byte data buffer to which the diagnostic code will be returned when the function is operating in synchronous mode |
Synchronous Mode
To operate the function in synchronous (blocking) mode, specify in tmo the length of time in seconds that the function will block. This causes the application to await a return from the function before performing any other processing. A suggested setting for tmo is 5.
Asynchronous Mode
To operate the function in asynchronous (non-blocking) mode, set tmo to 0. This allows the application to continue processing while awaiting a completion event from the device.
If event handling is set up properly for your application, DTEV_RETDIAG is returned by the SRL sr_getevttype( ) function when the diagnostics are successfully completed.
To use this function in asynchronous mode, you must use the SRL sr_enbhdlr( ) function to enable trapping of the event and create an event handler to process the completion event returned by the device. See Appendix A - Standard Runtime Library for more information on Digital Network Interface event management.
Diagnostic Return Codes
The diagnostic codes listed below provide results of the diagnostics run on the Digital Network Interface firmware. In synchronous mode, the diagnostic codes are returned to the one-byte buffer pointed to by diagbufp. In asynchronous mode, the codes are returned by the SRL sr_getevtdatap( ) function.
#include <windows.h> /* For Windows applications only */
#include <srllib.h>
#include <dtilib.h>
#include <errno.h>
main()
{
int devh; /* Board device handle */
int retval; /* Return value from function call */
char diagbufp; /* Diagnostic buffer */
/*
* Open board 1 device
*/
if ( ( devh = dt_open( "dtiB1", 0 ) ) == -1 ) {
printf( "Cannot open board dtiB1. errno = %d", errno );
exit( 1 );
}
/*
* Run diagnostics on the board with a 5 second timeout.
*/
if ( ( retval = dt_rundiag( devh, 5, &diagbufp ) ) == -1 ) {
printf("Error activating diag tests: error message = %s\n",
ATDV_ERRMSGP( devh ) );
}
if ( diagbufp ! = DTDE_NOERR )
printf( "Diagnostic buffer value = %d\n", diagbufp );
exit( 1 );
}
.
.
.
}
If the function returns -1, use the SRL Standard Attribute function ATDV_LASTERR( ) to obtain the error code or use ATDV_ERRMSGP( ) to obtain a descriptive error message. See Appendix A - Standard Runtime Library for more information on SRL functions. The error codes returned by ATDV_LASTERR( ) are:
Error defines can be found in the file dtilib.h.
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation