Topics

Endian issues...final chapter

Jack, W8TEE
 

All:

Jerry and I have continued to argue offline about passing data between machines that use different endians. (The endian idea is that an int data type can be organized in Big Endian or Little Endian, that is, are the two bytes organized as Hi-byte/Lo-byte or Lo-byte/Hi-byte.) His position is that C code is endian agnostic, meaning you don't have to worry about it. My position is that any communication between those two different endians must take it into consideration.

Jerry found a good discussion at:


In that reference, the Files and byte swap sections states:

    Endianness is a problem when a binary file created on a computer is read on another computer with different endianness.

which is what I was trying to say all along.

Anyway, I said I wouldn't waste anymore of the groups time on this, but I thought the Wikipedia source Jerry found kinda settles the issue...at least it has for me.

Jack, W8TEE

Jerry Gaffke
 

We agree that  "Endianness is a problem when a binary file created on a computer is read on another computer with different endianness."

Where we seem to disagree is that I am convinced this code will always prints a value of "4"
regardless of whether the machine is big or little endian:

  long data32;    int  data8;
  data32 = 0x04030201;
  data8 = data32>>24;
  printf("%d \n", data8);

From this, we can create the endian agnostic code at the top of post 44018.  
Arv is correct, this is not something most of you need to worry about.
I'm totally done here.
Unless you want to talk about Gulliver's Travels.

Jerry


On Sat, Mar 10, 2018 at 08:42 am, Jack Purdum wrote:
   Endianness is a problem when a binary file created on a computer is read on another computer with different endianness.
 

Michael Hagen
 

If Push comes to Stack, who wins Big Injun or Little Injun?


On 3/10/2018 10:48 AM, Jerry Gaffke via Groups.Io wrote:
We agree that  "Endianness is a problem when a binary file created on a computer is read on another computer with different endianness."

Where we seem to disagree is that I am convinced this code will always prints a value of "4"
regardless of whether the machine is big or little endian:

  long data32;    int  data8;
  data32 = 0x04030201;
  data8 = data32>>24;
  printf("%d \n", data8);

From this, we can create the endian agnostic code at the top of post 44018.  
Arv is correct, this is not something most of you need to worry about.
I'm totally done here.
Unless you want to talk about Gulliver's Travels.

Jerry


On Sat, Mar 10, 2018 at 08:42 am, Jack Purdum wrote:
   Endianness is a problem when a binary file created on a computer is read on another computer with different endianness.
 

-- 
Mike Hagen, WA6ISP
10917 Bryant Street
Yucaipa, Ca. 92399
(909) 918-0058
PayPal ID  "MotDog@..."
Mike@...

Ashhar Farhan
 

ietf solved this by insisting that internet protocos SHOULD be in plain text. it makes debuggera out our eyeballs and prevents testing of friendships.

On 11 Mar 2018 12:27 am, "Michael Hagen" <motdog@...> wrote:

If Push comes to Stack, who wins Big Injun or Little Injun?


On 3/10/2018 10:48 AM, Jerry Gaffke via Groups.Io wrote:
We agree that  "Endianness is a problem when a binary file created on a computer is read on another computer with different endianness."

Where we seem to disagree is that I am convinced this code will always prints a value of "4"
regardless of whether the machine is big or little endian:

  long data32;    int  data8;
  data32 = 0x04030201;
  data8 = data32>>24;
  printf("%d \n", data8);

From this, we can create the endian agnostic code at the top of post 44018.  
Arv is correct, this is not something most of you need to worry about.
I'm totally done here.
Unless you want to talk about Gulliver's Travels.

Jerry


On Sat, Mar 10, 2018 at 08:42 am, Jack Purdum wrote:
   Endianness is a problem when a binary file created on a computer is read on another computer with different endianness.
 

-- 
Mike Hagen, WA6ISP
10917 Bryant Street
Yucaipa, Ca. 92399
(909) 918-0058
PayPal ID  "MotDog@..."
Mike@...

Jack, W8TEE
 

Totally agree when moving data between internet users. The downside is that binary 255 takes one byte but ASCII takes three bytes to push down a com link. If you are doing something computationally intensive, like moving FFT data to an SDR spectrum display, minimizing data transfer time can make a large performance difference. As Hans Summers (designer of the super-cool QCX transceiver from QRP Labs) pointed out, the endian issue must be handled even when writing to EEPROM on the same machine. You could store numeric data in EEPROM as ASCII, but then you need to pass through atoi() going into EEPROM and itoa() coming out. Clearly, Hans is storing his EEPROM data in binary.

CAT protocols like the one Ian Lee has worked on use an ASCII data transfer and it makes it so much easier to debug when something goes south. Even then, however, when commands can be as short as 10 bytes, someone reported a noticeable delay in response time. If you're only tool is a hammer, it should be no surprise that every problem looks like a nail. Binary versus ASCII protocols simply hangs a second tool on your belt. You need to decide which best solves your design problem.

Jack, W8TEE



From: Ashhar Farhan <farhanbox@...>
To: BITX20@groups.io
Sent: Sunday, March 11, 2018 12:49 AM
Subject: Re: [BITX20] Endian issues...final chapter

ietf solved this by insisting that internet protocos SHOULD be in plain text. it makes debuggera out our eyeballs and prevents testing of friendships.

On 11 Mar 2018 12:27 am, "Michael Hagen" <motdog@...> wrote:
If Push comes to Stack, who wins Big Injun or Little Injun?

On 3/10/2018 10:48 AM, Jerry Gaffke via Groups.Io wrote:
We agree that  "Endianness is a problem when a binary file created on a computer is read on another computer with different endianness."

Where we seem to disagree is that I am convinced this code will always prints a value of "4"
regardless of whether the machine is big or little endian:

  long data32;    int  data8;
  data32 = 0x04030201;
  data8 = data32>>24;
  printf("%d \n", data8);

From this, we can create the endian agnostic code at the top of post 44018.  
Arv is correct, this is not something most of you need to worry about.
I'm totally done here.
Unless you want to talk about Gulliver's Travels.

Jerry


On Sat, Mar 10, 2018 at 08:42 am, Jack Purdum wrote:
   Endianness is a problem when a binary file created on a computer is read on another computer with different endianness.
 

-- 
Mike Hagen, WA6ISP
10917 Bryant Street
Yucaipa, Ca. 92399
(909) 918-0058
PayPal ID  "MotDog@..."
Mike@...



Virus-free. www.avast.com

Jerry Gaffke
 

I agree with Jack.
There are many cases where ASCII protocols are just too cumbersome. 


On Sun, Mar 11, 2018 at 07:58 am, Jack Purdum wrote:
Binary versus ASCII protocols simply hangs a second tool on your belt. You need to decide which best solves your design problem.