Previous PageTable Of Contents../index.htmlIndexNext Page



4. Application Guidelines

This chapter contains suggestions to guide programmers in designing and coding a Dialogic DCB/SC application for Windows.

Top Of Page4.1. Writing a Simple Application

This section provides DCB/SC general and task-specific programming guidelines:

NOTE:
These guidelines are not a comprehensive guide to developing or debugging DCB/SC applications. The examples following each function description in Chapter 3 illustrate proper use of the DCB/SC functions.

The following general guidelines for writing Dialogic applications are explained in this section:

Dialogic does not guarantee the numerical values of defines will remain the same as new versions of a software package are released. In general, do not use a numerical value in your application when an equivalent symbolic define is available. Symbolic defines are found in the dtilib.h, msilib.h, and dcblib.h files.

Various header files must be included in your application to test for error conditions, to use library functions from other Dialogic products, or to perform event-management and standard-attribute functions. An example is shown below. See Chapter 2 for details.

NOTE:
To avoid redundancy in the remaining programming examples in this chapter, #include statements will not be shown.

Most Network and DCB/SC Windows library functions return a value of -1 if they fail (extended attribute functions return AT_FAILURE or AT_FAILUREP if they fail). Any call to a library function should therefore check for a return value indicating an error. This can be done using a format similar to the following:

Using this technique ensures that all errors resulting from a library call will be trapped and handled properly by the application. In many cases, you can check for a return value of other than zero (0), as shown in the example below. However, this should only be used where a non-zero value is returned when the function fails. For details, see Chapter 2 and Chapter 3.

NOTE:
Calls to dcb_open( ) return either -1 or a non-zero device handle. Therefore, when issuing the dcb_open( ) function, check for a return of -1. The specific error can be found in the global variable errno, contained in errno.h.

As a first step, a DCB/SC application must intialize parameters.

Use dcb_setbrdparm( ) to set active talker and volume control digits. Specific setting choices include:

Active Talker Feature
(MSG_ACTID)

Active Talker feature can be enabled or disabled by setting to ACTID_ON or ACTID_OFF.

Volume Control Digits
(MSG_VOLDIG)

Defines the volume control status and volume up/down/reset digits.

If the resource assignment table updates are desired by the application, enable event generation using dcb_evtstatus( ).

When your process completes, devices should be shut down in an orderly fashion. Tasks that are performed to terminate an application generally include:

NOTE:
SRL Event Management functions (such as sr_dishdlr( ), which disables an event handler) must be called before closing the device that is sending the handler event notifications (see Appendix A for SRL details).

To compile and link your application, follow the instructions for your version of the Windows Compiler.

If using Microsoft Visual C++, link with the following libraries when using the DCB/SC board:

By default, the files are found in <install drive%>:<install directory>\dialogic\lib. Depending on your application, you may need to link with other libraries. Refer to the appropriate documentation for other Dialogic products.

If using Borland C++, you must include the cross-compatibility library files in your file set. The files are found in <install drive%>:<install directory>\dialogic\lib. You may also use the x-compatibility files when using Microsoft Visual C++.

If you abort a DCB/SC Windows application by pressing the interrupt key, the Windows system will terminate the current process but may leave devices in an unknown state. As a result, you may encounter errors the next time the application runs.

To avoid errors of this type, your application should include an event handler that traps the interrupt key and performs the actions listed in Section 4.1.3, Terminating.


Previous PageTable Of ContentsTop Of PageIndexNext Page

Click here to contact Dialogic Customer Engineering

Copyright 2000, Dialogic Corporation
All rights reserved
This page generated January, 2002