I am still struggling!
The raw camera files may be either big endian or little endian and the endian is indicated by the first two bytes of the file. So I have written the following routine to read data once the byte order has been determined and stored in a variable "IsLittleEndian":
Code: Select all
Function ReadDataWord pLowByte, pHighByte, pIsLittleEndian, @pImageFile
put empty into tDataWord
If pIsLittleEndian then
## Seems the wrong way around to me yet works
put byte pLowByte to pHighByte of pImageFile into tdataWord
Repeat with N = pHighByte down to pLowByte
put byte N of pImageFile after tDataWord
My understanding of Endian is that we generally view all numbers as Big Endian i.e the first digit represents the largest multiplier and the last digit the units e.g 1234 decimal the 1 represents thousands the 4 single digits. Little Endian reverses the order of the digits e.g. 4321.
So far I have tested my routine with Little Endian data which means that I should be populating tDataWord from the highest byte position down to the lowest byte position to put the data into man readable big endian format. Yet the function above is working with Little Endian data when it should fail.
The data in tDataWord is passed back and processed by BinaryDecode. I use format types C, S or I. The dictionary describes the multi byte types as
S: convert next amount 2-byte chunks of data to unsigned integers in host byte order
Does "host byte order" mean that the call reads the bytes in the variable passed in a different order depending on the type of computer/processor/OS the application is being run on ? In other words should my routine be determining where it is being run, Apple,PC,Linux and extracting the bytes in the order of the host system in order to obtain the correct decodes from BinaryDecode.
So what is host byte order? The dictionary states
The order in which the local system (the "host") stores bytes when using multi- byte data types. This depends on the operating system and microprocessor your computer has.
Great, so do I need a database of OS and microprocessor combinations in order to use binary decode?
perplexed of North Lincolnshire