📄 cvmcon.cpp
字号:
/****************************************************************************
* Program/file: PP-PCCON.C
*
* Copyright (C) by RTX TELECOM A/S, Denmark.
* These computer program listings and specifications, are the property of
* RTX TELECOM A/S, Denmark and shall not be reproduced or copied or used in
* whole or in part without written permission from RTX TELECOM A/S, Denmark.
*
* Programmer: SS
*
* MODULE:
* CONTROLLING DOCUMENT:
* SYSTEM DEPENDENCIES:
*
* DESCRIPTION:
*
****************************************************************************/
/****************************************************************************
* Include files
****************************************************************************/
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#include "std-def.h"
#include "primitiv.h"
#define PROJCFG_FP_CCF_INSTANCES 5
#include "app_task.h"
/****************************************************************************
* Macro Definitions
****************************************************************************/
#define TB_HANDLE_TASK 0x00 // for production test calls (simulated sendmail)
#define USER_TASK 0x0F // for standard API calls
#define BUSM_SendMailP0(pid,tid,prim) rsx_SendMailP0(tid,prim)
#define BUSM_SendMailP1(pid,tid,prim,p1) rsx_SendMailP1(tid,prim,p1)
#define BUSM_SendMailP2(pid,tid,prim,p1,p2) rsx_SendMailP2(tid,prim,p1,p2)
#define BUSM_SendMailP3(pid,tid,prim,p1,p2,p3) rsx_SendMailP3(tid,prim,p1,p2,p3)
#define DSP_NUMBER_OF_VOL_STEPS 10 // Volume Steps for ringer
#define DSP_NUMBER_OF_RING_VOL_STEPS 10 // Volume Steps for ringer
#define DATA_TEST_LENGTH 44
/****************************************************************************
* Typedefinitions
****************************************************************************/
typedef enum {
MMI_INIT,
MMI_STANDBY,
MMI_WAIT_SETUP,
MMI_ALERTING,
MMI_CONVERSATION,
MMI_WAIT_RELEASE,
MMI_BUSY,
MMI_EXT_DATA,
MMI_FP_WAIT_SETUP,
MMI_FP_WAIT_RELEASE
}ENUM8(mmi_main_states);
// Protocol interface.
typedef enum
{
CALLCLASS__EXT,
CALLCLASS__INT,
CALLCLASS_SERVICE,
CALLCLASS_EMERGENCY,
CALLCLASS_EXTHANDOVER,
CALLCLASS_EXT_DATA,
CALLCLASS_INT_DATA
} ENUM8(minigap_CallClassType);
typedef struct
{
PrimitiveType PrimitiveIdentifier;
uint8 bKey;
} KeyMessageReqType;
typedef struct
{
PrimitiveType PrimitiveIdentifier;
} recSendMailP0Type;
typedef struct
{
PrimitiveType PrimitiveIdentifier;
uint8 bParm1;
} recSendMailP1Type;
typedef struct
{
PrimitiveType PrimitiveIdentifier;
uint8 bParm1;
uint8 bParm2;
} recSendMailP2Type;
typedef struct
{
PrimitiveType PrimitiveIdentifier;
uint8 bParm1;
uint8 bParm2;
uint8 bParm3;
} recSendMailP3Type;
typedef struct
{
PrimitiveType PrimitiveIdentifier;
uint8 bData[500];
} recDataType;
/****************************************************************************
* Variables
****************************************************************************/
uint16 Comport = 1; // Default COM1:
int32 debug_ProgramId;
uint8 MmiState = MMI_INIT;
//uint8 bDataArr[500];
//uint16 Length;
uint8 Task = 0x0F; // Usertask
uint8 AudioVol = 4; // initial audio volume set to 4 (range 0-9)
uint8 *bConPtr;
uint8 ConTask;
uint16 ConLength;
static boolean HsDataTestMode = FALSE;
static uint8 HsDataTestTxCounter = 0;
static uint8 HsDataTestRxCounter = 0;
static uint32 HsDataTestTotalRxCount = 0;
static clock_t HsDataTestStartTime;
static uint32 HsDataTestTotalTxCount;
static uint32 HsDataReadyIndCount;
static uint8 HsDataTestLength = 30;
uint8 ConnectionEI = 0xFF;
uint8 CallClass;
//extern HSDDataType HSDData[HSD_MAX_CONNECTIONS];
//HSDDataType HSDData[PROJCFG_FP_CCF_INSTANCES-1];
/****************************************************************************
* Externals (not nice)
****************************************************************************/
extern void InitRs232(int Port, int BaudRate);
extern void InitTestBus(void);
extern void bus232_SendPacketToUnit(int iTaskId, int iLength, unsigned char *bInputDataPtr);
extern void sendmail_ReceivePacket(uint16 Length, uint8 *bDataPtr);
extern bool bus232_Busy(void);
/****************************************************************************
* Implementation (subfunctions)
****************************************************************************/
extern "C" void rsx_SendMail(uint32 iTaskId, uint32 iLength, uint8 *bDataPtr)
{
bus232_SendPacketToUnit(iTaskId, iLength, bDataPtr);
}
extern "C" void rsx_SendMailP0(uint32 iTaskId, PrimitiveType Primitive)
{
bus232_SendPacketToUnit(iTaskId, sizeof(PrimitiveType), (uint8*) &Primitive);
}
extern "C" void rsx_SendMailP1(uint32 iTaskId, PrimitiveType Primitive, uint8 bParm1)
{
recSendMailP1Type tmp;
tmp.PrimitiveIdentifier = Primitive;
tmp.bParm1 = bParm1;
bus232_SendPacketToUnit(iTaskId, sizeof(recSendMailP1Type), (uint8*) &tmp);
}
extern "C" void rsx_SendMailP2(uint32 iTaskId, PrimitiveType Primitive, uint8 bParm1, uint8 bParm2)
{
recSendMailP2Type tmp;
tmp.PrimitiveIdentifier = Primitive;
tmp.bParm1 = bParm1;
tmp.bParm2 = bParm2;
bus232_SendPacketToUnit(iTaskId, sizeof(recSendMailP2Type), (uint8*) &tmp);
}
extern "C" void rsx_SendMailP3(uint32 iTaskId, PrimitiveType Primitive, uint8 bParm1, uint8 bParm2, uint8 bParm3)
{
recSendMailP3Type tmp;
tmp.PrimitiveIdentifier = Primitive;
tmp.bParm1 = bParm1;
tmp.bParm2 = bParm2;
tmp.bParm3 = bParm3;
bus232_SendPacketToUnit(iTaskId, sizeof(recSendMailP3Type), (uint8*) &tmp);
}
uint8 *BUSM_AllocateMail(uint8 uProgramId, uint8 uTaskId, uint16 u16Size)
{
ConTask = uTaskId;
ConLength = u16Size;
bConPtr = (uint8 *)malloc(u16Size);
return(bConPtr);
}
void BUSM_DeliverMail(uint8 *Mail)
{
rsx_SendMail(ConTask, ConLength, bConPtr);
free(bConPtr);
}
/****************************************************************************
* FUNCTION: DataInit
*
* INPUTS :
* OUTPUTS : none
* RETURNS : none
*
* DESCRIPTION:
****************************************************************************/
static void DataInit(uint8 ei)
{
printf("<-API_FP_DATA_RECEIVE_READY_REQ * 5\n");
// We are allowed to send up to 5 ready req's in order to utilize the serial string fully
BUSM_SendMailP1(0, USER_TASK, API_FP_DATA_RECEIVE_READY_REQ, ei);
BUSM_SendMailP1(0, USER_TASK, API_FP_DATA_RECEIVE_READY_REQ, ei);
BUSM_SendMailP1(0, USER_TASK, API_FP_DATA_RECEIVE_READY_REQ, ei);
BUSM_SendMailP1(0, USER_TASK, API_FP_DATA_RECEIVE_READY_REQ, ei);
BUSM_SendMailP1(0, USER_TASK, API_FP_DATA_RECEIVE_READY_REQ, ei);
HsDataReadyIndCount = 0;
}
/****************************************************************************
* FUNCTION: DataSend
*
* INPUTS :
* OUTPUTS : none
* RETURNS : none
*
* DESCRIPTION:
****************************************************************************/
static void DataSend(uint8 Length)
{
if (HsDataReadyIndCount > 0)
{
ApiFpDataSendReqType * NewMailPtr;
NewMailPtr = (ApiFpDataSendReqType*) BUSM_AllocateMail(0, USER_TASK, ((uint16)(sizeof(ApiFpDataSendReqType)+Length-1)));
if(NewMailPtr != NULL)
{
uint8 i;
NewMailPtr->PrimitiveIdentifier = API_FP_DATA_SEND_REQ;
NewMailPtr->bConnectionEI = ConnectionEI;
NewMailPtr->bLength = Length;
for (i = 0; i < Length; i++)
{
NewMailPtr->bData[i] = HsDataTestTxCounter++;
}
BUSM_DeliverMail((uint8*) NewMailPtr);
HsDataTestTotalTxCount += Length;
if (HsDataTestMode && clock() && clock() != HsDataTestStartTime)
{
printf("<-API_FP_DATA_SEND_REQ (%u bytes %u total %u bps avg)\n", Length, HsDataTestTotalTxCount,
(uint32)((float)HsDataTestTotalTxCount*8*CLOCKS_PER_SEC/(clock()-HsDataTestStartTime)));
}
else
{
printf("<-API_FP_DATA_SEND_REQ (%u bytes)\n", Length, HsDataTestTotalTxCount);
}
HsDataReadyIndCount--;
}
}
}
/****************************************************************************
* FUNCTION: main
*
* INPUTS : mailpointer
* OUTPUTS : none
* RETURNS : none
*
* DESCRIPTION: main function
****************************************************************************/
void main(int argc, char *argv[])
//void main(void)
{
uint16 Primitiv;
uint16 tempLength = 1;
uint8 tempDataPtr[5];
uint8 Key = 'h'; // Start with print of help text
// initializing com port with cmd line args
printf("CVM Communication Console\n");
if((argc == 2) && ((*argv[1] >= '1') && (*argv[1] <= '9')))
{
Comport = ((*argv[1]) - '0'); // set com port
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -