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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:01:15+00:00 2026-05-23T16:01:15+00:00

Am working on decoding a protocol used by a certain gps device to communicate.

  • 0

Am working on decoding a protocol used by a certain gps device to communicate.
Right now, am analyzing the first data packet that it sends. I am able to read it, but am thinking am not reading it properly.

Here is what i got so far:

    public static String toHex(byte[] bytes) {
    BigInteger bi = new BigInteger(1, bytes);
    return String.format("%0" + (bytes.length << 1) + "X", bi);
}

private void ProcessInitialPacket(){
            int port = 1954;
    System.out.println("Listening on port :"+port);
    byte[] data =  new byte[17];
    byte[] ackPacket = new byte[2];
    byte[] dataPacket= new byte[15];
    try {
        ServerSocket sSocket = new ServerSocket(port);
        Socket cSocket = sSocket.accept();          
        DataInputStream dataIN = new DataInputStream(cSocket.getInputStream());
        int packetSize=dataIN.read(data,0,data.length);         
        System.arraycopy(data, 0, ackPacket, 0, 2);
        System.arraycopy(data,2,dataPacket,0,15);

        System.out.println("Total packet size: "+ packetSize);
        System.out.println("ACK PACKET : "+ toHex(ackPacket));
        System.out.println("DATA PACKET: "+ toHex(dataPacket));
        System.out.println("FULL PACKET: "+ toHex(data));
    } catch (IOException e) { 
        e.printStackTrace();
    }
}

the output:

-PARSER()--

-INITSESSION–
Listening on port :1954

Total packet size: 17

ACK PACKET : 000F

DATA PACKET: 333532383438303236323631393534

FULL PACKET: 000F333532383438303236323631393534

——CLOSESESSION————

Now, my problem:

what is happening here is that the device sends a [0x00][0x0F]xxxxxxxxxxxxxxx
where the xxxxxxx is its imei (the data packet).
My problem is that there are way too many 3´s on the data packet, so the real valid output is

352848026261954

which you obtain by removing 3´s. my question is: can this behavior come from my code or its part of the protocol? i can correct this programmatically but am wanting to know it there is a way that code can cause these extra 3s.

  • 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-05-23T16:01:16+00:00Added an answer on May 23, 2026 at 4:01 pm

    You are looking at the hex of the ascii values which needs to be decoded as numbers. The character ‘0’ as a decimal is 48 or as hex 0x30, up to ‘9’ is 57 as a decimal or 0x39 as hex.

    So a sequence of bytes

    33 35 32 38 34 38 30 32 36 32 36 31 39 35 34
    

    is

    "352848026261954"
    

    as ASCII characters.

    I would change your code like this

    dataIN.readFully(data); // always read 17 bytes, not less
    String text = new String(data, 0, 2, 13); // decodes 8-bit bytes as a String
    long number = Long.parseLong(text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The stringByReplacingPercentEscapesUsingEncoding method is not working properly as it's not decoding special symbols that
I'm working on an rtsp streaming(AAC format) client for iOS using ffmpeg. Right now
I'm a beginner java programmer. I'm working on an application that decrypts some data.
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project that parses a log of events, and then updates a
While working on decoding some video streaming standards I have noticed a lot of
Sometimes procedural programming is absolutely unavoidable when processing data. I am currently working on
For a fun project I'm trying to implement the BitTorrent spec, and right now
I am working on a collection of classes used for video playback and recording.
I am working on decoding VIN numbers into useful information and for the country

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.