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 1090195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:20:10+00:00 2026-05-16T23:20:10+00:00

I am trying to read data from a scale RS232 interface. It sends a

  • 0

I am trying to read data from a scale RS232 interface. It sends a continuous ASCII string stream through the Serial Port which I am having trouble getting. I just want to get one line of the data that it is sending out. I guess I assumed that I would use Readline to get the data, but it just locks up the PC when I run it. I think it is trying to get all of the data and won’t stop until the data stops? Here is the code I’m using:

private void button1_Click(object sender, EventArgs e)
    {
        serialPort1.PortName = "COM4";
        serialPort1.BaudRate = 9600;
        serialPort1.DataBits = 8;
        serialPort1.Parity = Parity.None;
        serialPort1.StopBits = StopBits.One;

        //opening the serial port
        serialPort1.Open();

        string str = serialPort1.ReadLine();

        MessageBox.Show(str);

        serialPort1.Close();

    }

Can you help me to determine how to get just one line of the output data and close the connection?

  • 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-05-16T23:20:11+00:00Added an answer on May 16, 2026 at 11:20 pm

    SerialPort.ReadLine is defined to block “up to the first occurrence of a NewLine value”, where NewLine defaults to a line feed. Are you sending a linefeed in your stream? Note that a linefeed character (ASCII 0x0A) is different that a carriage return (ASCII 0x0D) that you might be sending.

    You can redefine the NewLine if needed, or if a line ending doesn’t feel right, you can read up to a given string with SerialPort.ReadTo. You can also set a read timeout.

    You might prefer to read a given number of bytes from the port, rather than a line, with one of the SerialPort.Read overloads.

    If none of this applies, make sure that you’re actually sending data where you think you are – bring up HyperTerminal/TeraTerm/your favorite serial terminal, configure it with the same serial port settings as you’ve used above, and make sure you see the data you expect to see.

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

Sidebar

Related Questions

I am trying to read data from an RS-232 port. Does anyone have an
I am trying to read data from a file stream as shown below: fileStream.Read(byteArray,
I am specifically trying to read data from an SNMP port in python using
I'm trying to read data from an xml file and display it in a
I'm trying to read data from excel using POI. How can I check if
I am trying to read data from a sqlite database in an ios app.
I am trying to read data from a sqlite database and display it in
I'm trying to read data from SQL Server database using Perl and the DBI
I am trying to read data from a bluetooth barcode scanner (KDC300) using C.
I'm trying to read data from a socket, however whenever I try to read

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.