Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
AnswerRe: About downloading file Pin
N a v a n e e t h15-Jan-09 19:03
N a v a n e e t h15-Jan-09 19:03 
AnswerRe: About downloading file Pin
ashok_rgm20-Jan-09 0:01
ashok_rgm20-Jan-09 0:01 
AnswerRe: About downloading file Pin
Shyam K Pananghat23-Feb-09 3:18
Shyam K Pananghat23-Feb-09 3:18 
QuestionDataGrid Textbox will not apply value unless enter is pushed Pin
Brad Wick15-Jan-09 17:46
Brad Wick15-Jan-09 17:46 
AnswerRe: DataGrid Textbox will not apply value unless enter is pushed Pin
Aghosh Babu15-Jan-09 18:05
Aghosh Babu15-Jan-09 18:05 
GeneralRe: DataGrid Textbox will not apply value unless enter is pushed Pin
Brad Wick16-Jan-09 6:20
Brad Wick16-Jan-09 6:20 
AnswerRe: DataGrid Textbox will not apply value unless enter is pushed Pin
Mogesh17-Apr-09 0:35
Mogesh17-Apr-09 0:35 
QuestionHow to read from Serial (COM) Port? [modified] Pin
Aghosh Babu15-Jan-09 16:36
Aghosh Babu15-Jan-09 16:36 
i want to read data from a serial port(where a gsm modem is connected). I want to read the reply from modem when an AT command is send to the modem.
i.e for eg. if i send AT to the modem i want to read the reply OK from the modem!
I had used the below codes but the application hangs while executing these lines:

string data = Convert.ToString(serialPort1.Read(buffer, 0, (int)buffer.Length));<br />
//read using a Stream<br />
string data1 = Convert.ToString(serialPort1.BaseStream.Read(buffer, 0, (int)buffer.Length));<br />

I had also tried
string data = serialPort1.ReadLine();
Below is my full code section:
private void button1_Click(object sender, EventArgs e)
        {
            try
            {

                //configuring the serial port
                serialPort1.PortName = "COM6";
                serialPort1.Handshake = Handshake.None;
                serialPort1.BaudRate = 115200;
                serialPort1.DataBits = 8;
                serialPort1.Parity = Parity.None;
                serialPort1.StopBits = StopBits.One;
                serialPort1.DtrEnable = true;

                serialPort1.Open();
                
                string c = "AT+CMGS=";
                string c1 = "\"+6582083412\"\r\n";
                serialPort1.Write(c+c1);


                string d = "Test message from coded program ";
                //Now send the contents of the message
                serialPort1.Write(d);
                //SerialPortListen();
                char[] arr = new char[1];

                arr[0] = (char)26; //ascii value of Ctrl-Z

                serialPort1.Write(arr, 0, 1);
                
                //string data = Convert.ToString(serialPort1.Read(buffer, 0, (int)buffer.Length));
                //read using a Stream
                //string data1 = Convert.ToString(serialPort1.BaseStream.Read(buffer, 0, (int)buffer.Length));
               //MessageBox.Show(data + " part 2 is : " + data1);

                serialPort1.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


        }


I would appreciate your help very much, since this is my first time i am trying to communicate with a serial port. Thanks in advance

modified on Thursday, January 15, 2009 11:48 PM

AnswerRe: How to read from Serial (COM) Port? Pin
lincyang15-Jan-09 19:57
lincyang15-Jan-09 19:57 
AnswerRe: How to read from Serial (COM) Port? Pin
Bharat Jain15-Jan-09 21:34
Bharat Jain15-Jan-09 21:34 
GeneralRe: How to read from Serial (COM) Port? Pin
Aghosh Babu18-Jan-09 17:34
Aghosh Babu18-Jan-09 17:34 
GeneralRe: How to read from Serial (COM) Port? Pin
Bharat Jain26-Jan-09 20:24
Bharat Jain26-Jan-09 20:24 
QuestionPass Data between forms Pin
Illegal Operation15-Jan-09 13:45
Illegal Operation15-Jan-09 13:45 
AnswerRe: Pass Data between forms Pin
Colin Angus Mackay15-Jan-09 14:09
Colin Angus Mackay15-Jan-09 14:09 
Questionline break syntax for tooltip on asp.net hyperlink control Pin
Lara Nabozny15-Jan-09 12:44
Lara Nabozny15-Jan-09 12:44 
AnswerRe: line break syntax for tooltip on asp.net hyperlink control Pin
EliottA15-Jan-09 12:59
EliottA15-Jan-09 12:59 
GeneralRe: line break syntax for tooltip on asp.net hyperlink control Pin
Lara Nabozny15-Jan-09 13:05
Lara Nabozny15-Jan-09 13:05 
GeneralRe: line break syntax for tooltip on asp.net hyperlink control Pin
EliottA15-Jan-09 13:13
EliottA15-Jan-09 13:13 
GeneralRe: line break syntax for tooltip on asp.net hyperlink control Pin
Vikram A Punathambekar15-Jan-09 18:02
Vikram A Punathambekar15-Jan-09 18:02 
GeneralRe: line break syntax for tooltip on asp.net hyperlink control Pin
Lara Nabozny16-Jan-09 4:31
Lara Nabozny16-Jan-09 4:31 
GeneralRe: line break syntax for tooltip on asp.net hyperlink control Pin
Vikram A Punathambekar16-Jan-09 4:51
Vikram A Punathambekar16-Jan-09 4:51 
GeneralRe: line break syntax for tooltip on asp.net hyperlink control Pin
Lara Nabozny16-Jan-09 4:55
Lara Nabozny16-Jan-09 4:55 
Question[REQ: Help] Neural Network Pin
MavKilla15-Jan-09 12:38
MavKilla15-Jan-09 12:38 
Questionhow can made student form application in C#.net and login form?please send me coding and tutorial Pin
mohammedali200615-Jan-09 11:28
mohammedali200615-Jan-09 11:28 
AnswerRe: how can made student form application in C#.net and login form?please send me coding and tutorial Pin
User 665815-Jan-09 11:53
User 665815-Jan-09 11:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.