2013-07-14 6 views
-1

다음 코드SMS : AT 명령에 오류가 있습니까?

#pragma once 
using namespace System::IO::Ports; 
using namespace System::Text::RegularExpressions; 
using namespace System::Collections::Generic; 

    ref class SMS 
    { 
    public: 
     SMS(void); 
     void sendMessage(); 

    private: 
     System::IO::Ports::SerialPort ^port; 
    }; 

봐 내가 동글에 액세스하여 SMS를 보내려고하고

#include "StdAfx.h" 
#include "SMS.h" 


SMS::SMS(void) 
{ 
    //Initialize the Serial Port 
    port = gcnew System::IO::Ports::SerialPort(); 
    port->PortName = "COM12"; 
    port->BaudRate = 9600; 
    port->Parity = Parity::None; 
    port->DataBits = 8; 
    port->StopBits = StopBits::One; 
    port->Handshake = Handshake::RequestToSend; 
    port->DtrEnable = true; 
    port->RtsEnable = true; 
    port->NewLine = System::Environment::NewLine; 

    if(!port->IsOpen) 
    { 
     port->Open(); 
    } 

    //Set message format 
    port->WriteLine("AT+CMGF=1"); 

    //Turn off echo 
    port->WriteLine("ATE0"); 

    //Set memory configurations 
    port->WriteLine("AT+CPMS=\"ME\",\"ME\",\"ME\""); 





} 


//This method will send the SMS 

void SMS::sendMessage() 
{ 
    if(!port->IsOpen) 
    { 
     port->Open(); 
    } 

    port->WriteLine("AT+CMGS=\"012121212\""); 
    port->WriteLine("Test Message From C#"); 
    port->WriteLine(System::Convert::ToString((char)(26))); 

    port->Close(); 


} 

cpp가 파일을 가지고하시기 바랍니다. 포트가 정확하고 동글도 괜찮 았는데 몇 시간 전에 친구의 코드에 응답했기 때문에 괜찮습니다. 여기서 내가 뭘 잘못하고 있니? C++/CLI로 잘못된 것을 수행 했습니까? AT 명령? 도와주세요!

답변

0

각 AT 명령 뒤에 "CR" "LF"(캐리지 리턴 및 줄 바꿈 문자)를 추가해보십시오. 일부 GSM 동글 (SIM900과 같은)은 작동하기 위해 필요합니다. 나는 포인터가 파일 정보를 버퍼 // 포인터가 LPOFSTRUCT lpReOpenBuff을 파일 이름 // 이

HFILE OpenFile ( LPCSTR lpFileName를 사용하여 선호 ..이는 Win32에 대한 경우 감사

0

도움이되기를 바랍니다
UINT uStyle // 액션 및 속성 ); 다른 이벤트와

, ...

명령 기능 AT 모뎀과 SMS 게이트웨이를 사용하는 경우, 그 직접 읽기 괜찮 및 COM 포트 U는 휴대 전화를 사용하는 경우,이 많은이 작동하지 않습니다 쓰기. 예 노키아 6070, 3100 모델 그룹

하이퍼 터미널을 사용하여 가장 잘 테스트합니다.

나는

https://sites.google.com/site/xpressdms/rosegarden

응원을 위해 CBuildre6을 사용했다.

관련 문제