2011-07-06 4 views
1

나는 lightwave 형식의 usb gsm 모뎀을 가지고 있습니다. 이 코드는 C#에서 수신, 보내기, 삭제 및이 모뎀에서 SMS 메시지를 읽을 수 있지만 새 메시지가 모뎀에 도착하면 새 메시지를받을 때 발생해야하는 이벤트가 발생하지 않습니다. 나는 그 문제가 무엇인지 모른다. 그러나, 나는 시뮬레이션 후받은에서이 메시지를 읽을 수 있지만 메시지는 코드의이 부분에 도착했을 때 나는 제기받은 메시지의 이벤트를 원하는 :C에서 GSM 모뎀 프로그래밍

private void Form1_Load(object sender, EventArgs e) 
{ 
    int port = GsmCommMain.DefaultPortNumber; 
    int baudRate = 9600; // We Set 9600 as our Default Baud Rate 
    int timeout = GsmCommMain.DefaultTimeout; 

    dlg = new frmConnection(); 

    dlg.StartPosition = FormStartPosition.CenterScreen; 
    dlg.SetData(port, baudRate, timeout); 
    if (dlg.ShowDialog(this) == DialogResult.OK) 
    { 
     dlg.GetData(out port, out baudRate, out timeout); 
     CommSetting.Comm_Port = port; 
     CommSetting.Comm_BaudRate = baudRate; 
     CommSetting.Comm_TimeOut = timeout; 
    } 
    else 
    { 
     Close(); 
     return; 
    } 
    Cursor.Current = Cursors.WaitCursor; 
    CommSetting.comm = new GsmCommMain(port, baudRate, timeout); 
    Cursor.Current = Cursors.Default; 
    CommSetting.comm.PhoneConnected += new EventHandler(comm_PhoneConnected); 
    CommSetting.comm.MessageReceived += new MessageReceivedEventHandler(comm_MessageReceived); 
    //.... 
} 

는이 이벤트가 발생되지 않습니다을 때 메시지

CommSetting.comm.MessageReceived += new MessageReceivedEventHandler(comm_MessageReceived); 

codeproject.com에 설립 된이 코드는 C#에서 찾을 수 있습니다.

+0

당신은 설정하지 않은 경우 Handshake 속성을 사용하면 하드웨어 핸드 셰이크 신호를 직접 설정해야합니다. RtsEnable 및 DtrEnable 속성을 true로 설정하십시오. –

+0

GSMcomm을 사용하는 대신 데이터를 수신하고 그에 따라 의사 결정을 내리기 위해 자체 처리기를 사용해야합니다. –

답변

0

+ CMTI

는 GSM/GPRS 모뎀 또는 휴대 전화 용도 + CMTI는 새로운 SMS 메시지를 수신 한 컴퓨터/PC 및이 저장되는 메모리 위치를 통지한다.

if(indata.Contains("+CMTI"))//Alert for message recived read message from the loacation 

가 loaction를 확인하고 그 선택은 특정 시뮬레이션 위치에서 메시지를 읽을 이벤트에서 스레드가 DataReceivedHandler을 처리 실행에 계속.

심판 당신이 당신의 포트, 전송 속도 및 시간 제한이 유효한지 확인해야 모든 http://www.developershome.com/sms/resultCodes3.asp

심판 http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.datareceived.aspx

0

첫째. 그리고 나서 통신이 제대로 초기화되었는지 확인하십시오. 핸들러는 다음과 같은 코드 만 ......

comm.MessageReceived += comm_MessageReceived; 

를 작성하고 다음 코드에 의해 통신을 초기화 추가

.......

comm = new GsmCommMain(port, baudRate, timeout);