In this example, we will:
To route these channels using SCbus convenience functions, perform the following:
To disconnect digital channel 12 from fax channel 2, disconnect the listen channel of each device from the SCbus by issuing nr_scunroute( ) calls. When the functions return, digital channel 12 and fax channel 2 will be disconnected from the SCbus.
To connect voice channel 14 on the D/240SC-T1 board to digital channel 12, perform the following:
Figure 7. Fax Sharing Example

6.1.1. Windows Sample Code for SCbus Convenience Functions#include <windows.h>
#include <errno.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <dtilib.h>
#include <faxlib.h>
/*
* For nr_ function error printing, DTI and fax functionality, make sure
* PRINTON, DTISC and FAXSC are defined when compiling the sctools.c file.
*/
#include "sctools.h"
main()
{
int dtih, /* T-1 time slot handle */
faxh, /* Fax channel handle */
chdev; /* Voice channel handle */
/* Open T-1 time slot 12 on the first D/240SC-T1. */
if ((dtih = dt_open("dtiB1T12", 0)) == -1) {
printf("Cannot open T-1 time slot dtiB1T12. errno = %d", errno);
exit(1);
}
/* Open fax channel 2 on board 5 (fax channel 2 on the VFX/40ESC). */
if ((faxh = fx_open("dxxxB5C2", 0)) == -1) {
printf("Cannot open fax channel dxxxB5C2. errno = %d", errno);
exit(1);
}
/* Open voice channel 2 on board 9 (voice channel 14 on the first D/240SC-T1). */
if ((chdev = dx_open("dxxxB9C2", NULL)) == -1) {
printf("Cannot open voice channel dxxxB9C2. errno = %d", errno);
exit(1);
}
.
. Continue processing.
.
/***** SCbus routing example. *****/
/*
* Make a full duplex connection between T-1 time slot 12
* and fax channel 2.
*/
if (nr_scroute(dtih, SC_DTI, faxh, SC_FAX, SC_FULLDUP) == -1) {
printf("Could not route the T-1 time slot to the fax channel");
exit(1);
}
.
. Process fax call.
.
/***** Disconnect fax channel. ******/
/*
* Break the full duplex connection between T-1 time slot 12
* and fax channel 2.
*/
if (nr_scunroute(dtih, SC_DTI, faxh, SC_FAX, SC_FULLDUP) == -1) {
printf("Could not disconnect the T-1 time slot from the fax channel");
exit(1);
}
/***** Re-connect T-1 time slot 12 for voice processing *****/
/***** using voice channel 14. *****/
/*
* Make a full duplex connection between T-1 time slot 12
* and voice channel 14.
*/
if (nr_scroute(dtih, SC_DTI, chdev, SC_VOX, SC_FULLDUP) == -1) {
printf("Could not route the T-1 time slot to the voice channel");
exit(1);
}
.
. Continue processing.
.
}
6.1.2. Linux Sample Code for SCbus Convenience Functions#include <srllib.h>
#include <dxxxlib.h>
#include <dtilib.h>
#include <faxlib.h>
#include <errno.h>
/*
* For nr_ function error printing, DTI and fax functionality, make sure
* PRINTON, DTISC and FAXSC are defined when compiling the sctools.c file.
*/
#include "sctools.h"
main()
{
int dtih, /* T-1 time slot handle */
faxh, /* Fax channel handle */
chdev; /* Voice channel handle */
/* Open T-1 time slot 12 on the first D/240SC-T1. */
if ((dtih = dt_open("dtiB1T12", 0)) == -1) {
printf("Cannot open T-1 time slot dtiB1T12. errno = %d", errno);
exit(1);
}
/* Open fax channel 2 on board 5 (fax channel 2 on the VFX/40ESC). */
if ((faxh = fx_open("dxxxB5C2", 0)) == -1) {
printf("Cannot open fax channel dxxxB5C2. errno = %d", errno);
exit(1);
}
/* Open voice channel 2 on board 9 (voice channel 14 on the first D/240SC-T1). */
if ((chdev = dx_open("dxxxB9C2", NULL)) == -1) {
printf("Cannot open voice channel dxxxB9C2. errno = %d", errno);
exit(1);
}
.
. Continue processing.
.
/***** SCbus routing example. *****/
/*
* Make a full duplex connection between T-1 time slot 12
* and fax channel 2.
*/
if (nr_scroute(dtih, SC_DTI, faxh, SC_FAX, SC_FULLDUP) == -1) {
printf("Could not route the T-1 time slot to the fax channel");
exit(1);
}
.
. Process fax call.
.
/***** Disconnect fax channel. ******/
/*
* Break the full duplex connection between T-1 time slot 12
* and fax channel 2.
*/
if (nr_scunroute(dtih, SC_DTI, faxh, SC_FAX, SC_FULLDUP) == -1) {
printf("Could not disconnect the T-1 time slot from the fax channel");
exit(1);
}
/***** Re-connect T-1 time slot 12 for voice processing *****/
/***** using voice channel 14. *****/
/*
* Make a full duplex connection between T-1 time slot 12
* and voice channel 14.
*/
if (nr_scroute(dtih, SC_DTI, chdev, SC_VOX, SC_FULLDUP) == -1) {
printf("Could not route the T-1 time slot to the voice channel");
exit(1);
}
.
. Continue processing.
.
}
6.1.3. MS-DOS Sample Code for SCbus Convenience Functions#include <stdlib.h>
#include <stdio.h>
#include "d40.h"
#include "dti.h"
#include "fax.h"
#include "d40lib.h"
#include "dtilib.h"
#include "dtierr.h"
#include "faxlib.h"
#include "vfcns.h"
/*
* In order for the nr_ functions to have DTI and fax functionality,
* DTISC and FAXSC must be defined when compiling the sctools.c file.
*/
#include "sctools.h"
int main()
{
int dti_bd = 1, /* D/240SC-T1 network board device handle. */
dti_ts = 12, /* T-1 time slot number. */
fax_ch = 2, /* Fax channel. */
chdev = 14, /* Voice channel. */
rcode; /* To hold function error return codes. */
unsigned int sc_IRQ = 10, /* SCbus board interrupt (from DIALOGIC.CFG) */
num_chans, /* Location for number of voice channels */
/* returned by startsys(). */
num_dti_brd, /* Location for number of DTI boards */
/* returned by startdti(). */
num_dti_ts, /* Location for number of DTI time slots */
/* returned by startdti(). */
num_fax_brd, /* Location for number of fax boards */
/* returned by fx_startsys(). */
num_fax_chan; /* Location for number of fax channels */
/* returned by fx_startsys(). */
/***** Initialize system. ******/
/* Make sure the voice driver is loaded. */
if (getvctr() == 0) {
printf("Voice driver is not loaded.");
exit(1);
}
/* Make sure the fax driver is loaded. */
if (fx_isdrvact() == 0) {
printf("Fax driver is not loaded.");
exit(1);
}
/* Make sure the fax driver is stopped before starting. */
fx_stopsys();
/* Make sure the DTI driver is stopped before starting. */
stopdti();
/* Make sure the voice driver is stopped before starting. */
stopsys();
/* Start the voice driver. */
if ((rcode = startsys(sc_IRQ, SM_EVENT, 0, 0, &num_chans)) != E_SUCC) {
printf("Could not start voice driver: Error message = %s", d4xerr(rcode));
exit(1);
}
/* Start the DTI driver. */
if ((rcode = startdti(&num_dti_brd, &num_dti_ts)) != E_DTSUCC) {
printf("Could not start DTI driver: Error = %d", rcode);
exit(1);
}
/* Start the fax driver. */
if ((rcode = fx_startsys(&num_fax_brd, &num_fax_chan)) != EFX_SUCC) {
printf("Could not start fax driver: Error message = %s", fx_faxerr(rcode));
exit(1);
}
.
. Continue processing.
.
/***** SCbus routing example. ******/
/*
* Make a full duplex connection between T-1 time slot 12
* and fax channel 2.
*/
if ((rcode = nr_scroute(DT_MKTSLOT(dti_bd, dti_ts), SC_DTI,
fax_ch, SC_FAX,
SC_FULLDUP)) != 0) {
printf("Could not route the T-1 time slot to the fax channel: Error = %d", rcode);
exit(1);
}
.
. Process fax call.
.
/***** Disconnect fax channel. ******/
/*
* Break the full duplex connection between T-1 time slot 12
* and fax channel 2.
*/
if ((rcode = nr_scunroute(DT_MKTSLOT(dti_bd, dti_ts), SC_DTI,
fax_ch, SC_FAX,
SC_FULLDUP)) != 0) {
printf("Could not disconnect T-1 time slot from fax channel: Error = %d", rcode);
exit(1);
}
/***** Re-connect T-1 time slot 12 for voice processing *****/
/***** using voice channel 14. *****/
/*
* Make a full duplex connection between T-1 time slot 12
* and voice channel 14.
*/
if ((rcode = nr_scroute(DT_MKTSLOT(dti_bd, dti_ts), SC_DTI,
chdev, SC_VOX,
SC_FULLDUP)) != 0) {
printf("Could not route the T-1 time slot to the voice channel: Error = %d", rcode);
exit(1);
}
.
. Continue processing.
.
}
6.1.4. OS/2 Sample Code for SCbus Convenience Functions#define INCL_DOSERRORS
#include <os2.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <voxlib.h>
#include <dtilib.h>
#include <dti2lib.h>
#include <faxlib.h>
/*
* For nr_ function error printing, DTI and fax functionality, make sure
* PRINTON, DTISC and FAXSC are defined when compiling the sctools.c file.
*/
#include <sctools.h>
main()
{
int dtih, /* T-1 time slot handle */
faxh, /* Fax channel handle */
chdev; /* Voice channel handle */
/* Open T-1 time slot 12 on the first D/240SC-T1. */
if ((dtih = dt_open("DTIB0T11", 0)) == -1) {
printf("Cannot open T-1 time slot DTIB0T11. dl_errno = %d", dl_errno);
exit(1);
}
/* Open fax channel 2 on board 5 (fax channel 2 on the VFX/40ESC). */
if ((faxh = fx_open("VOXB4C1", O_RDWR)) == -1) {
printf("Cannot open fax channel VOXB4C1. dl_errno = %d", dl_errno);
exit(1);
}
/* Open voice channel 2 on board 9 (voice channel 14 on the first D/240SC-T1). */
if ((chdev = dl_open("VOXB8C1", O_RDWR)) == -1) {
printf("Cannot open voice channel VOXB8C1. dl_errno = %d", dl_errno);
exit(1);
}
.
. Continue processing.
.
/***** SCbus routing example. *****/
/*
* Make a full duplex connection between T-1 time slot 12
* and fax channel 2.
*/
if (nr_scroute(dtih, SC_DTI, faxh, SC_FAX, SC_FULLDUP) == -1) {
printf("Could not route the T-1 time slot to the fax channel");
exit(1);
}
.
. Process fax call.
.
/***** Disconnect fax channel. ******/
/*
* Break the full duplex connection between T-1 time slot 12
* and fax channel 2.
*/
if (nr_scunroute(dtih, SC_DTI, faxh, SC_FAX, SC_FULLDUP) == -1) {
printf("Could not disconnect T-1 time slot from fax channel");
exit(1);
}
/***** Connect T-1 time slot 12 for voice processing *****/
/***** using voice channel 14. *****/
/*
* Make a full duplex connection between T-1 time slot 12
* and voice channel 14.
*/
if (nr_scroute(dtih, SC_DTI, chdev, SC_VOX, SC_FULLDUP) == -1) {
printf("Could not route the T-1 time slot to the voice channel");
exit(1);
}
.
. Continue processing.
.
}
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation