# adiStartReceivingFSK

Receives frequency shift key (FSK) data.

#### Supported board types

- AG

- CG

#### Prototype

DWORD adiStartReceivingFSK ( CTAHD ctahd, void *buffer, unsigned bufsize, ADI_FSKRECEIVE_PARMS *parms)

Argument | Description
ctahd | Context handle returned by ctaCreateContext or ctaAttachContext.
buffer | Pointer to buffer to hold received data.
bufsize | Size of buffer to receive.
parms | Pointer to the FSK receive parameters, stored in the following structure (NULL designates default values): typedef struct { DWORD size; /* Size of this structure */ INT32 minlevel; /* Required minimum receive level (dB) */ DWORD minmark; /* Minimum required initial mark and seizure */ DWORD droptime; /* Minimum dropout to silence before a */ /* packet is considered terminated (ms) */ DWORD baudrate; /* Baud rate (only 1200 supported) */ } ADI_FSKRECEIVE_PARMS; Refer to ADI_FSKRECEIVE_PARMS for field descriptions.

#### Return values

Return value | Description
SUCCESS |
CTAERR_BAD_ARGUMENT | buffer is NULL or size is 0 (zero).
CTAERR_FUNCTION_ACTIVE | Function already started.
CTAERR_INVALID_CTAHD | Context handle is invalid.
CTAERR_INVALID_STATE | Function not valid in the current port state.
CTAERR_SVR_COMM | Server communication error.

#### Events

Event | Description
ADIEVN_FSK_RECEIVE_DONE | Generated by the ADI service when the receive function terminates. The event value field contains one of the following termination conditions or an error code: ADI_REASON_DROP_IN_DATA Stopped due to drop in data. ADI_REASON_BAD_STOP_BIT Stopped due to data framing error. The stop bit at the end of data was space, not mark. CTA_REASON_FINISHED Data was received successfully. CTA_REASON_RELEASED Call terminated. CTA_REASON_STOPPED Stopped by application request.

#### Details

Load the appropriate DSP file to the board before running adiStartReceivingFSK.

For AG boards, load this DSP file:

Bellcore 1200/2200 Hz | V.23 1300/2100 Hz
adsir.m54 | adsir_j.m54

For CG boards, load this DSP file:

Bellcore 1200/2200 Hz | V.23 1300/2100 Hz
adsir.f54 | adsir_j.f54

See DSP file summary for DSP file descriptions. Refer to the board installation and developer's manual for a table of MIPS usage for all functions.

Use this function to receive frequency shift key (FSK) data. The function can be stopped using adiStopReceivingFSK. When the function completes, ADIEVN_FSK_RECEIVE_DONE is generated.

If the event value field contains CTA_REASON_FINISHED or CTA_REASON_STOPPED, the size field of the event structure contains the number of bytes received. The received buffer is in the buffer field. If errors occur, the receive operation is terminated and the event value field contains either ADI_REASON_DROP_IN_DATA or ADI_REASON_BAD_STOP_BIT.

For more information, refer to Sending and receiving FSK data.

#### Example

#define MYRECEIVE_FAILURE (-11)
#define MYRECEIVE_STOPPED (-12)
int myReceiveFSK( CTAHD ctahd )
{
CTA_EVENT event;
char buffer [512];
if( adiStartReceivingFSK( ctahd, buffer, sizeof buffer, NULL) != SUCCESS )
return MYFAILURE;
do
{
myGetEvent( &event ); /* see ctaWaitEvent example */
} while( event.id != ADIEVN_FSK_RECEIVE_DONE );
switch( event.value )
{
case CTA_REASON_FINISHED:
return SUCCESS;
case CTA_REASON_RELEASED:
return MYDISCONNECT;
case CTA_REASON_STOPPED:
/* Receive was stopped by another application thread */
return MYRECEIVE_STOPPED;
case ADI_REASON_DROP_IN_DATA:
case ADI_REASON_BAD_STOP_BIT:
return MYRECEIVE_FAILURE;
default:
if( CTA_IS_ERROR( event.value ) )
return MYFAILURE;
}
return MYFAILURE;
}