Results 1 to 5 of 5

Thread: I need urgent help! File reader?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2020
    Posts
    34

    I need urgent help! File reader?

    I'm currently working on a software for a few months for my (automotive) chip tuning firm. I need to create a file reader that reads in both 8bit and 16bit (I'm maybe wrong! I don't know if I'm right)
    Here is and example from a well known automotive software (WINOLS) :
    One picture shows in 8bit and other shows in 16bit (it's how it's declared in WINOLS)
    If you read it in 8bit you get for instance a value : "C3" but if you switch to 16bit then that value is "50115"
    I've already made a binary reader based on the "Be.Hexbox" but converted from C# to VBNET. But i cant seem to find a way to read the file in 16bit?
    Any help would be grately appreciated!!

    Name:  3.jpg
Views: 290
Size:  333.0 KB
    Name:  2.jpg
Views: 338
Size:  92.4 KB
    FILE USED FOR REFERANCE: http://www.mediafire.com/file/3c6s6c..._file.bin/file

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: I need urgent help! File reader?

    C3 would be 8 bits represented in hex. 50115 is not 16 bits represented in hex, so it would be decimal. If you convert 50115 to hex, you get C3C3. So, all you are really doing is reading bytes into an array. The 8 bit display is showing each individual byte displayed as a hex string, while the 16 bit display is taking every two bytes and displaying them as decimal. It's not really apples and oranges, but it's part way there. It's the same data, it's just two different ways to display it.

    So, what does the file have? do you have two different kinds of files, or just one, because a file will just be some group of bytes. If there is reason to see every byte by itself, then the 8 bit display would make sense, whereas, if every pair of bytes really does belong together then the 2 bytes (16 bit) display makes more sense. In either case, you can decide whether you want to display the data in hex or decimal. Most people are more familiar with decimal, but when it comes to bytes, hex has a real advantage, since every four bits is one character of hex, so a byte is always two characters. If you were to show a byte in decimal, it could be up to three characters, so you would either have each byte show as 1, 2, or 3 characters, or you would pad out the display so that all bytes are 3 characters (where the left most character will only ever by 0, 1, or 2). Similarly, a 16 bit value would be four characters of hex, but up to five characters in decimal.

    That's just a question of how you want to represent the data. Underneath, it's all just bytes. You're making the choice of showing each byte individually, or grouping them together into groups of 2 or 4 (32 bits). Next, you're deciding to display them as hex or decimal. You could also provide a toggle, so that the user could switch back and forth between hex and decimal. You'd be changing the number of characters, but not much more than that.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2020
    Posts
    34

    Re: I need urgent help! File reader?


  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: I need urgent help! File reader?

    You aren't helping yourself. Not many people are going to go to some site and get an unknown file, especially if it's an entire project, and even more so if you haven't explained what the issue is. The point of my previous post was that 8-bit and 16-bit is meaningless. It's all just bytes. You either take them one at a time or two at a time, and then perhaps only for display purposes.

    So, what is the issue? Do you have the bytes? If you do, then is the issue about how to display them two at a time? Or are you having an issue showing them as decimal vs hex? It sounds like you already have code for the project. If it is not working, what is it doing that it shouldn't be doing, or what is it not doing that it should be doing?

    Beyond that, nobody is going to be very enthusiastic about looking through an entire project for just that part of the code that 1) reads the file, and 2) displays the file incorrectly. Those two chunks are tiny parts of the project. Just copy and paste whichever of those two is relevant to the actual problem into the thread.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2020
    Posts
    34

    Re: I need urgent help! File reader?

    The project is originally "Be.Hex" written in C#. I Used SharpDevelop to convert it to VB.NET. The software is Working but only displaying the content in 8BIT or as mentioned earlier "C3" I'm no god in programming and I do not know what should I alter to make it display "50115" instead of "C3" Here's the code that imports bytes into the HexBox:

    Code:
    Dim bytes() As Byte
                bytes = File.ReadAllBytes(Label3.Text) ' label3 is the location of the opened file using openfiledialog
                Dim b As Byte() = bytes
                Dim dbp As New DynamicByteProvider(b)
                Me.hexBox.ByteProvider = dbp
    This is how it looks like when the file is opened.
    Name:  ss.jpg
Views: 171
Size:  37.6 KB

    I don't know if it is eaven possible to do it with the converted project I'm using.
    Last edited by vargaperformance; Oct 20th, 2020 at 04:01 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width