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

  • SEARCH
  • Home
  • 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 8572677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:04:36+00:00 2026-06-11T19:04:36+00:00

I am sending data through serial port .. the sending part is ok, I

  • 0

I am sending data through serial port .. the sending part is ok, I am getting the the data in the other end but I can’t get the acknowledgement part done… this is what I am doing …

mySerialPort.Open();
        mySerialPort.Write(databuffer, 0, 19);
        System.Threading.Thread.Sleep(2000);
        if (mySerialPort.BytesToRead > 0)      // this condition not working
        {
            string rdata = mySerialPort.ReadExisting();
            if (rdata.ToUpper().Trim() == "OK")
            {
                lblmsg.Text = "OK";
            }
            else
            {
                lblmsg.Text = "FL";
            }
        }

        mySerialPort.Close();

and further my settings of serial port is like this ….

public void SettingRS232(string port)
    {
        try
        {
            SerialPort 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;
        }
    }
  • 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-11T19:04:38+00:00Added an answer on June 11, 2026 at 7:04 pm

    That’s very little to go by. First use another program to test the connection, something like HyperTerminal or Putty. That lets you very that you got the basics correct, a proper electrical connection and the correct baudrate, parity, stopbits and databits settings. And check that the device returns a response within the magic number you picked, 2 seconds.

    By far the most common mistake is not taking care of the proper Handshake. If you leave it at None then you must turn on the handshake signals yourself. Set the RtsEnable and DtrEnable properties to true. The device won’t send anything when it sees those signals turned off, it assumes that you are not powered-up (DTR) and not ready to receive data (RTS).

    Further improve your code by avoiding mixing binary data and strings, get rid the awful Sleep(). Call the Read() method to receive bytes, pay attention to the return value to know how many you got. Keep calling Read() until you got all of the ones you expected to receive.


    Edit: your SettingRS232() method has a bug:

     SerialPort mySerialPort = new SerialPort(port);
    

    That creates a local variable with the name mySerialPort. You are initializing that local variable, not the mySerialPort variable that the rest of your code is using. Fix the bug by writing it like this:

     mySerialPort = new SerialPort(port);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sending data from a linux application through serial port to an embedded
I'm very new to sending data over a serial port through .net and I've
When sending data to a stored procedure through SubSonic, how can I pass a
I am sending data to the IP address 127.0.0.1 on port number 5152. Through
I am sending data to PHP through HTTP POST. This works fine for data
I'm developing an application that is sending data through tcp/ip I've made my own
I'm sending data from client sockets through a proxy server to an http server.
I am having issue when sending data from Service to Activity through Notification ,
I'm trying to communicate to a device using RS-485 through the serial port. Everything
I've encountered an issue when sending large segments of data through a TCP socket,

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.