/************************************************* /* Copyright (C), 2010-2011,StoneU. Co., Ltd. /* File name: APCSilcon.cpp /* Author: Zero.t /* Version: Ver1.0.0.1 /* Date: 2011-10-19 /* Description: ## /* Others: RS232; /* Function List: ### /* History: 1.Date: ### Author: ### Modification: ### *************************************************/ #include "StdAfx.h" #include "CommProcess.h" #include ".\apcsilcon.h" APCSilcon::APCSilcon( char szPath[MAX_PATH], // 程序所在路径 char szIniName[MAX_PATH], // 配置文件名称 int nCommPort, // 串行端口 int nAddr, // 设备地址 int nRate, // 波特率 int nDataBit, // 数据位 int nStopBit, // 停止位 int nParity, // 校验位 int nInterval // 时间间隔 ) { #if IS_USE_READMSG_CS InitializeCriticalSection( &m_csReadMsg ); //初始化一个临界资源对象 #endif MTVERIFY( m_hSemComm = CreateEvent( NULL, TRUE, TRUE, 0 ) ); //CreateEvent()创建或打开一个命名的或无名的事件对象 memset(m_szSSTMsg, 0, sizeof(m_szSSTMsg)); m_devOnline = TRUE; m_dwOnlineTick = 0; bSendSST = FALSE; } APCSilcon::~APCSilcon() { #if IS_USE_READMSG_CS DeleteCriticalSection( &m_csReadMsg ); #endif MTVERIFY( CloseHandle( m_hSemComm ) ); CloseComm(); } BOOL APCSilcon::APCOpenComm(int nCommPort, int nAddr, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval) { BOOL bResult = FALSE; bResult = OpenComm( nCommPort, nAddr, nRate, nDataBit, nStopBit, nParity, nInterval ); return bResult; } int APCSilcon::SendReadRequest( char szPath[MAX_PATH], char szIniName[MAX_PATH], int nCommPort, int nAddr, char szCmd[MAX_CMD], char szMsg[VAR_MSG], int nReversed1, int nReversed2, int nReversed3, int nReversed4, int nReversed5, float fReversed1, float fReversed2, float fReversed3, char szReversed1[MAX_RESERVED1], char szReversed2[MAX_RESERVED2], char szReversed3[MAX_RESERVED3], char szReversed4[MAX_RESERVED4], char szReversed5[MAX_RESERVED5] ) { int nIndex = 0, nLen = 0; char szSendMsg[MAX_SEND_MSG] = {0}; char szType[TYPE_LENGTH] = {0}; GetIniInfo(szPath, szIniName, szCmd,szSendMsg, szType, nIndex, nLen); CCommProcess *pComm = FindComm(nCommPort); if( pComm == NULL ) return -1; int nRet = -1; if ( (strlen(m_szSSTMsg) ==0 && ( strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 || strcmp(szCmd, "cmd-3") == 0 || strcmp(szCmd, "cmd-4") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-7") == 0 || strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 || strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 || strcmp(szCmd, "cmd-12") == 0 || strcmp(szCmd, "cmd-13") == 0 || strcmp(szCmd, "cmd-14") == 0 || strcmp(szCmd, "cmd-15") == 0 || strcmp(szCmd, "cmd-16") == 0 || strcmp(szCmd, "cmd-17") == 0 || strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 || strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 || strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0 || strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 || strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 || strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 || strcmp(szCmd,"cmd-36") == 0 || strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0 || strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 || strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 ) ) || strcmp(szCmd, "cmd-1") == 0 ) { nRet = GetDeviceParam( nAddr,pComm, szSendMsg, szCmd, szMsg, nIndex, nLen, szType ); if( nRet != 0 ) return nRet; } if( GetTickCount() - m_dwOnlineTick > 60 *1000 && m_dwOnlineTick > 0 ){ m_devOnline = FALSE; } else if( GetTickCount() - m_dwOnlineTick < 60 *1000 && m_dwOnlineTick > 0 ){ m_devOnline = TRUE; } if( m_devOnline == FALSE ){ return -1; } nRet = GetSSTVarMsg(szCmd, szMsg, nIndex, nLen, szType); LOG4C((LOG_NOTICE, "%s=%d, return %d", szCmd, atoi(szMsg), nRet)); return nRet; } int APCSilcon::_SendSSTbyFirst(int nAddr,CCommProcess *pComm) { int nRet = 0; /************************************************************************/ /* SendMsg */ /************************************************************************/ char SendPart[9] = {0}; SendPart[0] = 0x31; SendPart[1] = 0x05; SendPart[2] = 0x01; SendPart[3] = 0x53; SendPart[4] = 0x53; SendPart[5] = 0x54; SendPart[6] = 0x02; SendPart[7] = 0x03; SendPart[8] = 0x54; //WaitForSingObject();等待有信号; if( WaitForSingleObject( m_hSemComm, 0 ) == WAIT_OBJECT_0 ) { //ResetEvent()设置无信号状态 ResetEvent( m_hSemComm ); int nResult = pComm->Write((BYTE *)&SendPart, 9); if( nResult != 9 ) { //SetEvent设置有信号; SetEvent( m_hSemComm ); //返回 错误值; return EER_CODE_APC_COM_REGNUM; } } else{ //如果m_hSemCom无信号,返回错误; return ERR_CODE_APC_COM_BUSY; } /************************************************************************/ /* ReadMsg */ /************************************************************************/ #if 0 char RecviPart[5] = {0}; int nReadLen = 0; nReadLen = pComm->Read((BYTE *)RecviPart, 5); if( nReadLen != 5){ // 错误数据 SetEvent( m_hSemComm ); return ERR_CODE_APC_COM_READ_NO_DATA; } m_dwOnlineTick = GetTickCount(); SetEvent( m_hSemComm ); #endif return nRet; } int APCSilcon::GetDeviceParam( int nAddr, CCommProcess *pComm, //串口对象指针 char szSendMsg[MAX_SEND_MSG], //发送Buffer char szCmd[MAX_CMD], // 命令 char szRecvMsg[VAR_MSG], // 接收Buffer int &nIndex, // 变量索引,针对接收Buffer而言 int &nLen, // 变量长度 char szType[TYPE_LENGTH]) // 变量数据类型 { int nRet = -1; #if DEBUG_APC nRet = _SendSSTbyFirst(nAddr,pComm); SetEvent( m_hSemComm ); if (nRet != 0) { return nRet; } #endif nRet = RequestReadStatus(nAddr,pComm, szSendMsg); if( nRet != 0 ){ return nRet; // 串口忙 } nRet = ResponseReadStatus(pComm, szCmd, szRecvMsg, nIndex, nLen, szType); return nRet; } int APCSilcon::GetSSTVarMsg(char szCmd[MAX_CMD], char szRecvMsg[VAR_MSG], int &nIndex, int &nLen, char szType[TYPE_LENGTH]) { int nRet = 0; if( strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 || strcmp(szCmd, "cmd-3") == 0 || strcmp(szCmd, "cmd-4") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-7") == 0 || strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 || strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 || strcmp(szCmd, "cmd-12") == 0 || strcmp(szCmd, "cmd-13") == 0 || strcmp(szCmd, "cmd-14") == 0 || strcmp(szCmd, "cmd-15") == 0 || strcmp(szCmd, "cmd-16") == 0 || strcmp(szCmd, "cmd-17") == 0 || strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 || strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 || strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0 || strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 || strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 || strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 || strcmp(szCmd,"cmd-36") == 0 || strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0 || strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 || strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 ){ #if IS_USE_READMSG_CS EnterCriticalSection( &m_csReadMsg ); #endif DataConversion(szType, m_szSSTMsg + nIndex, szRecvMsg, nLen,0,0 ); #if IS_USE_READMSG_CS LeaveCriticalSection(&m_csReadMsg); #endif nRet = 0; } return nRet; } int APCSilcon::ResponseReadStatus( CCommProcess *pComm, char szCmd[MAX_CMD], char szRecvMsg[VAR_MSG], int &nIndex, int &nLen, char szType[TYPE_LENGTH] ) { #if DEBUG_APC int nReceiveLen = 300; char *pBuffer = new char[ nReceiveLen ]; memset(pBuffer, 0, nLen); int nReadLen = 0; nReadLen = pComm->Read((BYTE *)pBuffer, nReceiveLen); if( nReadLen <= 0){ // 串口没有读到数据 TRACE("串口没有读到数据!\r\n"); SetEvent( m_hSemComm ); if( pBuffer != NULL) { delete[] pBuffer; pBuffer = NULL; } return ERR_CODE_APC_COM_READ_NO_DATA; } SetSSTVarMsg( szCmd, pBuffer); m_dwOnlineTick = GetTickCount(); SetEvent( m_hSemComm ); if( pBuffer != NULL){ delete[] pBuffer; pBuffer = NULL; } #else SimulationCommData(); #endif return 0; } int APCSilcon::RequestReadStatus(int nAddr,CCommProcess *pComm,char chSendMsg[MAX_SEND_MSG]) { #if DEBUG_APC char SendPart[2] = {0}; SendPart[0] = 0x30; SendPart[1] = 0x05; //WaitForSingObject();等待有信号; if( WaitForSingleObject( m_hSemComm, 0 ) == WAIT_OBJECT_0 ) // 有信号才写串口 { //ResetEvent()设置无信号状态 ResetEvent( m_hSemComm ); int nResult = pComm->Write((BYTE *)SendPart, 2); if( nResult != 2 ) { //SetEvent设置有信号; SetEvent( m_hSemComm ); //返回 错误值; return EER_CODE_APC_COM_REGNUM; } } else { //如果m_hSemCom无信号,返回错误; return ERR_CODE_APC_COM_BUSY; } #endif return 0; } void APCSilcon::SetSSTVarMsg(char szCmd[MAX_CMD], char *pBuff) { if( strcmp(szCmd, "cmd-1") == 0 || strcmp(szCmd, "cmd-2") == 0 || strcmp(szCmd, "cmd-3") == 0 || strcmp(szCmd, "cmd-4") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-5") == 0 || strcmp(szCmd, "cmd-6") == 0 || strcmp(szCmd, "cmd-7") == 0 || strcmp(szCmd, "cmd-8") == 0 || strcmp(szCmd, "cmd-9") == 0 || strcmp(szCmd, "cmd-10") == 0 || strcmp(szCmd, "cmd-11") == 0 || strcmp(szCmd, "cmd-12") == 0 || strcmp(szCmd, "cmd-13") == 0 || strcmp(szCmd, "cmd-14") == 0 || strcmp(szCmd, "cmd-15") == 0 || strcmp(szCmd, "cmd-16") == 0 || strcmp(szCmd, "cmd-17") == 0 || strcmp(szCmd,"cmd-18") == 0 || strcmp(szCmd,"cmd-19") == 0 || strcmp(szCmd,"cmd-20") == 0 || strcmp(szCmd,"cmd-21") == 0 || strcmp(szCmd,"cmd-22") == 0 || strcmp(szCmd,"cmd-23") == 0 || strcmp(szCmd,"cmd-24") == 0 || strcmp(szCmd,"cmd-25") == 0 || strcmp(szCmd,"cmd-26") == 0 || strcmp(szCmd,"cmd-27") == 0 || strcmp(szCmd,"cmd-28") == 0 || strcmp(szCmd,"cmd-29") == 0 || strcmp(szCmd,"cmd-30") == 0 || strcmp(szCmd,"cmd-31") == 0 || strcmp(szCmd,"cmd-32") == 0 || strcmp(szCmd,"cmd-33") == 0 || strcmp(szCmd,"cmd-34") == 0 || strcmp(szCmd,"cmd-35") == 0 || strcmp(szCmd,"cmd-36") == 0 || strcmp(szCmd,"cmd-37") == 0 || strcmp(szCmd,"cmd-38") == 0 || strcmp(szCmd,"cmd-39") == 0 || strcmp(szCmd,"cmd-40") == 0 || strcmp(szCmd,"cmd-41") == 0 || strcmp(szCmd,"cmd-42") == 0 || strcmp(szCmd,"cmd-43") == 0 || strcmp(szCmd,"cmd-44") == 0 ){ #if IS_USE_READMSG_CS EnterCriticalSection( &m_csReadMsg ); #endif memcpy(m_szSSTMsg, &pBuff[5], sizeof(m_szSSTMsg)); #if IS_USE_READMSG_CS LeaveCriticalSection(&m_csReadMsg); #endif } } int APCSilcon::GetIniInfo( char szPath[MAX_PATH], //服务器程序所在目录 char szIniName[MAX_PATH], //配置文件名 char szCmd[MAX_CMD], //命令 char szSendMsg[MAX_CMD], //发送Buffer char nType[MAX_CMD], int &nIndex, int &nLen ) { CHAR szFile[MAX_PATH + 1] = ""; wsprintf(szFile, "%s\\config\\%s", szPath, szIniName); GetPrivateProfileString(szCmd, "SendCmd", "", szSendMsg, 10, szFile); szSendMsg[strlen(szSendMsg)] = '\0'; GetPrivateProfileString(szCmd, "type", "", nType, 10, szFile); nType[strlen(nType)] = '\0'; nIndex = GetPrivateProfileInt(szCmd, "Index", 0, szFile); nLen = GetPrivateProfileInt(szCmd, "Len", 0, szFile); return 0; } void APCSilcon::SimulationCommData(void) { m_szSSTMsg[0] = 0x01; m_szSSTMsg[1] =0x53; m_szSSTMsg[2] =0x53; m_szSSTMsg[3] =0x54; m_szSSTMsg[4] =0x02; m_szSSTMsg[5] =0x20; m_szSSTMsg[6] =0x33; m_szSSTMsg[7] =0x39; m_szSSTMsg[8] =0x34; m_szSSTMsg[9] =0x20; m_szSSTMsg[10] =0x33; m_szSSTMsg[11] =0x39; m_szSSTMsg[12] =0x32; m_szSSTMsg[13] =0x20; m_szSSTMsg[14] =0x33; m_szSSTMsg[15] =0x39; m_szSSTMsg[16] =0x33; m_szSSTMsg[17] =0x20; m_szSSTMsg[18] =0x34; m_szSSTMsg[19] =0x31; m_szSSTMsg[20] =0x32; m_szSSTMsg[21] =0x20; m_szSSTMsg[22] =0x34; m_szSSTMsg[23] =0x31; m_szSSTMsg[24] =0x33; m_szSSTMsg[25] =0x20; m_szSSTMsg[26] =0x34; m_szSSTMsg[27] =0x31; m_szSSTMsg[28] =0x30; m_szSSTMsg[29] =0x20; m_szSSTMsg[30] =0x34; m_szSSTMsg[31] =0x31; m_szSSTMsg[32] =0x32; m_szSSTMsg[33] =0x20; m_szSSTMsg[34] =0x34; m_szSSTMsg[35] =0x31; m_szSSTMsg[36] =0x33; m_szSSTMsg[37] =0x20; m_szSSTMsg[38] =0x34; m_szSSTMsg[39] =0x31; m_szSSTMsg[40] =0x30; m_szSSTMsg[41] =0x20; m_szSSTMsg[42] =0x20; m_szSSTMsg[43] =0x20; m_szSSTMsg[44] =0x36; m_szSSTMsg[45] =0x20; m_szSSTMsg[46] =0x20; m_szSSTMsg[47] =0x20; m_szSSTMsg[48] =0x37; m_szSSTMsg[49] =0x20; m_szSSTMsg[50] =0x20; m_szSSTMsg[51] =0x20; m_szSSTMsg[52] =0x38; m_szSSTMsg[53] =0x20; m_szSSTMsg[54] =0x20; m_szSSTMsg[55] =0x20; m_szSSTMsg[56] =0x32; m_szSSTMsg[57] =0x20; m_szSSTMsg[58] =0x20; m_szSSTMsg[59] =0x20; m_szSSTMsg[60] =0x34; m_szSSTMsg[61] =0x20; m_szSSTMsg[62] =0x20; m_szSSTMsg[63] =0x20; m_szSSTMsg[64] =0x36; m_szSSTMsg[65] =0x20; m_szSSTMsg[66] =0x20; m_szSSTMsg[67] =0x20; m_szSSTMsg[68] =0x36; m_szSSTMsg[69] =0x20; m_szSSTMsg[70] =0x20; m_szSSTMsg[71] =0x20; m_szSSTMsg[72] =0x37; m_szSSTMsg[73] =0x20; m_szSSTMsg[74] =0x20; m_szSSTMsg[75] =0x31; m_szSSTMsg[76] =0x30; m_szSSTMsg[77] =0x20; m_szSSTMsg[78] =0x20; m_szSSTMsg[79] =0x20; m_szSSTMsg[80] =0x20; m_szSSTMsg[81] =0x2B; m_szSSTMsg[82] =0x20; m_szSSTMsg[83] =0x20; m_szSSTMsg[84] =0x31; m_szSSTMsg[85] =0x20; m_szSSTMsg[86] =0x20; m_szSSTMsg[87] =0x20; m_szSSTMsg[88] =0x20; m_szSSTMsg[89] =0x20; m_szSSTMsg[90] =0x20; m_szSSTMsg[91] =0x20; m_szSSTMsg[92] =0x32; m_szSSTMsg[93] =0x20; m_szSSTMsg[94] =0x20; m_szSSTMsg[95] =0x20; m_szSSTMsg[96] =0x31; m_szSSTMsg[97] =0x30; m_szSSTMsg[98] =0x30; m_szSSTMsg[99] =0x30; m_szSSTMsg[100] =0x30; m_szSSTMsg[101] =0x30; m_szSSTMsg[102] =0x30; m_szSSTMsg[103] =0x30; m_szSSTMsg[104] =0x30; m_szSSTMsg[105] =0x30; m_szSSTMsg[106] =0x30; m_szSSTMsg[107] =0x30; m_szSSTMsg[108] =0x30; m_szSSTMsg[109] =0x20; m_szSSTMsg[110] =0x20; m_szSSTMsg[111] =0x39; m_szSSTMsg[112] =0x39; m_szSSTMsg[113] =0x20; m_szSSTMsg[114] =0x34; m_szSSTMsg[115] =0x33; m_szSSTMsg[116] =0x36; m_szSSTMsg[117] =0x20; m_szSSTMsg[118] =0x34; m_szSSTMsg[119] =0x33; m_szSSTMsg[120] =0x37; m_szSSTMsg[121] =0x20; m_szSSTMsg[122] =0x20; m_szSSTMsg[123] =0x32; m_szSSTMsg[124] =0x37; m_szSSTMsg[125] =0x20; m_szSSTMsg[126] =0x20; m_szSSTMsg[127] =0x20; m_szSSTMsg[128] =0x30; m_szSSTMsg[129] =0x20; m_szSSTMsg[130] =0x20; m_szSSTMsg[131] =0x20; m_szSSTMsg[132] =0x30; m_szSSTMsg[133] =0x20; m_szSSTMsg[134] =0x20; m_szSSTMsg[135] =0x20; m_szSSTMsg[136] =0x20; m_szSSTMsg[137] =0x20; m_szSSTMsg[138] =0x20; m_szSSTMsg[139] =0x20; m_szSSTMsg[140] =0x20; m_szSSTMsg[141] =0x20; m_szSSTMsg[142] =0x32; m_szSSTMsg[143] =0x30; m_szSSTMsg[144] =0x32; m_szSSTMsg[145] =0x20; m_szSSTMsg[146] =0x20; m_szSSTMsg[147] =0x20; m_szSSTMsg[148] =0x20; m_szSSTMsg[149] =0x20; m_szSSTMsg[150] =0x20; m_szSSTMsg[151] =0x20; m_szSSTMsg[152] =0x20; m_szSSTMsg[153] =0x20; m_szSSTMsg[154] =0x20; m_szSSTMsg[155] =0x35; m_szSSTMsg[156] =0x30; m_szSSTMsg[157] =0x20; m_szSSTMsg[158] =0x20; m_szSSTMsg[159] =0x20; m_szSSTMsg[160] =0x20; m_szSSTMsg[161] =0x20; m_szSSTMsg[162] =0x20; m_szSSTMsg[163] =0x20; m_szSSTMsg[164] =0x35; m_szSSTMsg[165] =0x2E; m_szSSTMsg[166] =0x2F; m_szSSTMsg[167] =0x2E; m_szSSTMsg[168] =0x30; m_szSSTMsg[169] =0x20; m_szSSTMsg[170] =0x20; m_szSSTMsg[171] =0x20; m_szSSTMsg[172] =0x20; m_szSSTMsg[173] =0x30; m_szSSTMsg[174] =0x30; m_szSSTMsg[175] =0x30; m_szSSTMsg[176] =0x30; m_szSSTMsg[177] =0x30; m_szSSTMsg[178] =0x30; m_szSSTMsg[179] =0x30; m_szSSTMsg[180] =0x30; m_szSSTMsg[181] =0x37; m_szSSTMsg[182] =0x30; m_szSSTMsg[183] =0x30; m_szSSTMsg[184] =0x30; m_szSSTMsg[185] =0x30; m_szSSTMsg[186] =0x30; m_szSSTMsg[187] =0x30; m_szSSTMsg[188] =0x30; m_szSSTMsg[189] =0x30; m_szSSTMsg[190] =0x30; m_szSSTMsg[191] =0x30; m_szSSTMsg[192] =0x30; m_szSSTMsg[193] =0x30; m_szSSTMsg[194] =0x30; m_szSSTMsg[195] =0x30; m_szSSTMsg[196] =0x30; m_szSSTMsg[197] =0x30; m_szSSTMsg[198] =0x30; m_szSSTMsg[199] =0x03; m_szSSTMsg[200] =0x47; char pBuffer[201] = {0}; memcpy(pBuffer,m_szSSTMsg,201); memcpy(m_szSSTMsg,&pBuffer[6],201); }