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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:05:03+00:00 2026-05-24T22:05:03+00:00

I am developing a program to communicate with an old system. I use System.IO.Ports.SerialPort

  • 0

I am developing a program to communicate with an old system. I use System.IO.Ports.SerialPort for this. The problem is when I send a longer message, the message bevome corrupt. I use a line listener and get the following results

What I sending

aa 01 00 00 12 03 06 18 02 c1 94 02 c1 94 00 00 00 00 00 00 00 00 00 00 00 00 1e fd 

What I get

c2 aa 01 00 00 12 03 06 18 02 c3 81 c2 94 02 c3 81 c2 94 00 00 00 00 00 00 00 00 00 00 00 00 1e c3 bd

The code I’m using is

_comPort.Encoding = new UTF8Encoding();
_comPort.PortName = PortName;  //Com1
_comPort.BaudRate = BaudRate;  //9600
_comPort.StopBits = StopBits;  //1
_comPort.DataBits = DataBits;  //8
_comPort.Parity   = Parity;    //None
_comPort.Open();

_comPort.Write(messageStr);

Why is data corrupted and how do I fix this?

  • 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-24T22:05:06+00:00Added an answer on May 24, 2026 at 10:05 pm

    My guess is that messageStr is a string, and you’re seeing encoding issues. You’ve explicitly specified the UTF-8 encoding, so that’s what you’re getting – but I suspect it’s not what you really want.

    You’ve shown binary data, so I assume you actually want to send exactly that binary data – in which case you should use the Write(byte[], int, int) overload.

    If you really want to write text data, you probably just need to pick the right encoding – but you’ll need to give us more information for us to help you make the right choice.

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

Sidebar

Related Questions

I am developing a program that use DirectShow to grab audio data from media
I am developing a program that is used to communicate between a mobile and
I am developing a program in Java that I will use for registering data.
I am developing a Clojure program and I use (:use modulename :reload) : everywhere
first question here. I'm developing a program in C# (.NET 3.5) that displays files
I am developing a C# program, and i have one function that consumes too
I'm developing an Windows Forms application that requires me to call a separate program
I'm trying to start a program using QProcess (Qt4.4 on vista64bit, developing in MSVC2005).
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
I have a question, I am developing a web page and I communicate with

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.