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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:05:52+00:00 2026-06-03T10:05:52+00:00

I need to be able to write signed bytes to a serial port using

  • 0

I need to be able to write signed bytes to a serial port using

SerialPort.Write() method, except that method only takes byte[] arrays of unsigned bytes, how would i write a signed byte to the serial port?

For what I’m working on the particular command takes values from -1700 to 1700.

thanks

nightmares

  • 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-03T10:05:54+00:00Added an answer on June 3, 2026 at 10:05 am

    The serial communication channel has no concept of signed or unsigned, only a concept of 1’s and 0’s on the wire. It is your operating system (and ultimately your CPU architecture) that assigns a numeric value to those 1’s and 0’s, on both the sending and receiving side.

    The value range you state cannot be represented in a byte (per my comment and your reply). You need to understand what bit pattern the receiving device expects for a given number (is the other device big endian or little endian?), and then you can send an appropriate sequence of byte[] to represent the number you want to transmit.

    If both devices have the same endianness, you can setup an array of short then copy to an array of byte like this:

    short[] sdata = new short[] { 1, -1 };
    byte[] bdata = new byte[sdata.Length * 2];
    
    Buffer.BlockCopy(sdata, 0, bdata, 0, bdata.Length);
    

    However, be sure and test for a range of values. Especially if you are dealing with embedded devices, numeric encoding may not be exactly as on an Intel PC.

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

Sidebar

Related Questions

I need to be able to write a function that shows repeated words from
I need to write an Icecast 2 client that will be able to stream
I need to be able to write a script to automatically connect mysql in
I'm writing a Delphi expert. I need to be able to write a value
I need to write something like a minesweeper in prolog. I am able to
We're developing an applet and need it to be able to read/write files in
For a project i'm working on, I need to be able to write to
I have a Java Applet which is digitally signed. I need to be able
I have a template class, and would like to write a member method that's
I need to be able to write to a remote text file located on

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.