2014-11-10 5 views
0


AT 명령 응답을 받고 싶습니다.
내 GSM 모뎀에서 SMS를 읽으 려합니다.
C#을 사용하여 GSM 모뎀에 AT 명령을 보내고 응답을 받으십시오.

Google에서 코드를 작성했지만이 스크립트는 AT 명령을 보내지 만 응답을받지 못합니다.

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.IO.Ports; 
using System.Linq; 
using System.Text; 
using System.Threading; 
using System.Threading.Tasks; 
using System.Windows.Forms; 

namespace CSharp_SMS 
{ 
    public partial class Form_SMS_Sender : Form 
    { 
     private SerialPort _serialPort; 
     public Form_SMS_Sender() 
     { 
      InitializeComponent(); 
     } 

     private void buttonSend_Click(object sender, EventArgs e) 
     { 
      string number = textBoxNumber.Text; 
      string message = textBoxMessage.Text; 

      _serialPort = new SerialPort("COM6", 115200); 

      Thread.Sleep(1000); 

      _serialPort.Open(); 

      Thread.Sleep(1000); 

      _serialPort.WriteLine("AT" + "\r"); 



      Thread.Sleep(1000); 

      string status = _serialPort.ReadLine(); 

      labelStatus.Text = "|-"+ status + "-|"; 

      _serialPort.Close(); 
     } 
    } 
} 


이 코드는 작동되지 않습니다
이 내 코드입니다.
응답을받지 못하지만 AT 명령을 보냅니다.
응답받는 방법은 무엇입니까?
감사

ECHO 모뎀에 꺼져 있으면
+0

? 터미널 에뮬레이터를 사용하여 모뎀 설정을 확인 했습니까? – iheanyi

+0

휴대폰 번호와 텍스트를 쓰고 GSM 모뎀에서 SMS를받습니다. –

+0

좋아, 그럼 작품을 보내고 알아. 터미널 에뮬레이터를 사용하여 GSM 모뎀 응답을 확인 했습니까? – iheanyi

답변

1

, 당신은 당신의 AT 명령에 대한 응답을받지 않습니다.

에코를 확인을 전송하여 사용할 수 ATE1 먼저 보내기가 작동하는지 어떻게 알

Thread.Sleep(1000); 
_serialPort.WriteLine("ATE1" + "\r"); 

Thread.Sleep(1000); 
_serialPort.WriteLine("AT" + "\r"); 
2
 celu.RtsEnable = true; 
     celu.DtrEnable = true; 
     celu.WriteBufferSize = 3000; 
     celu.BaudRate = 9600; 
     celu.PortName = "COM26"; // You have check what port your phone is using here, and replace it 
     celu.Open(); 
     //string cmd = "AT+CLIP=1"; // Here you put your AT command 
     //celu.WriteLine(cmd); 
     celu.WriteLine ("AT+CLIP=1"+"\r"); 

     Thread.Sleep(500); 
     //celu.Open(); 

     string ss = celu.ReadExisting();