I am writing a serial communications program, which will connect to a data acquisition instrument and download data. I am using FPC/Lazarus in order to make the program platform independent so it can be deployed also on an embedded Linux system even though it is developed on Windows or Ubuntu on an x86 machine.
My problem is that the data downloaded are basically memory dumps of an array of measure point records where the record contains various data types including single precision floats, multi-byte integers and character arrays. The instrument contains a Motorola microcontroller so its endian is opposite that of the typical Windows PC. When I wrote my Windows only program in Delphi 7 I had to introduce swap functions to correct the endian of the various values after downloading the memory dump. This worked fine but was a bit tedious to do.... Now, however, the problem may be complicated because the program may well run on a CPU that is using the *same* endian structure as the original instrument in which case of course the swaps should not be done. So I need some detector or other to decide if swaps are needed. Is there some commonly used function to handle this or is there some conditional directive one can use to control the compiler to "do the right thing" depending on the target CPU endian? Or maybe this is a moot question if FPC is only so far running on platforms that have the same endian as x86 CPU:s? I have no information on this though... I can see at least these targets: - Windows and Linux on x86 CPU:s - Embedded Linux on ARM CPU:s Bo Berglund _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal