Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8608689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:40:53+00:00 2026-06-12T03:40:53+00:00

I have a problem on reading data from serial-port in my winform application…here is

  • 0

I have a problem on reading data from serial-port in my winform application…here is my code ..

private void rtrvBtn_Click(object sender, EventArgs e)
    {
        btnid = 2;
        mySerialPort = new SerialPort(port);
        mySerialPort.Open();
        compacket(btnid);

        if (combuffer[0] != 0)
        {
            mySerialPort.Write(combuffer, 0, 4);
            System.Threading.Thread.Sleep(500);
            mySerialPort.DataReceived += new SerialDataReceivedEventHandler(this.port_rec);
        }
        else
        {
            lblmsg.Text = "FL";
        }
        mySerialPort.Close();


        rtrvBtn.Enabled = false;
        conBtn.Enabled = true;
    }

public void port_rec(object sender, SerialDataReceivedEventArgs e)
    {
        string s = Convert.ToString(mySerialPort.ReadExisting());
        MessageBox.Show(s);
    }

so here i am not getting any data and i am not also entering the port_rec event also.. can any one help … and my serial-port settings are like this ….

 public void SettingRS232(string port)
    {
        try
        {
            mySerialPort = new SerialPort(port);
            mySerialPort.PortName = port;
            mySerialPort.BaudRate = 9600;
            mySerialPort.Parity = Parity.None;
            mySerialPort.StopBits = StopBits.One;
            mySerialPort.DataBits = 8;
            mySerialPort.Handshake = Handshake.None;
            mySerialPort.ReadTimeout = 2000;
            mySerialPort.WriteTimeout = 500;

            mySerialPort.DtrEnable = true;
            mySerialPort.RtsEnable = true;


        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }

help me guys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:40:54+00:00Added an answer on June 12, 2026 at 3:40 am

    I would guess that these two methods are in the same class with a mySerialPort field. You shouldn’t be making a new serial port object in the click event, you should be using the one you already have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing a GUI for reading continuous data from a serial port.
Android 2.1 update 1 Eclipse 3.5 I have a problem reading data from my
I have some problem with reading from sqlite3 database. -(void) readMessengesFromDatabase { sqlite3 *database;
I'm reading data from a serial port. I read this posting: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/a709d698-5099-4e37-9e10-f66ff22cdd1e He is
I am reading data from a scale using a serial port. Communication is working
Here is my scenario: I have some data coming into serial port. I want
I have a problem with the boost::asio::serial_port class reading from a GPS device (USB-Serial).
My problem involves checking if I have a valid database connection before reading from
Well I have a problem reading the JSON data in jQuery, which is outputted
I'm having a problem reading and processing data from my server. I've spent hours

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.