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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:47:54+00:00 2026-06-04T12:47:54+00:00

Tearing my hair out with an RS232 programming issue. I have a char[7] buffer

  • 0

Tearing my hair out with an RS232 programming issue.

I have a char[7] buffer with some characters in it which I am writing to a serial port.
I am using a Serial Port Monitor program to monitor incomings and outgoings from the port.

The buffer I am sending to the port contains

a5 00 01 00 0b 4a

when I get to the monitor program the monitor program indicates that it can see:

3f 00 01 00 0b 4a

So the header character is either being monitored wrong or being changed on the way out of the program.

I’m stumped and not sure how to get around this.

this is the code I am using to populate the buffer.

        char[]cmdBuffer=createCommandBuffer(0, 4, 1);
        cmdBuffer[4] = Convert.ToChar(what);
        placeChecksums(cmdBuffer);
        serialPort.Write(cmdBuffer, 0, cmdBuffer.Length);

I have checked the contents of cmdBuffer in a breakpoint before calling serialPort.Write and they are correct. I can only conclude that the monitor program is wrong, but then when I use it to monitor other software running at the same BAUD rate – it monitors correctly.

Anyone else had this same issue?

  • 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-04T12:47:55+00:00Added an answer on June 4, 2026 at 12:47 pm

    You’re handling characters, but you’ve expressed values as bytes.

    I would personally encourage you to use binary data everywhere you can, to simplify things – but the reason a5 is being converted to 3f is almost certainly due to the Encoding property of SerialPort, which defaults to ASCII. The value 0xA5 doesn’t exist in ASCII, so it’s converted to ‘?’ instead.

    If this is genuinely meant to be text, then change the encoding appropriately – but if it’s meant to be binary data, then use binary APIs instead (which deal in bytes and byte arrays instead of characters, character arrays and strings).

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

Sidebar

Related Questions

Am tearing my hair out here. Have read many examples which describe how to
I'm tearing my hair out over this issue. I have javascript code that looks
For some reason this has me tearing my hair out. I have a UNIX
Tearing my hair out. I created an as3 class - blah.Foo, which extends MovieClip.
I'm tearing my hair out over this gotcha and have been for a couple
I have been tearing my hair out over this for about 3 hours, please
I, like so many programmers before me, am tearing my hair out writing the
I have been tearing my hair out over the last couple of days. Just
Been tearing my hair out all day over this I am trying to have
I have been tearing my hair out now for a week or so, it's

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.