Click here to Skip to main content
Sign Up to vote bad
good
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

Comments
Krunal Rohit - 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?

2 solutions

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 - 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!
  Permalink  
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..:)

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Prasad_Kulkarni 407
1 Sergey Alexandrovich Kryukov 340
2 _Amy 338
3 Christian Graus 273
4 Rohan Leuva 250
0 Sergey Alexandrovich Kryukov 6,649
1 Prasad_Kulkarni 3,281
2 _Amy 3,065
3 OriginalGriff 2,989
4 CPallini 2,696


Advertise | Privacy | Mobile
Web04 | 2.6.130617.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid