📄 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"
#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
// Keys
#define KEY_CTRL_A 0x01
#define KEY_CTRL_C 0x03
#define KEY_CTRL_H 0x08
#define KEY_CTRL_I 0x09
#define KEY_CTRL_R 0x12
#define KEY_CTRL_S 0x13
#define KEY_CTRL_T 0x14
#define KEY_CTRL_U 0x15
#define KEY_CTRL_Z 0x1a
/****************************************************************************
* Typedefinitions
****************************************************************************/
typedef enum {
MMI_INIT, // 0x00
MMI_UNLOCKED, // 0x01
MMI_STANDBY, // 0x02
MMI_WAIT_SETUP, // 0x03
MMI_ALERTING, // 0x04
MMI_CONVERSATION, // 0x05
MMI_WAIT_RELEASE, // 0x06
MMI_BUSY, // 0X07
MMI_SERVICE_CALL, // 0X08
MMI_EXT_DATA, // 0x09
MMI_WT_STANDBY, // 0x0A
MMI_WT_FP_MODE, // 0x0B
MMI_WT_WAIT_SETUP, // 0x0C
MMI_WT_ALERTING, // 0x0D
MMI_WT_WAIT_CONNECT, // 0x0E
MMI_WT_CONVERSATION, // 0x0F
MMI_WT_WAIT_RELEASE, // 0x10
MMI_WT_BUSY // 0X11
}ENUM8(mmi_main_states);
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)
static uint8 MmiCallClass;
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;
static uint32 lnClipTestCnt=0; // test counter for CLIP , makes it easier to see how many
// clip packets that have been received
/****************************************************************************
* 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: SendSwCtrlCmdP2
*
* INPUTS :
* OUTPUTS : none
* RETURNS : none
*
* DESCRIPTION: Sends a command to the switch-control.
****************************************************************************/
static void
SendSwCtrlCmd(CvmSwCmdIdType n_CmdId, uint8 n_ParmLen, uint8 *p_Parm)
{
CvmPpSwCtrlReqType * NewMailPtr;
NewMailPtr = (CvmPpSwCtrlReqType*) BUSM_AllocateMail(0, USER_TASK, ((uint16)(sizeof(CvmPpSwCtrlReqType)-1+n_ParmLen)));
if(NewMailPtr != NULL)
{
NewMailPtr->PrimitiveIdentifier = CVM_PP_SW_CTRL_REQ;
NewMailPtr->bCommandId = n_CmdId;
NewMailPtr->bParamLength=n_ParmLen;
if (n_ParmLen)
{
memcpy(NewMailPtr->bParams,p_Parm,n_ParmLen);
}
BUSM_DeliverMail((uint8*) NewMailPtr);
}
}
/****************************************************************************
* FUNCTION: SendSwCtrlCmdP0
*
* INPUTS :
* OUTPUTS : none
* RETURNS : none
*
* DESCRIPTION: Sends a command to the switch-control.
****************************************************************************/
static void
SendSwCtrlCmdP0(CvmSwCmdIdType n_CmdId)
{
SendSwCtrlCmd(n_CmdId,0,NULL);
/*
CvmPpSwCtrlReqType * NewMailPtr;
NewMailPtr = (CvmPpSwCtrlReqType*) BUSM_AllocateMail(0, USER_TASK, ((uint16)(sizeof(CvmPpSwCtrlReqType)-1)));
if(NewMailPtr != NULL)
{
NewMailPtr->PrimitiveIdentifier = CVM_PP_SW_CTRL_REQ;
NewMailPtr->bCommandId = n_CmdId;
NewMailPtr->bParamLength=0;
BUSM_DeliverMail((uint8*) NewMailPtr);
}
*/
}
/****************************************************************************
* FUNCTION: SendSwCtrlCmdP2
*
* INPUTS :
* OUTPUTS : none
* RETURNS : none
*
* DESCRIPTION: Sends a command to the switch-control.
****************************************************************************/
static void
SendSwCtrlCmdP2(CvmSwCmdIdType n_CmdId, uint8 n_p1, uint8 n_p2)
{
uint8 b[2];
b[0]=n_p1;
b[1]=n_p2;
SendSwCtrlCmd(n_CmdId,2,b);
}
/****************************************************************************
* Implementation
****************************************************************************/
/****************************************************************************
* FUNCTION: main
*
* INPUTS : mail pointer
* 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
}
else
{
printf("No cmdline arguments\n");
}
printf("Connecting to COM%d:\n",Comport);
InitTestBus();
InitRs232(Comport, 19200);
// initialize state handler
if(MmiState == MMI_INIT)
{
while(bus232_Busy()); // wait for rs232 handshake
Primitiv = INITTASK;
tempDataPtr[0] = (uint8) (Primitiv&0x00ff);
tempDataPtr[1] = (uint8) (Primitiv>>8);
tempLength = 0;
sendmail_ReceivePacket(tempLength, tempDataPtr);
}
// check for quit
while (Key != 0x1B/*ESC Key*/)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -