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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:36:30+00:00 2026-05-15T01:36:30+00:00

I have a C# application wherein serial (COM1) data appears to sometimes not get

  • 0

I have a C# application wherein serial (COM1) data appears to sometimes not get transmitted. Following is a simplified snippet of my code (calls to textBox writes have been removed):

    InitializeComponent()
    {
       // 
       // serialPort1
       // 
       this.serialPort1.BaudRate = 115200;
       this.serialPort1.DiscardNull = true;
       this.serialPort1.ReadTimeout = 500;
       this.serialPort1.ReceivedBytesThreshold = 2;
       this.serialPort1.WriteTimeout = 500;
       this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived);
    }

        if (radioButtonUart9600.Checked)
        {
           serialPort1.BaudRate = 9600;

           try
           {
              serialPort1.Open();
           }
           catch (SystemException ex)
           {
              /* ... */
           }
        }

        try
        {
           serialPort1.Write("D");
           serialPort1.Write(msg, 0, 512);
           serialPort1.Write("d");
           serialPort1.Write(pCsum, 0, 2);
        }
        catch (SystemException ex)
        {
           /* ... */
        }

What is odd is that this same code works just fine when the port is configured for 115.2Kbps. However, when running at 9600bps data that should be transmitted by this code seems to not get transmitted. I have verified this by monitoring the receive flag on the remote device. No exceptions are thrown from within the try statement. Is there something else (Flush, etc.) that I should be doing to make sure the data is transmitted? Any thoughts or suggestions you may have would be appreciated. I’m using Microsoft Visual C# 2008 Express Edition. Thanks.

  • 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-15T01:36:31+00:00Added an answer on May 15, 2026 at 1:36 am

    Remove these try/catch blocks. That ought to give you a chance to see the TimeoutException you get because you set the WriteTimeout value too low. Sending 516 bytes at 9600 baud takes 538 milliseconds.

    Your other settings are recipes for trouble too. Get rid of ReceivedBytesThreshold and DiscardNull.

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

Sidebar

Related Questions

I'm writing an application wherein I have some debug code that I do not
I am working on an application in Android, wherein I have to get android.graphics.
I have this Grails application wherein I installed JQuery, JQuery-UI, and JQGrid plugin. I
I have application with needs to have access to some sensitive data(in this case
i have an application wherein i have incorporate a Remember Me feature for the
i have an application wherein i am accessing the Session object in the CommonCode.cs
i have an application wherein i am using a web-service. Now the ip address
I have an application wherein I would like a function to be executed in
I have an application wherein I am hosting multiple types of content (images, PowerPoint
I have an application wherein the application will need to check whether one user

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.