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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:24:26+00:00 2026-05-23T19:24:26+00:00

I have an application that reads from a COM Port and then does something

  • 0

I have an application that reads from a COM Port and then does something with the data that it receives. I am currently using a COM Port emulator (Since i don’t have the device available for me to use) but I am feeding it a sample of the data. The program seems to work perfectly fine if I open the COMPort before I start transmitting data. However, if I start transmitting before I open the COMPort, and then I open the port, the dataReceived event is never fired and I am never able to get any data. I have even tried to flush the INBuffer as soon as I open the port but am unable to read from it.

My code to open the port is this:

public void setupComPort(string baudRate, string dataBits, string stopBits, string parity, string portName)
    {
        if (comPort.IsOpen)
            comPort.Close();
        comPort.BaudRate = int.Parse(baudRate);
        comPort.DataBits = int.Parse(dataBits);
        comPort.StopBits = (StopBits)Enum.Parse(typeof(StopBits), stopBits);
        comPort.Parity = (Parity)Enum.Parse(typeof(Parity), parity);
        comPort.PortName = portName;
        // When data is recieved through the port, call this method
        comPort.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
        try
        {
            // Open the port
            comPort.Open();
            //If there's data in buffer, discard so we can start receiving
            //comPort.DiscardInBuffer();
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message, "Error Opening Port", MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }

Any help would be appreciated.

  • 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-23T19:24:28+00:00Added an answer on May 23, 2026 at 7:24 pm

    Its probably an issue with the emulator. I’ll guess the issue will go away when you have the actual hardware. The only other thing I can think to try is setting the ReceivedBytesThreshold to something other than the default (like 10 or something).

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

Sidebar

Related Questions

I have an application that reads data from a com port using javax.comm. The
Here's the scenario - I have a C# application that reads from a COM
I have an application that reads lines from a file and runs its magic
I have an application that reads a table from a database. I issue an
I have an application that reads a CSV file with piles of data rows.
Problem in words: For my application, I have a class that reads from a
We have an application that starts a WCF server and the app reads from
Hy, I have an application that sends mails with Gmail SMTP server (smtp.gmail.com) using
I have a dll which includes a function called ReadPort that reads data from
I have an application that reads emails from ONE email account (gmail application account)

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.