Help reading sms at commands

This is a discussion on Help reading sms at commands within the C# Programming forums, part of the General Programming Boards category; Reading and sending works fine on hyperterminal. What i want is to read sms and output it on a text ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    1

    Help reading sms at commands

    Reading and sending works fine on hyperterminal. What i want is to read sms and output it on a text box. I wrote this code, am I doing it right? I am not that experienced with c#. I think the correct method is use event handler but how to do it? Thanks..


    Code:
     //read sms
            private void button3_Click(object sender, EventArgs e)
            {
    
    
                if (this.serialPort1.IsOpen)
                {
    
                  serialPort1.BaseStream.Flush();
    
                  string a = "sm"; string b = "all";
                  //this.serialPort1.Write("AT+CPMS=\"" + a + "\"\r\n");
                // this.serialPort1.Write("AT+CPMS=SM\r\n");
     
                     // this.serialPort1.Write("AT+CMGF=1\r\n");
                     //this.serialPort1.Write("AT+CSCS=\"PCCP437\"");
                     //this.serialPort1.Write("AT+CPMS=\"" + a + "\"\r\n");
                     this.serialPort1.Write("AT+CMGR=2\r");
            
    
    
                  //this.serialPort1.Write("AT+CMGL=\"" + b + "\"\r\n");
    
    
               textBox5.Text = this.serialPort1.ReadExisting();
    
    
                  
              MessageBox.Show("\nMessage Was Read\n", "Information");
                   
    
                }
    
               else
               {
                    MessageBox.Show("\nSerial Port Is Not Open\n", " ERROR ");
               }
    
    
    
            }

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Hello and welcome!

    Is the port open? Is there any output on the text box?
    I say make two buttons. One to write and one to read. Then try writing and reading and post what you actually get.

    What you should note is that by the time you call ReadExisting() maybe the AT command response hasn't been available yet.
    So a second button would allow you to add necessary delay. Not sure if the AT command gives back a nicely formatted String (with the right enconding).
    If not, you can use the plain Read() method.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. which commands
    By munna_dude in forum C Programming
    Replies: 1
    Last Post: 12-26-2006, 02:40 AM
  2. MS-DOS commands...
    By MipZhaP in forum C++ Programming
    Replies: 9
    Last Post: 08-19-2004, 03:52 AM
  3. DOS Commands
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 05-13-2002, 03:40 AM
  4. DOS Commands
    By Zuul in forum C++ Programming
    Replies: 11
    Last Post: 01-04-2002, 03:41 PM
  5. dos commands in c++
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-18-2001, 11:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21