//////////////////////////////////////////////////////////////// // Technomaint 2004 (c) SofTech di Germinara Francesco 2000,2004 // www.germinara.it info@germinara.it // Story: // //////////////////////////////////////////////////////////////// // Checked Version: 6/5/2004 //////////////////////////////////////////////////////////////// // CDlgModemGSM.cpp : implementation file // #include "stdafx.h" #include "Ctechnomaint.h" #include "CDlgModemGSM.h" #include ".\cdlgmodemgsm.h" #include "CFGSmsParser.h" //La Classe Applicazione extern CTechnomaintApp theApp; // CDlgModemGSM dialog IMPLEMENT_DYNAMIC(CDlgModemGSM, CDialog) CDlgModemGSM::CDlgModemGSM(CWnd* pParent /*=NULL*/) : CDialog(CDlgModemGSM::IDD, pParent) , m_strProduttore(_T("")) , m_strModello(_T("")) , m_strCommand(_T("")) , m_strResponse(_T("")) , m_strError(_T("")) , m_strTxBuffer(_T("")) , m_strRxBuffer(_T("")) , m_strOperatore(_T("")) , m_strInfoSeriale(_T("")) { m_bModemOK=FALSE; m_bComOk=FALSE; m_tmCheckSMS=atoi(theApp.bseInfo.m_tmCheckSMS); if(m_tmCheckSMS<=0) m_tmCheckSMS=1000; //Ogni 4 secondi spedisco un messaggio nCntCheckMsg = 10; //Sec / Millisec Timer nFireSMS=nCntCheckMsg; //Initial Setting //***************** MUTEX pMutex=NULL; AcquireMUX(); //***************** MUTEX } CDlgModemGSM::~CDlgModemGSM() { //***************** MUTEX if(pMutex!=NULL) delete pMutex; //***************** MUTEX } void CDlgModemGSM::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_SICOMMCTRL1, m_siComm); DDX_Text(pDX, IDC_EDT_PRODUTTORE, m_strProduttore); DDX_Text(pDX, IDC_EDT_MODELLO, m_strModello); DDX_Text(pDX, IDC_EDT_COMMAND, m_strCommand); DDX_Text(pDX, IDC_EDT_RISPOSTA, m_strResponse); DDX_Text(pDX, IDC_EDT_ERRORE, m_strError); DDX_Text(pDX, IDC_EDT_TX, m_strTxBuffer); DDX_Text(pDX, IDC_EDT_RX, m_strRxBuffer); DDX_Control(pDX, IDC_IND_SEGNALE, m_prgBarIndSegnale); DDX_Text(pDX, IDC_STS_OPERATORE, m_strOperatore); DDX_Text(pDX, IDC_EDT_INFOSER, m_strInfoSeriale); } BEGIN_MESSAGE_MAP(CDlgModemGSM, CDialog) ON_BN_CLICKED(IDC_BTN_INVIA, OnBnClickedBtnInvia) ON_WM_TIMER() END_MESSAGE_MAP() // CDlgModemGSM message handlers void CDlgModemGSM::OnBnClickedBtnInvia() { UpdateData(TRUE); //SendSMS("+393471229860","Chissā se funziona!"); //CString numTel; //CString text; //ReadSMS(numTel,text); //AfxMessageBox("Numero: ["+numTel+"] Testo: ["+text+"]"); //return; CString strResult,strTerm; strTerm.AppendChar(0x0d); m_strCommand.TrimRight(); m_strCommand+=strTerm; SendData(m_strCommand); strResult= ReceiveData(); m_strResponse=strResult; m_strCommand=""; UpdateData(FALSE); } BOOL CDlgModemGSM::OnInitDialog() { CDialog::OnInitDialog(); UpdateData(FALSE); if(theApp.bseInfo.m_strSendSMSNotifyTo!="SI") EndDialog(IDCANCEL); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } BOOL CDlgModemGSM::SendData(CString strCmd){ m_siComm.FlushTxBuffer(); int i=0; BOOL sts=FALSE; i=strCmd.GetLength(); int len=m_siComm.PutString(strCmd); UpdateDataBuffer(strCmd,m_strTxBuffer); if(len != i){ CString msg; msg.Format("Errore in Trasmissione %s Da Tx= %d -> Tx = %d",strCmd,i,len); AfxMessageBox(msg); return TRUE; } return FALSE; } void CDlgModemGSM::CheckResult(CString strResult,CString& strCmdId,CString& strValue,CString& strErr){ int pos=0; CString fit; //Result code is: //CMD \x0d | \x0d \x0a OK \x0d \x0a \x78//Like ATZ //CMD \x0d | \x0d \x0a RESULTDATA \x0d \x0a \x0d \x0a OK \x0d \x0a // CR | | strValue=_T(""); strErr=_T(""); strCmdId=_T(""); pos=strResult.Find(0x0d,pos); if(pos!=-1){ char test[4096]; strcpy(test,strResult); strCmdId=strResult.Mid(0,pos); fit=strResult.Mid(pos+1); strResult=fit; } if(!strCmdId.IsEmpty()){ if(strCmdId.Find("ATZ")!=-1){ strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CMGR=")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CGMM")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CMGF=1")!=-1){ strErr=GetStrVal(strResult); strValue=strErr; return; } if(strCmdId.Find("AT+CMGD=1,4")!=-1){ strErr=GetStrVal(strResult); strValue=strErr; return; } if(strCmdId.Find("AT+COPS?")!=-1){ strValue=GetStrVal(strResult); int posIni=strValue.Find("\""); if(posIni != -1) strValue=strValue.Mid(posIni); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("ATI")!=-1){ strValue=GetStrVal(strResult); strValue+=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+GSN")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CGMR")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CBC")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CSQ")!=-1){ strValue=GetStrVal(strResult); int posIni=strValue.Find(","); if(posIni != -1) strValue=strValue.Mid(posIni+1); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CMGS")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CMGF")!=-1){ strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CMGD=")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CPMS")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } if(strCmdId.Find("AT+CMGL")!=-1){ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } //Check for command error if(strValue.Find("+CMS ERROR") != -1 || strValue.Find("+CME ERROR") != -1){ strErr=strValue; strValue=_T(""); return; } }else{ strValue=GetStrVal(strResult); strErr=GetStrVal(strResult); return; } } CString CDlgModemGSM::GetStrVal(CString& strResult){ int posIni=0; int posFin=0; CString res,fit; posIni=strResult.Find(">",0); if(posIni != -1){ res=">"; strResult=""; } posIni=strResult.Find(0x0a,0); if(posIni != -1){ posFin=strResult.Find(0x0a,posIni+1); if(posFin != -1){ res=strResult.Mid(posIni+1,posFin-posIni-2); fit=strResult.Mid(posFin+1); strResult=fit; } } return res; } void CDlgModemGSM::CloseComPort(){ m_siComm.SetPortOpen(FALSE); //Open serial port m_bComOk=FALSE; m_bModemOK=FALSE; } BOOL CDlgModemGSM::OpenComPort(){ int nComPort,nBitDati,nParity,nVelocita,nBitStop; CString strInfoCfg,m_strOper; BOOL stsPort=FALSE; int sts=0; //Controllo Su Quale Seriale č configurato il modem GSM... CString gsmProtocol="2"; m_strOper=""; sts=theApp.m_pTabSeriali->LoadDatiByProtocol(theApp.bseInfo.m_strIdTerm,gsmProtocol); if(sts==RC_SI){ nComPort=atoi(theApp.m_pTabSeriali->m_porta); strInfoCfg.Format("Com%d, ",nComPort+1); m_strOper+="Porta di comunicazione "+strInfoCfg; nParity=atoi(theApp.m_pTabSeriali->m_parity); if(nParity==0)strInfoCfg="Nessuna Paritā, "; if(nParity==1)strInfoCfg="Paritā Pari, "; if(nParity==2)strInfoCfg="Paritā Dispari, "; m_strOper+=strInfoCfg; switch(atoi(theApp.m_pTabSeriali->m_bit)){ case 0: nBitDati=WordLen7; strInfoCfg.Format("BitDati 7, "); break; case 1: nBitDati=WordLen8; strInfoCfg.Format("BitDati 8, "); break; } m_strOper+=strInfoCfg; nBitStop=atoi(theApp.m_pTabSeriali->m_stop); strInfoCfg.Format("BitStop %d, ",nBitStop+1); m_strOper+=strInfoCfg; switch(atoi(theApp.m_pTabSeriali->m_baud)){ case 0: nVelocita=Baud1200; strInfoCfg="Velocitā 1200 "; break; case 1: nVelocita=Baud2400; strInfoCfg="Velocitā 2400 "; break; case 2: nVelocita=Baud4800; strInfoCfg="Velocitā 4800 "; break; case 3: nVelocita=Baud9600; strInfoCfg="Velocitā 9600 "; break; case 4: nVelocita=Baud192K; strInfoCfg="Velocitā 19200 "; break; case 5: nVelocita=Baud384K; strInfoCfg="Velocitā 38400 "; break; case 6: nVelocita=Baud1152K; strInfoCfg="Velocitā 115200 "; break; } m_strOper+=strInfoCfg; //Ok, inizializzo... m_siComm.SetPortNumber(nComPort); m_siComm.SetBaudRate(nVelocita); m_siComm.SetParity(nParity); m_siComm.SetWordLength(nBitDati); m_siComm.SetStopBits(nBitStop); m_siComm.SetCardType(CardWinApi); m_siComm.SetCommTicks(CommTickMilliSecond); m_siComm.SetDeltaCTS(TRUE); m_siComm.SetDeltaDSR(TRUE); m_siComm.SetPortOpen(TRUE); } stsPort=m_siComm.GetPortOpen(); if(stsPort==FALSE){ m_strOper+="ERRORE: Impossibile Inizializzare la Porta Seriale."; theApp.WrtLogOper(m_strOper,theApp.bseInfo.m_strCodUte); m_bComOk=FALSE; }else{ m_strOper+=". Ok,seriale inizializzata."; theApp.WrtLogOper(m_strOper,theApp.bseInfo.m_strCodUte); m_bComOk=TRUE; m_siComm.FlushRxBuffer(); m_siComm.FlushTxBuffer(); } m_strInfoSeriale=m_strOper; return stsPort; } BOOL CDlgModemGSM::SendSimpleCmdToPhone(CString cmd,CString& result){ CString strCommand,strResult,strValue,strErr,strCommandId; int sts=0; int nIndex=0; strCommand=m_GsmAtCommands.GetCmd(cmd,nIndex); sts=SendData(strCommand); if(!sts){ strResult= ReceiveData(); CheckResult(strResult,strCommandId,strValue,strErr); } if(strErr=="OK"){ result=strValue; return TRUE; } return FALSE; } CString CDlgModemGSM::ReceiveData(){ CString result; CString command; CString dati; CString crlf; CString strAltro; result=""; command=rxGetCommand(); //Leggo il comando... crlf=rxGetCRLF(); //Leggo CR/LF dati=rxGetData(); //Leggo Dati BSTR bstr; bstr=strAltro.AllocSysString(); m_siComm.GetString(&bstr); strAltro = bstr; ::SysFreeString(bstr); result=command+crlf+dati+strAltro; UpdateDataBuffer(result,m_strRxBuffer); //m_siComm.FlushRxBuffer(); return result; } //Leggo il comando... CString CDlgModemGSM::rxGetCommand(){ CString strCommand; strCommand=""; short nChar=0x00; long nBytes=0L; int nTry=2; REDO: CheckDataInRX(); if(!m_bTimeOut){ //Ok, leggo dati... for(;;){ nBytes = m_siComm.GetByte(&nChar); if(nBytes==1){ strCommand.AppendChar((char)nChar); if(nChar==0x0d){ break; } }else{ nTry--; if(nTry) goto REDO; else break; } } } return strCommand; } //Leggo Dati CString CDlgModemGSM::rxGetData(){ CString strData; short nChar=0x00; strData=""; long nBytes=0L; int nTry=2; REDO: CheckDataInRX(); if(!m_bTimeOut){ //Ok, leggo dati... for(;;){ nBytes = m_siComm.GetByte(&nChar); if(nBytes==1){ strData.AppendChar((char)nChar); if(nChar==0x0a){ break; } }else{ nTry--; if(nTry) goto REDO; else break; } } } return strData; } //Leggo CR/LF CString CDlgModemGSM::rxGetCRLF(){ CString strData; short nChar=0x00; strData=""; long nBytes=0L; int nTry=2; REDO: CheckDataInRX(); if(!m_bTimeOut){ //Ok, leggo dati... for(;;){ nBytes = m_siComm.GetByte(&nChar); if(nBytes==1){ strData.AppendChar((char)nChar); if(nChar==0x0a){ break; } }else{ nTry--; if(nTry) goto REDO; else break; } } } return strData; } //Riceve Dati CString CDlgModemGSM::NewReceiveData(){ CString strResult(""); long nBytes=0L; int nRetry=10; BSTR bstr; BOOL bRead=FALSE; CString strCommand,strCommandEmpty; Sleep(300); for(;;){ nBytes = m_siComm.GetBytesInReceiveBuffer(); if( nBytes >= 2L) { bRead=TRUE; break; }else{ nRetry--; if(nRetry == 0){ //MessageBox("Time-Out!"); bRead=FALSE; break; } Sleep(100L); } } if(bRead){ Sleep(100); bstr=strResult.AllocSysString(); nBytes = m_siComm.GetString(&bstr); if( nBytes > 0L) { strResult = bstr; ::SysFreeString(bstr); //MessageBox(strResult); } } UpdateDataBuffer(strResult,m_strRxBuffer); return strResult; } void CDlgModemGSM::UpdateDataBuffer(CString str, CString& strBuffer){ int len=str.GetLength(); unsigned char ch; CString hex; strBuffer=""; for(int nIndex=0; nIndex < len; nIndex++){ ch=str.GetAt(nIndex); hex.Format("%02x ",ch); strBuffer+=hex; } UpdateData(FALSE); UpdateWindow(); } BOOL CDlgModemGSM::CheckDataInRX(){ long int nBytes=0; int nRetry=50; BOOL bRead=FALSE; Sleep(100); for(;;){ nBytes = m_siComm.GetBytesInReceiveBuffer(); if( nBytes > 0L) { bRead=TRUE; m_bTimeOut=FALSE; break; }else{ nRetry--; if(nRetry == 0){ bRead=FALSE; m_bTimeOut=TRUE; //AfxMessageBox("TimeOut"); break; } Sleep(100L); } } return bRead; } void CDlgModemGSM::InitModem() { int sts=0; int nIndex=0; CString msgErr; CString strCommand,strResult,strErr,strCommandId,strBatInfo,strRev,strSN,strPIN,strTest; strCommand=m_GsmAtCommands.GetCmd("Reset",nIndex); //IdentifyModem sts=SendData(strCommand); strResult= ReceiveData(); CheckResult(strResult,strCommandId,strTest,strErr); if(strErr!="OK"){ msgErr.Format("Errore: Impossibile comunicare con il Modem GSM\nVerificare il collegamento e l'alimentazione del Modem."); theApp.bseInfo.m_strSendSMSNotifyTo="NO"; AfxMessageBox(msgErr); return; } strCommand=m_GsmAtCommands.GetCmd("IdentifyModem",nIndex); // sts=SendData(strCommand); if(sts){ msgErr.Format("Errore(Send): Impossibile comunicare con il Modem GSM"); }else{ strResult= ReceiveData(); m_strResponse=strResult; CheckResult(strResult,strCommandId,m_strProduttore,strErr); if(strErr!="OK"){ m_strError=strErr+" ("+strResult+")"; }else{ m_strError=""; m_bModemOK=TRUE; SendSimpleCmdToPhone("GetRevisionId",strRev); SendSimpleCmdToPhone("GetSerialNumber",strSN); m_strModello.Format("S/N: %s Rev.: %s",strSN,strRev); strCommand=m_GsmAtCommands.GetCmd("SendPIN",nIndex); CGsmAtCommand *atCommand; atCommand=m_GsmAtCommands.GetPtrCmd(nIndex); if(atCommand!=NULL){ atCommand->SetParm1(theApp.bseInfo.m_strPIN); strCommand=m_GsmAtCommands.GetCmd(nIndex); sts=SendData(strCommand); if(sts){ msgErr.Format("Errore(Send): Impossibile comunicare con il Modem GSM"); AfxMessageBox(msgErr); }else{ strResult= ReceiveData(); m_strResponse=strResult; CheckResult(strResult,strCommandId,strPIN,strErr); if(strErr!="OK"){ m_strError=strErr+" ("+strResult+")"; }else{ m_strError=""; } //Leggo Operatore SendSimpleCmdToPhone("SetFormatOperatorName",m_strOperatore); SendSimpleCmdToPhone("ReadOperatorName",m_strOperatore); //Segnale CString signal; int nSignal=0,nPos=0; m_prgBarIndSegnale.SetRange(0,10); m_prgBarIndSegnale.SetStep(1); SendSimpleCmdToPhone("GetSignal",signal); nSignal=atoi(signal); switch(nSignal){ case 0: nPos=1; break; // -113 dBm case 1: nPos=3; break; // -111 dBm case 30: nPos=7; break; // -109 a -53 dBm case 31: nPos=10; break; // -51 o piu dBm case 99: nPos=0; break; // Sconosciuto } m_prgBarIndSegnale.SetPos(nPos); } SendSimpleCmdToPhone("SetMessageFormatText",m_strResponse); } } } UpdateData(FALSE); } void CDlgModemGSM::StartUp(){ if(theApp.bseInfo.m_strSendSMSNotifyTo=="SI"){ if(!m_bComOk){ OpenComPort(); m_GsmAtCommands.SetupCommands(); if(m_bComOk==TRUE){ InitModem(); if(theApp.bseInfo.m_strSendSMSNotifyTo=="SI"){ SetTimer(IDTM_CHECK_SMS,m_tmCheckSMS,NULL); } } } } } void CDlgModemGSM::OnOK() { CDialog::OnOK(); } void CDlgModemGSM::OnCancel() { CDialog::OnCancel(); } void CDlgModemGSM::SendSMS(CString numTel,CString text){ CString strResult,strTermNum,strTermText,strCommand; text.TrimRight(); if(text.GetLength()>160) text=text.Mid(0,160); strTermNum.AppendChar(0x0d); //CR strTermText.AppendChar(0x1a); //^Z strCommand="AT+CMGS="; strCommand+=numTel+strTermNum+text+strTermText+strTermNum; SendData(strCommand); strResult= ReceiveData(); m_strResponse=strResult; } void CDlgModemGSM::ReadSMS(CString& numTel,CString& text){ CString strResult,strTerm,strCommand; numTel=""; text=""; REDO: strTerm.AppendChar(0x0d); //CR strCommand="AT+CMGR=1"; strCommand+=strTerm; SendData(strCommand); strResult= ReceiveData(); if(strResult.Find("+CMTI:")!=-1){ Sleep(100); goto REDO; } m_strResponse=strResult; UpdateData(FALSE); if(m_strResponse.Find("ERROR")!=-1) return; int posIni=0,posFin=0; posIni=strResult.Find(","); if(posIni!=-1){ posIni+=2; posFin=strResult.Find(",",posIni); if(posFin!=-1){ numTel=strResult.Mid(posIni,posFin-posIni-1); } } posIni=strResult.Find("\n",posFin); if(posIni!=-1){ posIni+=1; posFin=strResult.Find("\n",posIni); if(posFin!=-1){ text=strResult.Mid(posIni,posFin-posIni-1);; } } int nMaxRetry=10; RETRY: SendSimpleCmdToPhone("DeleteAllMessage",m_strResponse); //AfxMessageBox("SendSimpleCmdToPhone - Cancellato ? (" +m_strResponse+")"); if(m_strResponse.Find("CMGR") != -1){ nMaxRetry--; if(nMaxRetry){ Sleep(100); goto RETRY; }else{ //AfxMessageBox("Impossibile cancellare messaggio SMS!" +m_strResponse); } } UpdateData(FALSE); } void CDlgModemGSM::OnTimer(UINT nIDEvent) { if(nIDEvent == IDTM_CHECK_SMS){ KillTimer(IDTM_CHECK_SMS); //***************** MUTEX if(pMutex != NULL) pMutex->Wait(INFINITE); else{ AfxMessageBox("Errore:Impossibile gestire Mutex in CDlgModemGSM::OnTimer()"); return; } //***************** MUTEX //Controllo se ci sono messaggi da spedire ... nFireSMS--; if(nFireSMS == 0){ nFireSMS=nCntCheckMsg; int sts=0; CString idMsg; CString msgType; CString msgSts; CString msg; CString idUser; CString msgData; CString msgOra; CString numTel; sts=theApp.m_pTabMsgToSend->LoadFirst(); if(sts==RC_SI){ idMsg=theApp.m_pTabMsgToSend->m_idMsg; msg=theApp.m_pTabMsgToSend->m_textMsg.TrimRight(); numTel=theApp.m_pTabMsgToSend->m_sendTo.TrimRight(); msgData=theApp.m_pTabMsgToSend->m_data; msgOra=theApp.m_pTabMsgToSend->m_ora; idUser=theApp.m_pTabMsgToSend->m_strUserName; if(!numTel.IsEmpty()){ msgType="S"; SendSMS(numTel,msg); if(m_strResponse.Find("OK")!=-1) msgSts="0"; //OK else msgSts="1"; //ERRORE sts=theApp.m_pTabMsgToSend->DeleteRec(idMsg); int nTotMsgRicevuti=0; CString msgId; sts=theApp.m_pTabStoricoMsg->LoadLastSend(msgType); if(sts==RC_SI){ nTotMsgRicevuti=atoi(theApp.m_pTabStoricoMsg->m_idMSG.Mid(4))+1; }else nTotMsgRicevuti=1; msgId.Format("%4s%0.6ld",theApp.bseInfo.m_strIdTerm,nTotMsgRicevuti); theApp.m_pTabStoricoMsg->Insert(msgId,msgType,msg,msgSts,numTel,msgData,msgOra,idUser,theApp.bseInfo.m_strIdTerm); } } }else{ //Controllo se č arrivato qualcosa qui... CString numTel,msgText; ReadSMS(numTel,msgText); numTel.TrimRight(); msgText.TrimRight(); if(!numTel.IsEmpty() && !msgText.IsEmpty()){ int nTotMsgRicevuti=0; int sts=0; CString msgId; CString msgType="R"; //Received CString msgSts="0"; //OK CString idUser; CBseData bseData; bseData.Oggi(); bseData.SetDataAAAAMMGG(); sts=theApp.m_pTabStoricoMsg->LoadLastSend(msgType); if(sts==RC_SI){ nTotMsgRicevuti=atoi(theApp.m_pTabStoricoMsg->m_idMSG.Mid(4))+1; }else nTotMsgRicevuti=1; msgId.Format("%4s%0.6ld",theApp.bseInfo.m_strIdTerm,nTotMsgRicevuti); sts=theApp.m_pTabCfgInvioMsg->FindByNumber(numTel); if(sts==RC_SI) idUser=theApp.m_pTabCfgInvioMsg->m_addrmailto.TrimRight(); else idUser="----"; theApp.m_pTabStoricoMsg->Insert(msgId,msgType,msgText,msgSts,numTel,bseData.data,bseData.ora,idUser,theApp.bseInfo.m_strIdTerm); theApp.m_SendResponseTO=numTel; theApp.m_ParseMsgText=msgText; if(!theApp.m_SendResponseTO.IsEmpty() && !theApp.m_ParseMsgText.IsEmpty()){ CFGSmsParser myParser; myParser.SetStrToParser(theApp.m_ParseMsgText); myParser.Parser(); //TRUE for Debug mode } } } //***************** MUTEX pMutex->Release(); //***************** MUTEX SetTimer(IDTM_CHECK_SMS,m_tmCheckSMS,NULL); } } void CDlgModemGSM::AcquireMUX(){ //Creo oggetto MUTEX e provo ad acquisire il MUX if(pMutex==NULL){ pMutex=new CMclMutex("TECHNOMAINT_MUTEX"); ASSERT(pMutex!=NULL); //AfxMessageBox("MUX_ Creato"); } if(pMutex!=NULL){ DWORD sts=pMutex->Status(); //Controllo se esiste il MUX indicato //Se ha dato errore ... non esiste, quindi lo crea nel S.O. ... if(sts!=0){ pMutex=new CMclMutex(FALSE, "TECHNOMAINT_MUTEX"); ASSERT(pMutex!=NULL); //CString strErr; //strErr.Format("MUX_Acquisito...: Stato: %0x",sts); //AfxMessageBox(strErr); } } }