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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:14:31+00:00 2026-06-02T13:14:31+00:00

I have a binary protocol which extracts the MSB of each payload byte into

  • 0

I have a binary protocol which extracts the MSB of each payload byte into a MSB collection byte (septett) for transmission, and re-injects the MSBs on receiver side. The payload consists of n four byte frames, depending on sender (six in my case).

Those are two example frames, with their septett (last byte), as seen on the wire:

0x2E 0x00 0x5F 0x00 0x04
0x79 0x01 0x38 0x22 0x04

Those are the same frames, client side, with the MSBs re-injected:

0x2E 0x00 0xDF 0x00
0x79 0x01 0xB8 0x22

The C functions that do the transformation are defined on pages 9 and 10 in this document. My version of these, in Java, is below. The problem I have is that none of this works, and I’m confused as to why. I pass my four bytes from the wire, and get same bytes out, untouched. I could use some help figuring out what’s wrong here (probably something trivial that I fail to see).

private static byte[] vbusExtractSeptett(byte[] data, int offset, int length) {
    byte septett = 0;
    for (int i = 0; i < length; i++) {
        if ((data[offset + i] & 0x80) != 0) {
            data[offset + i] &= 0x7F;
            septett |= 1 << i;
        }
    }

    data[offset + length] = septett;
    return data;
}

private static byte[] vbusInjectSeptett(final byte[] data, int offset, int length) {
    byte septett = data[offset + length];

    for (int i = 0; i < length; i++) {
        if ((septett & (1 << i)) != 0)
            data[offset + i] |= 0x80;
    }

    return data;
}
  • 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-02T13:14:32+00:00Added an answer on June 2, 2026 at 1:14 pm

    In Java, a byte is signed. Without reading through all your code, I bet that is the problem.

    The C code in your document uses unsigned char math.

    Since Java doesn’t have “unsigned”, you probably need to do all your math in shorts (or ints) and then convert back to bytes. Be sure to mask off the sign bit, e.g. something like

    byte theResult = theIntIDidtheMathOn & 0xFF;
    data[index] = theResult;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say, i have binary protocol, where first 4 bits represent a numeric value which
does anyone have a good definition for what a binary protocol is? and what
I have a binary tree where each node can have a value. I want
I have a binary search loop which gets hit many times in the execution
I have a binary image (a dll) which I wish to view the assembly
Many languages have functions which only process plaintext, not binary. Does this mean that
I am writing a dissector in Lua for a custom, binary protocol. I have
I have a library which parses various messages, sent in binary form from multiple
Assume I have simple protocol implemented over TCP, where each message is made up
I have a TCP server that handles a specific binary protocol. Some requests include

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.