About sending and receiving message


#1

Hello! I am developing an application with the modems Itegno WM10801+. I have some problem with it:

  1. I am unable to send and to receive characters which are not ASCII (I develop it for French speakers).

  2. When I send messages with it (using AT command),it add to my original message a code that I don’t expect.

Let me explain more: For example I send “hello man” . The message which is received is “AT+CMGR=19 hello man”

I am using C# under Microsoft Visual studio (.net framework) and I use AT commands.

Any one to help me please?

Thank you in advance


#2

This is something, problem in your code.
If you could send the code, i may help you out


#3

Hello.Thank you for answering.Here is the code in c#:

//Initialisation of the port
public void initialise()
{
Publique.cm.PortName = “COM8”;
Publique.cm.BaudRate = 115200;
Publique.cm.RtsEnable = true;
Publique.cm.DtrEnable = true;
Publique.cm.DataBits = 8;
Publique.cm.Encoding = Encoding.Default ;
string cmd = “AT+CMGF=1\r”;
try
{
Publique.cm.Open();
Publique.cm.Write(cmd);
Thread.Sleep(1000);
catch
{
Console.Writeline(“Error of com port”
}
}

bool sendsms(string mess,string dest)
{
try
{

            string cmd = "AT+CMGS=" + dest + "\r";
            Publique.cm.Write(cmd);
            Thread.Sleep(400);
            Publique.cm.DiscardOutBuffer();
            Publique.cm.DiscardInBuffer();
            Thread.Sleep(50);
            cm.Write(mes + '\x001a');
            Thread.Sleep(1000);
          
        }
        catch (Exception ex)
        {
                return false;
        }

        return true;

}

string receive()
{

        try
        {
           for (int i = 0; i <= 20; i++)
            {
                try
                {
                   
                    Publique.cm.DiscardInBuffer();
                    string read = "AT+CMGR=" + i.ToString() + "\r";
                    Publique.cm.Write(read);
                    Thread.Sleep(400);
                    string message = Publique.cm.ReadExisting();
                    if (message.IndexOf("ERROR") >= 0 || message.Length == 0 || message.IndexOf("CMGD") > 0) continue;
                    return message;                        
                }
                catch (Exception ex)
                {
                     continue;
                }
                
            }


      
           
        }
        catch (Exception ex)
        {
         Console.Writeline("Reception error")
        }

}


#4

Hi
my suggestion is to after you submit the message to send using AT commands check for the response
OK or Error message from modem. also at+cmgs gives you receipt number.
intraduce some handshaking or query the receive buffer.

hope this will help you
Asiri


#5

Hai friend,

I have seen your code. My suggestion is to use events like on serialport in vb6, we have a event in .net 2.0
try using system.io
you will find the event.
there you can handle, no need to write delays and all.


#6

Hello Shivaprasad.I see what you are meaning.I checked events of the serialport.Only events about reception are availabe.But my problem about reception is when some body sends a non ascii caracter( for exemple é , à,ù).The caracter is replaced by ‘?’ or someting else.

About sending,can you sugest something?

Waasiri,I think you have a good Idea about my problem on sending.But How can I read the results of an AT command?

Thanks to you all.I am happy to meet persons who undestand what I am asking .


#7

Hai is the baud rate problem. simple run the command AT+IPR=0 and the same code.