Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Converting binary data bytes to usable numbers

Converting binary data bytes to usable numbers

Scheduled Pinned Locked Moved Visual Basic
iotsaleshelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Scott Page
    wrote on last edited by
    #1

    I have downloaded a binary stream of data from a GPIB (IEEE 488.2) instrument that contains an EEPROM on the sensor connected to it. I have the header and table structure of the information and some of the types that the data represents, i.e. "7.8 (signed)", "16 bit integer" <-- quoted from the instrument programming manual. I am trying to convert this data into usable numbers, for example: The header is made up of 9 bytes. The first two bytes make up a "7.8 (signed)" value ranging from -127.0 to +127.9, the second two bytes are the same, the third and fourth bytes make up a 16 bit integer.... and so on. After the header is a table containing various other data types and contents. I have the full byte table from the manufactures manual if anyone that would like to help needs it. Any help would be appreciated, this has been one big headache, and I'm sure our customer will be glad to know we got it to work. X|

    R 1 Reply Last reply
    0
    • S Scott Page

      I have downloaded a binary stream of data from a GPIB (IEEE 488.2) instrument that contains an EEPROM on the sensor connected to it. I have the header and table structure of the information and some of the types that the data represents, i.e. "7.8 (signed)", "16 bit integer" <-- quoted from the instrument programming manual. I am trying to convert this data into usable numbers, for example: The header is made up of 9 bytes. The first two bytes make up a "7.8 (signed)" value ranging from -127.0 to +127.9, the second two bytes are the same, the third and fourth bytes make up a 16 bit integer.... and so on. After the header is a table containing various other data types and contents. I have the full byte table from the manufactures manual if anyone that would like to help needs it. Any help would be appreciated, this has been one big headache, and I'm sure our customer will be glad to know we got it to work. X|

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      Hi, for all types which have equivalents in .Net (like 16 bit integer to Single) you can use the BitConverter class. It provides static functions to convert byte arrays to the specified format and vice versa. With the other type I cant help you. I dont even know what "7.8 (signed)" exactly mens. I think its some kind of floating point type but .Net only provides 32 and 64 bit floating number types. If you programming manual has some more info regarding this type then feel free to post it here.

      S 1 Reply Last reply
      0
      • R Robert Rohde

        Hi, for all types which have equivalents in .Net (like 16 bit integer to Single) you can use the BitConverter class. It provides static functions to convert byte arrays to the specified format and vice versa. With the other type I cant help you. I dont even know what "7.8 (signed)" exactly mens. I think its some kind of floating point type but .Net only provides 32 and 64 bit floating number types. If you programming manual has some more info regarding this type then feel free to post it here.

        S Offline
        S Offline
        Scott Page
        wrote on last edited by
        #3

        Robert, Thanks for the quick response. I spoke to the Manufacturer and obtained detailed information concerning the conversion of the Bytes to usable values. Multiplying Int32 by some number, dividing by another, blah blah blah. Anyway, thanks for all the help, Scott

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups