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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:31:23+00:00 2026-06-18T15:31:23+00:00

I don’t come from a low-level development background, so I’m not sure how to

  • 0

I don’t come from a low-level development background, so I’m not sure how to convert the below instruction to an integer…

Basically I have a microprocessor which tells me which IO’s are active or inactive. I send the device an ASCII command and it replies with a WORD about which of the 15 I/O’s are open/closed… here’s the instruction:

  • Unit Answers “A0001/” for only DIn0 on, “A????/” for All Inputs Active
  • Awxyz/ – w=High Nibble of MSB in 0 to ? ASCII Character 0001=1, 1111=?, z=Low Nibble of LSB.

At the end of the day I just want to be able to convert it back into a number which will tell me which of the 15 (or 16?) inputs are active.

I have something hooked up to the 15th I/O port, and the reply I get is “A8000”, if that helps?
Can someone clear this up for me please?

  • 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-18T15:31:24+00:00Added an answer on June 18, 2026 at 3:31 pm

    You can use the BitConverter class to convert an array of bytes to the integer format you need.

    If you’re getting 16 bits, convert them to a UInt16.

    C# does not define the endianness. That is determined by the hardware you are running on. Intel and AMD processors are little-endian. You can learn the endian-ness of your platform using BitConverter.IsLittleEndian. If the computer running .NET and the hardware providing the data do not have the same endian-ness, you would have to swap the two bytes.

    byte[] inputFromHardware = { 126, 42 };
    ushort value = BitConverter.ToUInt16( inputFromHardware, index );
    

    which of the 15 (or 16?) inputs are active

    If the bits are hardware flags, it is plausible that all 16 are used to mean something. When bits are used to represent a signed number, one of the bits is used to represent positive vs. negative. Since the hardware is providing status bits, none of the bits should be interpreted as a sign.

    If you want to know if a specific bit is active, you can use a bit mask along with the & operator. For example, the binary mask

    0000 0000 0000 0100

    corresponds to the hex number

    0x0004

    To learn if the third bit from the right is toggled on, use

    bool thirdBitFromRightIsOn = (value & 0x0004 != 0);
    

    UPDATE

    If the manufacturer says the value 8000 (I assume hex) represents Channel 15 being active, look at it like this:

    Your bit mask

    1000 0000 0000 0000  (binary)
     8    0    0    0    (hex)
    

    Based in that info from the manufacturer, the left-most bit corresponds to Channel 15.

    You can use that mask like:

    bool channel15IsOn = (value & 0x8000 != 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't be afraid to use any technical jargon or low-level explanations for things, please.
Don't know what's going on, but for some reason my background image is not
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
Don't know why people do not practice AJAX implementation for authentication systems. Is it
Don't they both have to convert to machine code at some point to execute
Don't know where else to ask, but from one day to the other my
Don't worry, I'm not going to ask that question, yet again... I am wanting
Don't know is it possible to copy elements from one map to another map
Don't know if I'm over-thinking this or not.. but I'm trying to be able

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.