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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:46:50+00:00 2026-05-28T06:46:50+00:00

I am trying to unpack a variable containing a string received from a spectrum

  • 0

I am trying to unpack a variable containing a string received from a spectrum analyzer:

#42404?û¢-+Ä¢-VÄ¢-oÆ¢-8æ¢-bÉ¢-ôÿ¢-+Ä¢-?Ö¢-sÉ¢-ÜÖ¢-¦ö¢-=Æ¢-8æ¢-uô¢-=Æ¢-\Å¢-uô¢-?ü¢-}¦¢-=Æ¢-)…

The format is real 32 which uses four bytes to store each value. The number #42404 represents 4 extra bytes present and 2404/4 = 601 points collected. The data starts after #42404. Now when I receive this into a string variable,

$lp = ibqry($ud,":TRAC:DATA? TRACE1;*WAI;");

I am not sure how to convert this into an array of numbers :(… Should I use something like the followin?

@dec = unpack("d", $lp);

I know this is not working, because I am not getting the right values and the number of data points for sure is not 601…

  • 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-28T06:46:51+00:00Added an answer on May 28, 2026 at 6:46 am

    First, you have to strip the #42404 off and hope none of the following binary data happens to be an ASCII number.

    $lp =~ s{^#\d+}{};
    

    I’m not sure what format “Real 32” is, but I’m going to guess that it’s a single precision floating point which is 32 bits long. Looking at the pack docs. d is “double precision float”, that’s 64 bits. So I’d try f which is “single precision”.

    @dec = unpack("f*", $lp);
    

    Whether your data is big or little endian is a problem. d and f use your computer’s native endianness. You may have to force endianness using the > and < modifiers.

    @dec = unpack("f*>", $lp);  # big endian
    @dec = unpack("f*<", $lp);  # little endian
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to unpack an array I obtain from reflecting an objects fields.
I'm trying to unpack a binary string sent via Javascript's FileReader readAsBinaryString method in
I am trying to query a bittorrent tracker and am using unpack to get
I'm trying to unpack a Weblogic 10.3 domain on one of our production servers
I'm trying to unpack all the system gems to end up with a standalone
I'm trying to convert a big-endian 2 byte string into a numeric port number.
I'm trying to read a binary file (which represents a matrix in Matlab) in
I am trying to do the following: <execution> <id>copy-jre</id> <phase>package</phase> <goals> <goal>unpack</goal> </goals> <configuration>
I am trying to read in data from a text file using numpy.loadtxt with
So I have been given a C program, which I am trying to make

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.