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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:14:56+00:00 2026-06-11T09:14:56+00:00

I am having problems with calculating CRC-16 implementation of a byte array in java.

  • 0

I am having problems with calculating CRC-16 implementation of a byte array in java. Basically I am trying to send bytes to a RFID that starts writing to a tag. I can see the checksum value of array by looking tcpdump command on mac. But my goal is to generate it by myself. Here is my byte array which should generate 0xbe,0xd9:

byte[] bytes = new byte[]{(byte) 0x55,(byte) 0x08,(byte) 0x68, (byte) 0x14, 
                          (byte) 0x93, (byte) 0x01, (byte) 0x00, (byte) 0x00, 
                          (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, 
                          (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, 
                          (byte) 0x13, (byte) 0x50, (byte) 0x00, (byte) 0x00, 
                          (byte) 0x00, (byte) 0x22, (byte) 0x09, (byte) 0x11};

0x55 is the header. As the documentation says it will be excluded.

Whenever I try this array on java (with 0xbe,0xd9), RFID works. My problem is the generating of those checksum values. I searched almost entire web but no chance. I couldn’t find any algorithm that produces 0xbe,0xd9.

Any idea is most welcome for me. Thanks in advance.

edit: here is the protocol that provided with rfid

  • 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-11T09:14:57+00:00Added an answer on June 11, 2026 at 9:14 am

    I’m not really sure if this is the correct translation in Java of the C crc16 algorithm….
    but it shows the correct result for your example!

    Please compare other results with Mac’s CRC16 and stress-test it before using it.

    public class Crc16 {
    public static void main(String... a) {
        byte[] bytes = new byte[] { (byte) 0x08, (byte) 0x68, (byte) 0x14, (byte) 0x93, (byte) 0x01, (byte) 0x00,
                (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x01,
                (byte) 0x00, (byte) 0x13, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x22, (byte) 0x09,
                (byte) 0x11 };
        byte[] byteStr = new byte[4];
        Integer crcRes = new Crc16().calculate_crc(bytes);
        System.out.println(Integer.toHexString(crcRes));
    
        byteStr[0] = (byte) ((crcRes & 0x000000ff));
        byteStr[1] = (byte) ((crcRes & 0x0000ff00) >>> 8);
    
        System.out.printf("%02X\n%02X", byteStr[0],byteStr[1]);
    } 
    
    int calculate_crc(byte[] bytes) {
        int i;
        int crc_value = 0;
        for (int len = 0; len < bytes.length; len++) {
            for (i = 0x80; i != 0; i >>= 1) {
                if ((crc_value & 0x8000) != 0) {
                    crc_value = (crc_value << 1) ^ 0x8005;
                } else {
                    crc_value = crc_value << 1;
                }
                if ((bytes[len] & i) != 0) {
                    crc_value ^= 0x8005;
                }
            }
        }
        return crc_value;
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having problems with a small awk script, Im trying to choose the newest of
im having problems starting a codeigniter project, the problem is that when i do
im having problems on how to save the content of an array in an
I'm having problems with trying to catch an error. I'm using Pyramid/SQLAlchemy and made
I'm having problems correctly calculating tax and discounts per item, mainly because I'm not
I'm having some performance problems where a SQL query calculating the average of a
I'm having some problems implementing a control that shows a Busy indicator, here is
I am having some performance problems that have left me baffled. I am using
Having problems iterating. Problem has to do with const correctness, I think. I assume
Having problems with the combining of two statements in a controller. Both statements work

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.