By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,740 Members | 798 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,740 IT Pros & Developers. It's quick & easy.

Please help with Hex Length and Binary Word

P: n/a
Hi,

(First apologies if this is not the most relevant place to post this
but I wasn't sure of where was and I am writing my app in VB.)

I'm attempting to parse a binary file for which I have the format. The
format states that the general packet format is as follows

Message header
Hex Length of whole binary packet
Binary Word of above Hex Length
etc.

I just wanted to make sure of a couple of terms before I start - most
notably 'Hex Length' and 'Binary Word'.
I guess binary word is just a binary representation of the hex length
e.g. if the hex length was 8 then the binary word of hex length would
be '1000'. However, what is meant by hex length and how is it
determined? If you could provide an example I'd be grateful.

Thanks

Paul
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Paul" <pa********@hotmail.com> wrote in message
news:ca*************************@posting.google.co m...
I guess binary word is just a binary representation of the hex length
e.g. if the hex length was 8 then the binary word of hex length would
be '1000'. However, what is meant by hex length and how is it
determined? If you could provide an example I'd be grateful.

Hi Paul.. sounds like you have to ask whoever gave you that homework as to
what he/she meant. We at the board have no idea on how to guess that
meaning. It didn't make sense to me.

The term "word" can be of different length depending on the language. In VB
you have integer, single, double, long, variant, etc. for variable types.

For obvious reason, you have to know exactly how many bytes this info is
encoded in order to "read" the header properly.
Jul 17 '05 #2

P: n/a

On 2 Apr 2004 01:11:08 -0800, Paul <pa********@hotmail.com> wrote:
I'm attempting to parse a binary file for which I have the format. The
format states that the general packet format is as follows

Message header
Hex Length of whole binary packet
Binary Word of above Hex Length
etc.


None of these terms have standard definitions. Look elsewhere in the
document to see how these terms are interpreted for this particular file
format. Post the document if you still can't figure it out.
Jul 17 '05 #3

P: n/a
I have to agree with previous contributors, but....

There are always ways of applying guesses by using common definitions. I
will analyse like this:

1. Hex means data is presented in hexadecimal format
2. Binary os obvious
3. Word is usually a 16 bit value. (compare: bit, byte, word, longword etc)
4. ength, since this is a header of course the length of the coming data
block
5. I assume the binary data length, i.e. number of binary words correspond
to the length value

No good answers but some guesses, but still one important problem: What is
the length of the hex value? If not specified this can be one byte, two
bytes, four bytes (these are the most common) or any length. I would guess
for the moment that it is one byte, i.e. two characters.

So an examle of how my interpretation would look like with some data:

0A
10011010100101101011010111100111011010111000110111 01001101011000101111000111
01100111001111100111110100110011010110011010110101 10101011010110100111001011
01101010
Ok, so what does this the tell me? Well, with these conclusions it seems
that your "binary" file is stored as a textfile, which is very uncommon and
stupid since it only adds quite a lot of length to the file. So in the end
here I am probably wrong anyway.

Final answer will then be that your description is not only very sloppy but
extremely bad. A lot of information is missing and leasve open areas for
guessing.

E.T. - wants a homing phone
"Paul" <pa********@hotmail.com> wrote in message
news:ca*************************@posting.google.co m...
Hi,

(First apologies if this is not the most relevant place to post this
but I wasn't sure of where was and I am writing my app in VB.)

I'm attempting to parse a binary file for which I have the format. The
format states that the general packet format is as follows

Message header
Hex Length of whole binary packet
Binary Word of above Hex Length
etc.

I just wanted to make sure of a couple of terms before I start - most
notably 'Hex Length' and 'Binary Word'.
I guess binary word is just a binary representation of the hex length
e.g. if the hex length was 8 then the binary word of hex length would
be '1000'. However, what is meant by hex length and how is it
determined? If you could provide an example I'd be grateful.

Thanks

Paul
Jul 17 '05 #4

P: n/a
Hi,

Thanks to all that responded. Apologies if there was not a lot to go
on. I figured it out after analyzing the binary file in a hex viewer.
Take for example the following extract from the binary file

40 30 30 38 31 81 00

The first byte (40 or '@') is the packet header
Hex length = 30 + 30 + 38 + 31 = 129
Binary word of hex length is as somebody suggested the next two bytes,
i.e. 81 00, or 129 in decimal.

Thanks again,

Paul
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.