
Description | Cautions | Example | Errors | See Also
Name: |
int fx_rcvfax2(dev, fd, rcvflag) | |
Inputs: |
int dev |
fax channel device handle (to receive fax data) |
|
int fd |
receive file descriptor |
|
unsigned long rcvflag |
mode flag |
Returns: |
0 if success (on invocation in asynchronous mode) | |
|
-1 if failure (on invocation in asynchronous mode) | |
Includes: |
srllib.h | |
|
dxxxlib.h | |
|
faxlib.h | |
Category: |
receive fax | |
Mode: |
synchronous/asynchronous | |
|
||
The fx_rcvfax2( ) function receives fax data (file descriptor argument) from an open channel device and stores it as a TIFF/F file or a raw file.
The fx_rcvfax2( ) function can be issued by the fax receiver or the fax transmitter. To stop a fax reception in progress, use fx_stopch( ).
The encoding scheme in which the incoming fax data may be stored (MH and/or MMR) is based on the capability of the Dialogic fax product. For product capabilities, see Section 2.4. Key Product Features on page 8.
The fx_rcvfax2( ) function uses a file descriptor argument (fd) to specify the receive file instead of a file name as in the fx_rcvfax( ) function.
To receive a fax using user-definable I/O functions, you must issue fx_rcvfax2( ) and logically "OR" the IO_UIO bit in the rcvflag argument.
For more information on setting up the channel device to receive fax data, see Chapter 5. Implementing Fax Capability -- Receive Fax.
/*
* The principal difference between fx_rcvfax( ) and
* fx_rcvfax2( ) is that the application must open the
* receive file and pass the file descriptor to the
* fx_rcvfax2( ) function instead of the receive file name.
* Example 1 from the function reference for fx_rcvfax( ) has
* been modified for use with fx_rcvfax2( ) and included
* below. The other examples in fx_rcvfax( ) can be modified
* similarly.
*/
#include <stdio.h>
#include <windows.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <faxlib.h>
int voxdev; /* Voice channel device handle. */
int dev; /* Fax channel device handle. */
int rcvfd;
unsigned long rcvflag;
/*
* Open the channel using dx_open( ) and obtain the Dialogic
* VOICE channel device handle in voxdev.
*/
.
.
/*
* Open the channel using fx_open( ) and obtain the Dialogic
* FAX channel device handle in dev.
*/
.
.
/*
* Set channel on-hook using dx_sethook( ) in synchronous
* mode.
*/
.
.
/*
* Wait for 1 ring and go off-hook using dx_wtring( ).
*/
.
.
/* If this is a channel on a VFX/40SC (return type DFS_FAX40)
* or VFX/40ESC (return type DFS_FAX40E),
* a vertical resolution for the receive file can
* be specified in rcvflag. For the VFX/40ESC, the
* received data can be stored as MMR encoded data.
*/
switch (ATFX_CHTYPE(dev)) {
case DFS_FAX40:
/* Store the received file in low vertical resolution. */
rcvflag |= DF_RXRESLO;
break;
case DFS_FAX40E:
/*
* Store the received file in low vertical resolution
* and MMR encoding.
*/
rcvflag |= DF_RXRESLO;
value = DF_MMR;
if (fx_setparm(dev,FC_RXCODING,(void *)&value) == -1) {
printf("Error - %s (error code %d)\n", ATDV_ERRMSGP(dev),
ATDV_LASTERR(dev));
if (ATDV_LASTERR(dev) == EDX_SYSTEM) {
/* Perform system error processing */
}
}
break;
default:
break;
}
/*
* Set the fax state of the channel to DF_RX using
* fx_initstat( ).
*/
.
.
/*
* Open the file "myfax.tif" in preparation for receiving a
* fax. Use dx_fileopen( ) to open the file.
*/
if ((rcvfd = dx_fileopen("myfax.tif", O_BINARY|O_WRONLY|O_CREAT|O_TRUNC,
0666)) == -1) {
/* Error opening file. */
/* Perform system error processing */
.
.
}
/*
* Receive the fax data into "myfax.tif" file - synchronous
* mode.
*/
if((fx_rcvfax2(dev,rcvfd,rcvflag))
== -1) {
printf("Error - %s (error code %d)\n", ATDV_ERRMSGP(dev),
ATDV_LASTERR(dev));
if (ATDV_LASTERR(dev) == EDX_SYSTEM) {
/* Perform system error processing */
}
printf("Phase E status: %ld\n", ATFX_ESTAT(dev));
/* Application specific error handling. */
.
.
}
/* Close the received file. */
if (dx_fileclose(rcvfd) == -1) {
/* Error closing file. */
/* Perform system error processing */
.
.
}
In synchronous mode, this function returns a zero to indicate successful completion or a -1 to indicate an error.
In asynchronous mode, this function returns a zero to indicate successful invocation or a -1 to indicate an invocation error.
Errors that occur during reception generate a Standard Runtime Library event (TFX_FAXERROR). To access the Dialogic defined error code, call the Dialogic standard attribute functions ATDV_LASTERR( ) and ATDV_ERRMSGP( ). The latter returns a string describing the error (see the Voice Software Reference - Programmer's Guide). See Appendix D for a list of Dialogic defined fax error codes.
If the fx_rcvfax2( ) function successfully completes, a TFX_FAXRECV Dialogic Standard Runtime Library event is generated.
The fax extended attribute ATFX_ESTAT( )) provides additional error information for T.30 Phase E fax protocol.
System errors return an EDX_SYSTEM error; use dx_fileerrno( ) to obtain error value. Refer to the dx_fileerrno( ) function in the Voice Software Reference - Programmer's Guide for a list of the possible system error values.
Click here to contact Dialogic Customer Engineering
Copyright 2002, Intel Corporation