Probably wrong, but here's a shot at it using Ruby.
Up vote 0 down vote favorite share g+ share fb share tw.
I have a binary file , the definition of its content is as below : ( all data is stored in little endian (ie. Least significant byte first)) . The example numbers below are HEX 11 63 39 46 --- Time, UTC in seconds since 1 Jan 1970.
01 00 --- 0001 = No Fix, 0002 = SPS 97 85 ff e0 7b db 4c 40 --- Latitude, as double a1 d5 ce 56 8d 26 28 40 --- Longitude, as double f0 37 e1 42 --- Height in meters, as float fe 2b f0 3a --- Speed in km/h, as float 00 00 00 00 --- Heading (degrees? ), as float 01 00 --- RCR, log reason. 0001=Time, 0004=Distance 59 20 6a f3 4a 26 e3 3f --- Distance in meters, as double, 2a ---?
Don't know a8 --- Checksum, xor of all bytes above not including 0x2a the data from the Binary file "in HEX" is as below "F25D39460200269652F5032445401F4228D79BCC54C09A3A2743B4ADE73F2A83" I appreciate if you can support me to translate this data line based on the instruction before. Decimal hex link|improve this question edited Dec 12 '10 at 21:11Phrogz39.2k44693 asked Dec 12 '10 at 21:06waleed nosir31.
Despite the bad formatting of the instructions the content seems quite clear (except of course second-last byte). What is your specific problem with the description? – 6502 Dec 12 '10 at 21:17.
Probably wrong, but here's a shot at it using Ruby: hex = "F25D39460200269652F5032445401F4228D79BCC54C09A3A2743B4ADE73F2A83" ints = hex. Scan(/../). Map{ |s| s.
To_i(16) } raw = ints. Pack('C*') fields = raw. Unpack( 'VvEEVVVvE') p fields #=> 1178164722, 2, 42.2813707974677, -83.1970117467067, 1126644378, 1072147892, nil, 33578, nil p Time.
At( fields. First ) #=> 2007-05-02 21:58:42 -0600 I'd appreciate it if someone well-versed in #pack and #unpack would show me a better way to accomplish the first three lines.
I am not sure about the other values , but I am sure that the time is correct , . How did you do it. Are there any code in vb.net or C# to understand .
Thank you all for your support . – waleed nosir Dec 13 '10 at 19:02 @waleednosir 1. Convert each hex character pair to the integer value.
2. Create a raw byte array from all those integers, treating each as an unsigned byte. 3.
Extract the first four bytes (V) as an unsigned little-endian long. 4. Treat those as the epoch.
– Phrogz Dec 13 '10 at 19:07 Thanks so much , it works . Thanks again . But I do not understand how did you convert the integer value 1178164722 to time and date .
Also , why was the you have read the first HEX value in reverse to convert it to INTeger . I mean that the value 1178164722 is the decimal value of 46395DF2 while the first 4 bytes of my code were the reverse ie F25D3946 . Please note that your results are OK but I do not understand why.
Also , are there any simple code in VB.net or C# that does this nice things. . You have solved it in 3 lines of code only .
That is really amazing . – waleed nosir Dec 13 '10 at 20:59 @waleednosir Conversion from epoch to time object is part of the Time class in Ruby (or the Date in JavaScript, with milliseconds). The little-endian decoding causes the bytes to be read in reverse order.
I'm sorry, I don't know either VB.net or C# to be able to tell you how to accomplish the same task in those languages. Perhaps you should try a Google search such as "decoding byte streams little endian C#" – Phrogz Dec 13 '10 at 21:17 Thanks Phrogs for your clarification . I really appreciate this so much .
– waleed nosir Dec 13 '10 at 22:14.
My Cygnus Hex Editor could load such a file and, using structure templates, display the data in its native formats. Beyond that, it's just a matter of doing through each value and working out the translation for each byte.
Sorry for delay , I did not relealse that there is Accept or reject pathway of each question . It is my fault . I have accepted your genius answers and inspiration .
Sorry for delay – waleed nosir Dec 26 '10 at 15:21.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.