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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:24:08+00:00 2026-06-04T18:24:08+00:00

I want to make a GUI for my device to show the value of

  • 0

I want to make a GUI for my device to show the value of each sensor. My device send data with this format

:1*895*123;
:1*987*145;

* is use to separate data from sensors

; is for the end of data

: is for start of data in next loop

I have variables dot, Rx1 and Ry2 to storing the data and show it on label, but looks like my program didn’t works.. here’s my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        string TestText, Rx1, Ry1, dot;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }



    private void button1_Click(object sender, EventArgs e)
    {
        serialPort1.PortName = "COM7";
        serialPort1.BaudRate = 2400;

        serialPort1.Open();
        if (serialPort1.IsOpen)
        {
            button1.Enabled = false;
            button2.Enabled = true;
        }
    }

    private void button2_Click(object sender, EventArgs e)
    {
        if (serialPort1.IsOpen)
        {
            serialPort1.Close();
            button1.Enabled = true;
            button2.Enabled = false;
        }

    }

    private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
    {
        TestText = serialPort1.ReadExisting();
        string[] nameArray = TestText.Split ('*');
        foreach (string name in nameArray)
        {
            dot = nameArray[0];
            Rx1 = nameArray[1];
            Ry1 = nameArray[2];
        }
    }

    private void label3_Click(object sender, EventArgs e)
    {

    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        label3.Text = dot;
        posY.Text = Ry1;
        posX.Text = Rx1;
    }
        //this.Invoke(new EventHandler(DisplayText));
    }


}

I’m still new in c# and not so good with it.. so i need help. thanks before.

  • 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-04T18:24:09+00:00Added an answer on June 4, 2026 at 6:24 pm

    Are you sure that you’re getting complete packets in the data received method? if not you’ll need to buffer them up to be sure it’s working properly.

    You could try something like this.

    // A buffer for the incoming data strings.
    string buffer = string.Empty;
    
    private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
    {
      // buffer up the latest data.
      buffer += serialPort1.ReadExisting();;
    
      // there could be more than one packet in the data so we have to keep looping.
      bool done = false;
      while (!done)
        {
           // check for a complete message.
           int start = buffer.IndexOf(":");
           int end = buffer.IndexOf(";");
           if (start > -1 && end > -1 && start < end)
           {
              // A complete packet is in the buffer.
              string packet = buffer.Substring(start + 1, (end - start) - 1);
    
              // remove the packet from the buffer.
              buffer = buffer.Remove(start, (end - start) + 1);
    
              // split the packet up in to it's parameters.
              string[] parameters = packet.Split('*');
              rx1 = parameters[0];
              ry1 = parameters[1];
              dot = parameters[2];
    
           }
        else
           done = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a GUI have a slider, this slider's value will be
I want to make a JFrame to display a GUI like this: https://i.stack.imgur.com/2POFs.png (im
I want to make some GUI mockup program for video player, so my idea
I want to make basic gui-tests with the ms ui automation framework, therefore i'm
I want to make a gui for what i explained here C# visual control
I want to make GUI for my application. It should work on multiple platforms.
I want to make a GUI for chess in C#. The modern freely available
I want to make a button inside my GUI that triggers a shell script.
I want to make a java-based GUI tool that checks for the latest version
I want to make my GUI components aesthetically pleasing. Is there any particular ratio

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.