Kinfe Tadesse
2006-04-30 10:31:09 UTC
Hi All,
I am trying to stream data to CAPI. i am facing a problem while trying to
send DATA_B3_REQ to CAPI. Please find the detailed description of the
problem below. I will be waiting for a recommendation to a solution
anxiously!
The statement of the problem: I have a TTS system which is integrated into
my application to speak prompts to a user. Each byte of the data the TTS
speaks need to be bit-flipped before it is sent to the TTS engine. I have
ProcessReceivedData(char* Data, WORD len) to do so. This method reverses the
bytes and calls the sendData(char * Data) method below with the reversed
data to be sent to CAPI. Please read on and find the bug in the following
code segements.
In the interest of being clear, I have tried to be specific.
I have the following Structrure definitions:
/* DATA-B3-REQUEST */
typedef struct {dword Data; word Data_Length; word Number; word Handle; word
Flags;} _DAT_B3_REQP;
/* DATA-B3-CONFIRM */
typedef struct {word Number; word Handle; word Info;} _DAT_B3_CONP;
I also have the following #defines:
#define CAPIMSG_BUF_LEN 2048 // Max length of CAPI Message buffer
#define DATA_LEN 1024 // Max data length
#define CHUNKCOUNT 7 // Number of data chunks that can be sent to CAPI
#define CAPIMSG_HEADER_LEN sizeof(CAPIMsg.header)// Length of the CAPI Msg
header (12 bytes)
#define _DATA_B3_R 0x8086 //command and subcommand are merged into a
WORD
#define _DATA_B3_I 0x8286 //command and subcommand are merged into a
WORD
/* OR this to convert a REQUEST to a CONFIRM */
#define CONFIRM 0x0100
/* OR this to convert a INDICATION to a RESPONSE */
#define RESPONSE 0x0100
The following global variables are also defined:
DWORD dwApplId = 0; // Appl. Id. #
WORD wCAPICmd =0;
WORD wCtrl = 1; // Controller #
WORD wDataLen = 0; // Data Len #
WORD wDataHandle =0; //Data Handle
BYTE bPLCI = 0; // PLCI #
WORD wNCCI = 0; // NCCI #
char szDataBuf[DATA_LEN]; // Data buffer #
The following function is meant to fill a buffer with data and send
DATA_B3_REQ and get confirmation from CAPI.
void SendData(char *Data){
DWORD dwApplId=0;
static WORD wDataHandle;
int i=0;
while(i<CHUNKCOUNT && Data !=NULL){
for(int j=0;j<DATA_LEN;j++){
szDataBuf[j]= Data[j];
i++;}}
if( PutCAPIDataReq(dwApplId) != FALSE ){
GetCAPIDataConf(dwApplId) ;
wDataHandle++; //To make the data handle unique}}
*-------------------------------------------------------------------
* PutCAPIDataReq()
*-------------------------------------------------------------------*/
BOOL PutCAPIDataReq(DWORD dwApplId){
DWORD dwRetCode;
CAPI_MSG CAPIMsg;
memset(&CAPIMsg, 0, sizeof(CAPIMsg));
CAPIMsg.header.appl_id = (WORD)dwApplId;
CAPIMsg.header.controller = (BYTE)wCtrl;
CAPIMsg.header.plci = bPLCI;
CAPIMsg.header.ncci = wNCCI;
CAPIMsg.header.command = _DATA_B3_R;
CAPIMsg.header.length = CAPIMSG_HEADER_LEN + sizeof(_DAT_B3_REQP);
CAPIMsg.info.data_b3_req.Handle = wDataHandle;
CAPIMsg.info.data_b3_req.Data_Length = DATA_LEN;
CAPIMsg.info.data_b3_req.Data = (DWORD) &szDataBuf;
CAPIMsg.info.data_b3_req.Number = 0; // Always use same handle: 0
CAPIMsg.info.data_b3_req.Flags = 0; // No flags.
dwRetCode = CAPI_PUT_MESSAGE( dwApplId, &CAPIMsg);
if (dwRetCode != SUCCESS)
{
printf("\n[ERROR] CAPI_PUT_MESSAGE DATA_B3_REQ failed, error
0x%04X.",dwRetCode);
return FALSE;
}
printf("\n[OK ] CAPI_PUT_MESSAGE.DATA_B3_REQ");
return TRUE;
}
The call to PutCAPIDataReq(dwApplId) always returns FALSE and CONFIRM is
never done! But for completeness please find the Confirmation function
below.
/*-------------------------------------------------------------------
* GetCAPIDataConf()
* -------------------------------------------------------------------*/
BOOL GetCAPIDataConf(DWORD dwApplId){
CAPI_MSG *CAPIMessage=NULL;
//Wait for a DATA_B3_CONF
do{
CAPIMessage = WaitForConfirmation(dwApplId);// function waiting for
confirmation message
}while(!(CAPIMessage->header.command & _DATA_B3_R));
if(CAPIMessage->info.data_b3_con.Info!= SUCCESS)
{
printf("\n==>: DATA_B3_CONF NOT OK, Info =
0x%04X",CAPIMessage->info.data_b3_con.Info);
return FALSE;
}
printf("\n[OK ] RECEIVED DATA_B3_CONF: DATA CONFIRMATION OK.");
return TRUE;
}
This has become a stumbling block and I appreciate any help!!!
Best regards,
Kinfe T.
I am trying to stream data to CAPI. i am facing a problem while trying to
send DATA_B3_REQ to CAPI. Please find the detailed description of the
problem below. I will be waiting for a recommendation to a solution
anxiously!
The statement of the problem: I have a TTS system which is integrated into
my application to speak prompts to a user. Each byte of the data the TTS
speaks need to be bit-flipped before it is sent to the TTS engine. I have
ProcessReceivedData(char* Data, WORD len) to do so. This method reverses the
bytes and calls the sendData(char * Data) method below with the reversed
data to be sent to CAPI. Please read on and find the bug in the following
code segements.
In the interest of being clear, I have tried to be specific.
I have the following Structrure definitions:
/* DATA-B3-REQUEST */
typedef struct {dword Data; word Data_Length; word Number; word Handle; word
Flags;} _DAT_B3_REQP;
/* DATA-B3-CONFIRM */
typedef struct {word Number; word Handle; word Info;} _DAT_B3_CONP;
I also have the following #defines:
#define CAPIMSG_BUF_LEN 2048 // Max length of CAPI Message buffer
#define DATA_LEN 1024 // Max data length
#define CHUNKCOUNT 7 // Number of data chunks that can be sent to CAPI
#define CAPIMSG_HEADER_LEN sizeof(CAPIMsg.header)// Length of the CAPI Msg
header (12 bytes)
#define _DATA_B3_R 0x8086 //command and subcommand are merged into a
WORD
#define _DATA_B3_I 0x8286 //command and subcommand are merged into a
WORD
/* OR this to convert a REQUEST to a CONFIRM */
#define CONFIRM 0x0100
/* OR this to convert a INDICATION to a RESPONSE */
#define RESPONSE 0x0100
The following global variables are also defined:
DWORD dwApplId = 0; // Appl. Id. #
WORD wCAPICmd =0;
WORD wCtrl = 1; // Controller #
WORD wDataLen = 0; // Data Len #
WORD wDataHandle =0; //Data Handle
BYTE bPLCI = 0; // PLCI #
WORD wNCCI = 0; // NCCI #
char szDataBuf[DATA_LEN]; // Data buffer #
The following function is meant to fill a buffer with data and send
DATA_B3_REQ and get confirmation from CAPI.
void SendData(char *Data){
DWORD dwApplId=0;
static WORD wDataHandle;
int i=0;
while(i<CHUNKCOUNT && Data !=NULL){
for(int j=0;j<DATA_LEN;j++){
szDataBuf[j]= Data[j];
i++;}}
if( PutCAPIDataReq(dwApplId) != FALSE ){
GetCAPIDataConf(dwApplId) ;
wDataHandle++; //To make the data handle unique}}
*-------------------------------------------------------------------
* PutCAPIDataReq()
*-------------------------------------------------------------------*/
BOOL PutCAPIDataReq(DWORD dwApplId){
DWORD dwRetCode;
CAPI_MSG CAPIMsg;
memset(&CAPIMsg, 0, sizeof(CAPIMsg));
CAPIMsg.header.appl_id = (WORD)dwApplId;
CAPIMsg.header.controller = (BYTE)wCtrl;
CAPIMsg.header.plci = bPLCI;
CAPIMsg.header.ncci = wNCCI;
CAPIMsg.header.command = _DATA_B3_R;
CAPIMsg.header.length = CAPIMSG_HEADER_LEN + sizeof(_DAT_B3_REQP);
CAPIMsg.info.data_b3_req.Handle = wDataHandle;
CAPIMsg.info.data_b3_req.Data_Length = DATA_LEN;
CAPIMsg.info.data_b3_req.Data = (DWORD) &szDataBuf;
CAPIMsg.info.data_b3_req.Number = 0; // Always use same handle: 0
CAPIMsg.info.data_b3_req.Flags = 0; // No flags.
dwRetCode = CAPI_PUT_MESSAGE( dwApplId, &CAPIMsg);
if (dwRetCode != SUCCESS)
{
printf("\n[ERROR] CAPI_PUT_MESSAGE DATA_B3_REQ failed, error
0x%04X.",dwRetCode);
return FALSE;
}
printf("\n[OK ] CAPI_PUT_MESSAGE.DATA_B3_REQ");
return TRUE;
}
The call to PutCAPIDataReq(dwApplId) always returns FALSE and CONFIRM is
never done! But for completeness please find the Confirmation function
below.
/*-------------------------------------------------------------------
* GetCAPIDataConf()
* -------------------------------------------------------------------*/
BOOL GetCAPIDataConf(DWORD dwApplId){
CAPI_MSG *CAPIMessage=NULL;
//Wait for a DATA_B3_CONF
do{
CAPIMessage = WaitForConfirmation(dwApplId);// function waiting for
confirmation message
}while(!(CAPIMessage->header.command & _DATA_B3_R));
if(CAPIMessage->info.data_b3_con.Info!= SUCCESS)
{
printf("\n==>: DATA_B3_CONF NOT OK, Info =
0x%04X",CAPIMessage->info.data_b3_con.Info);
return FALSE;
}
printf("\n[OK ] RECEIVED DATA_B3_CONF: DATA CONFIRMATION OK.");
return TRUE;
}
This has become a stumbling block and I appreciate any help!!!
Best regards,
Kinfe T.