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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:05:35+00:00 2026-05-27T01:05:35+00:00

I should get ID from socket but this code is not giving the correct

  • 0

I should get ID from socket but this code is not giving the correct one. Can someone tell me what is wrong in my code? (see below for more information)

for (int i = 0; i < numberOfSRecords; i++) {
    socketReader.read(cbuf, 0, 4);
    String Param_Codes_In_HEX =
        Integer.toHexString(0x000000ff & cbuf[2]) +
        Integer.toHexString(0x000000ff & cbuf[1]) +
        Integer.toHexString(0x000000ff & cbuf[0]);
    System.out.println("Param_Codes_In_HEX: "+Param_Codes_In_HEX);
    int paramCode = Integer.parseInt(Param_Codes_In_HEX, 16);
    if ((0x000000ff & cbuf[3]) ==0) {
    EnumParamCodes enumParamCode = 
         EnumConverterUtil.getEnumFor(EnumParamCodes.class, paramCode);
    System.out.println("Param_code " + paramCode + ": " + enumParamCode);
    }
  else if((0x000000ff & cbuf[3]) ==64)
   {
    paramCode = 0x0000ffff & paramCode ;
    EnumParamCodes enumParamCode = EnumConverterUtil.getEnumFor(EnumParamCodes.class, paramCode);
   System.out.println("Param_code " + paramCode + ": " + enumParamCode);
   }
  else if ((0x000000ff & cbuf[3]) ==128) {
      paramCode = 0x00ffffff & paramCode ;
      EnumAlarm enumParamCodeAlarm = EnumConverterUtil.getEnumFor(EnumAlarm.class, paramCode);
      System.out.println("Param_code " + paramCode + ": " + enumParamCodeAlarm);
    } 
  else{
      System.out.println("Error in the body of message");
        }
      }

Note:
• For Numerical and Enumerative Parameters (ActualValue), the
Param_code corresponds to the ID in the Parameters section

• For Numerical and Enumerative Parameters (SetValue), the
Param_code corresponds to 0x40000000 + the ID in the Parameters
section

• For Alarm Parameters, the Param_code corresponds to 0x80000000
+ the ID in the Parameters section

  • 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-27T01:05:36+00:00Added an answer on May 27, 2026 at 1:05 am
    String getByteString(byte b) {
        StringBuffer buf = new StringBuffer();
        String digit=Integer.toHexString(b &0xff);
        buf.append(digit);
        if (digit.length()<2) buf.append('0');
        return buf.toString();
    }
    

    this should get the 0 padding for you

    String Param_Codes_In_HEX = getByteString(cbuf[2]) + getByteString(cbuf[1]) + getByteString(cbuf[0]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the feeling this is probably something I should know but I can't
I have a three tier set-up. Someone suggested I should get the ConnectionString from
When I click on the hx:commandExButton the Javascript function should get called, but it
I'm considering developing an app for Google App Engine, which should not get too
I don't have much experience doing unit testing. From what I learned, code should
I'm working on a site with multiple subdomains, some of which should get their
How should I get the number of characters in a string in C++?
I just starting reading about SEO and realized that I should change my GET
I´m building an asp.net app, which technology I should use to get AJAX capabilities?
Should I mention [request setHTTPMethod:@GET] ? and what should I enter in the [request

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.