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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:23:36+00:00 2026-05-13T18:23:36+00:00

This might be extremely trivial, and if so I apologise, but I’m getting really

  • 0

This might be extremely trivial, and if so I apologise, but I’m getting really confused with the outputs I’m getting: hex? decimal? what?

Here’s an example, and what it returns:

>>> print 'Rx State: ADC Clk=', ADC_Clock_MHz,'MHz DDC Clk=', DDC_Clock_kHz,'kHz Temperature=', Temperature,'C'
Rx State: ADC Clk= [1079246848L, 0L] MHz DDC Clk= [1078525952L, 0L] kHz Temperature= [1078140928L, 0L] C

Now I admit this is slight guesswork because I don’t know exactly what the data is – I have a specification of how to parse it out of the file, but it’s giving me very strange answers.

As you can see – the values are very similar, all around the 1078000000 mark, which leads me to believe I might be extracting something strange (like hex, but I don’t think it is…)

The structure is read as follows (apologies for length):

#Read block
    more = 1
    while(more == 1):
        a = array.array("L")
        a.fromfile(wholeFile,2)
        if len(a) == 2:
            structure_id = a[0]
            print 'structure_id: ', hex(structure_id)
            structure_length = a[1]
            print 'structure_length: ', structure_length
        else:
            print 'cannot read structure start'

        numDwords = (structure_length/4) - 2 - 1;
        print 'numDwords: ', numDwords

        content = array.array("L")
        content.fromfile(wholeFile,numDwords)
        if len(content) != numDwords:
            print 'cannot read structure'
            more = 0
            ok = 0

and then the above example was retrieved from this by:

pos = 2
v1 = [content[pos+1], content[pos]]
pos = pos+2
v2 = [content[pos+1], content[pos]]
pos = pos+2
v3 = [content[pos+1], content[pos]]
pos = pos+2

ADC_Clock_MHz = v1
DDC_Clock_kHz = v2
Temperature = v3

Right sorry again for how verbose that was, but it’s not just those values, it seems some values are ok and some aren’t, which leads me to believe that the larger numbers are encoded differently… Also I have no idea why all the values are in pairs either!

Pants question, but if anyone has any insight it’d be much appreciated.

  • 1 1 Answer
  • 1 View
  • 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-13T18:23:36+00:00Added an answer on May 13, 2026 at 6:23 pm

    Found out it’s incredibly easy to do this with numpy.fromfile

    Specify what you want to extract (e.g. uint32, int16 etc.) and it extracts it as an array.
    You can even specify your own types as a collection of existing types, meaning you can extract known structures in one go (e.g. 2 uint32s then 1 string then 5 int16s as an array of 8 values)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might sound like a stupid question but just trying to learn something here.
This might be a really trivial one. Is File storage OS dependant ? Why
(extremely) inexperienced in C++ but I've been getting along ok until now and this
This might be an extremely dumb question, but I simply can't understand the problem
The question is extremely easy, but the solution might not. Let's say this is
I know this might be an extremely beginner level question but I am just
This might seem like a very easy question for some of you folks, but
This might be a simple question but I've searched and searched and can't find
This might be a very basic question but it confuses me. Can two different
This might have to be broken down a bit but what i want to

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.