Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
some theory question that i could not understand correctly if any body here to help me here thanks

C#
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)
C#
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
Updated 23-Dec-12 19:50pm
v2
Comments
[no name] 24-Dec-12 1:42am    
what questions ?
Member 9411249 24-Dec-12 1:46am    
question in\\ after coding see
deepakdynamite 24-Dec-12 1:51am    
I don't see any question
Member 9411249 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?

 
Share this answer
 
v2
Comments
Member 9411249 24-Dec-12 1:57am    
thnx
Mehdi Gholam 24-Dec-12 2:06am    
5'ed
ridoy 24-Dec-12 2:12am    
thank you..:)
__TR__ 27-Dec-12 11:13am    
My 5!
ridoy 27-Dec-12 12:31pm    
Thanks..:)
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.
 
Share this answer
 
Comments
ridoy 24-Dec-12 1:59am    
+5
Mehdi Gholam 24-Dec-12 2:06am    
Thanks Ridoy!
Member 9411249 24-Dec-12 2:05am    
Mehdi Gholam thanks alot Sir
__TR__ 27-Dec-12 11:13am    
My 5!
Mehdi Gholam 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)



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