Click here to Skip to main content
15,887,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my SMS application, I read the COM messages with the following function :

C#
void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    if (e.EventType == SerialData.Chars)
    {
        string t = _sp.ReadExisting();
        Debug.WriteLine("message recu : " + t);
    }
}


And I launch command in the COM port with :

C#
public void ExecCommand(string command)
{
    _sp.DiscardOutBuffer(); //_sp is my SerialPort object
    _sp.DiscardInBuffer();

    _sp.Write(command + "\r");
}


I launch the CMTI notifications for the new messages received with :

C#
ExecCommand("AT+CNMI=2,1,0,0,0");


And I receive the notifications (for example) :

C#
+CMTI: "ME",0


Then, I try to read this received message with :

C#
ExecCommand("AT+CMGR=" + pos); // pos = 0


But my only response is
C#
OK


And the `AT+CPMS?` command :

C#
+CPMS: "ME",0,20,"ME",0,20,"ME",0,20


The ME and SM storage are empty... how can I read the messages I receive ?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900