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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:05:39+00:00 2026-05-28T08:05:39+00:00

I’m developing a piece of software, which reads data sent through the COM port

  • 0

I’m developing a piece of software, which reads data sent through the COM port and display the value in a live graph and in a textbox (for debugging). It reads fine at first, but then suddenly one of the numbers is divided into two pieces. Like this:

63 – 64 – 65 – 66 – 67 – 6 – 8 – 69 – 70 – 80

It should say 68. This makes the graph all wrong!

What is the cause of this?

My code is as follows:

   private void DisplayText(object sender, EventArgs e)
    {
        textBox1.AppendText(RxString);
        textBox1.AppendText(" - ");

    }



    private void comPort_DataReceived_1(object sender, SerialDataReceivedEventArgs e)
    {
      RxString = comPort.ReadExisting();
      this.Invoke(new EventHandler(DisplayText));

      newRead = Convert.ToDouble(RxString);
      AddDataToGraph(zedGraph, howfar, newRead);
      howfar++;


    }

Thanks in advance.

  • 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-28T08:05:40+00:00Added an answer on May 28, 2026 at 8:05 am

    There’s no guarantee in what size chunks you will get the data….

    it could get them character at a time, or several characters at a time.

    Generally, never depend on timing to work out the difference between logical “chunks” ( in your case, numbers). Instead create a protocol that you can interpret.

    in your case if you have a VERY simple protocol where you send a number [space] number [space] number then you can parse out

    eg…

    RxString += comPort.ReadExisting();  // add to an existing string
    if(RxString.Contains(" ") // ok, there is a space, so we can parse out a number
    {
      // parse...
      newRead = Convert.ToDouble(RxString.Substring(0,RxString.IndexOf(" "));
      RxString = RxString.Remove(0,RxString.IndexOf(" ")+1;
      AddDataToGraph(zedGraph, howfar, newRead);
      howfar++;
    }
    

    and if you were using 123,123,234,123,343\n

        RxString += comPort.ReadExisting();  // add to an existing string
        if(RxString.Contains("\n")   // ok, there is a linefeed, so we can parse out all the numbers
        {
           // parse...
           var line = RxString.Substring(0, RxString.IndexOf("\n"));
           var values = line.Split(new char[] {','}, StringSplitOptions.None).ToList();
           values.ForEach(v =>  AddDataToGraph(zedGraph, howFar, Convert.ToDouble(v)));
           RxString = RxString.Remove(0, RxString.IndexOf("\n"));
           howfar++;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
i want to parse a xhtml file and display in UITableView. what is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to loop through a bunch of documents I have to put

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.