Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
some theory question that i could not understand correctly if any body here to help me here thanks
 
class SmsClass
   {
       SerialPort serialPort;
       public SmsClass(string comPort)
       {
           this.serialPort = new SerialPort();
           this.serialPort.PortName = comPort;
           this.serialPort.BaudRate = 9600; //what is BaudRate and why we use 9600 not other?
           this.serialPort.Parity = Parity.None;//if parity is for error checking then why we set Parity.None? 
           this.serialPort.DataBits = 8;// what is Databits?
           this.serialPort.StopBits = StopBits.One;
           this.serialPort.Handshake = Handshake.RequestToSend;// what is Handshake do?
           this.serialPort.DtrEnable = true;
           this.serialPort.RtsEnable = true;
           this.serialPort.NewLine = System.Environment.NewLine;
       }
       public bool sendSms(string cellNo, string sms)
       {
           string messages = null;
           messages = sms;
           if (this.serialPort.IsOpen == true)
           {
               try
               {
                   this.serialPort.WriteLine("AT" + (char)(13));// why we set char 13?
                   Thread.Sleep(4);
                   this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));//also here char 13?
                   Thread.Sleep(5);
                   this.serialPort.WriteLine("AT+CMGS=\"" + cellNo + "\"");
                   Thread.Sleep(10);
                   this.serialPort.WriteLine(">" + messages + (char)(26));//why we set char 26 here? 
               }
               catch (Exception ex)
               {
                   MessageBox.Show(ex.Source);
               }
               return true;
           }
           else
               return false;
       }
 

Questions
1)What is BaudRate and why we use 9600 not other?
2)If parity is for error checking then why we set Parity.None?
3)What is Databits?
4)What is Handshake do?
5)
this.serialPort.WriteLine("AT" + (char)(13));// why we set char 13?
 
6)this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));//also here char 13?
7)this.serialPort.WriteLine(">" + messages + (char)(26));//why we set char 26 here?
Posted 23-Dec-12 19:41pm
Edited 23-Dec-12 19:50pm
v2
Comments
Krunal Rohit at 24-Dec-12 1:42am
   
what questions ?
Member 9411249 at 24-Dec-12 1:46am
   
question in\\ after coding see
deepakdynamite at 24-Dec-12 1:51am
   
I don't see any question
Member 9411249 at 24-Dec-12 1:57am
   
1)What is BaudRate and why we use 9600 not other?
2)If parity is for error checking then why we set Parity.None?
3)What is Databits?
4)What is Handshake do?
5)
Collapse | Copy Code
this.serialPort.WriteLine("AT" + (char)(13));// why we set char 13?

6)this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));//also here char 13?
7)this.serialPort.WriteLine(">" + messages + (char)(26));//why we set char 26 here?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Comments
Member 9411249 at 24-Dec-12 1:57am
   
thnx
Mehdi Gholam at 24-Dec-12 2:06am
   
5'ed
ridoy at 24-Dec-12 2:12am
   
thank you..:)
__TR__ at 27-Dec-12 11:13am
   
My 5!
ridoy at 27-Dec-12 12:31pm
   
Thanks..:)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

1) Baud rate is the data transfer rate for the com port 9600 bits/sec this is the default for most devices which works correctly (you can increase it but you might get errors).
 
2) Parity is for error checking the data and the default is none for most devices which sends less data over the wirre.
 
3) Databits are the number of bits in the stream which can be 8 for binary transfer or 7 for text transfer.
 
4) Handshake is a protocol between the sender and receiver for determining the data transfer correctness.

5,6) char 13 = the return key code equivalent to pressing the enter key.
 
7) char 26 = ctrl+z key which terminates the connection.
  Permalink  
Comments
ridoy at 24-Dec-12 1:59am
   
+5
Mehdi Gholam at 24-Dec-12 2:06am
   
Thanks Ridoy!
Member 9411249 at 24-Dec-12 2:05am
   
Mehdi Gholam thanks alot Sir
__TR__ at 27-Dec-12 11:13am
   
My 5!
Mehdi Gholam at 28-Dec-12 2:10am
   
Thanks!

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

  Print Answers RSS
0 CHill60 330
1 OriginalGriff 285
2 Sergey Alexandrovich Kryukov 274
3 BillWoodruff 170
4 Aescleal 140


Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100