2

A new satellite data processing center has just been completed and ready for the initial testing using live data being sent down from an orbiting satellite. As the very first messages are displayed on the screen and you notice many of the data values are wildly out of range.
For example, on the terminal screen is something defined as “delta time” and it seems to be out of the expected range [0.01 to 10,000.00 seconds], but the value displayed (as a double) is [-4.12318024e-028 seconds]. After further investigation into the raw byte-based data stream, you find the original data being sent down from the satellite for this double word as [0xC0 0x83 0xA1 0xCA 0x66 0x55 0x40 0xBA]. On one of the old terminals, this data is displayed correctly and is within the expected range.

a. [5]  What caused this problem?
b. [5]  If this is the real problem, what should the actual value be?
terps24
  • 21
  • 2

1 Answers1

0

Ah, Failure Mode Analysis. Very important indeed!

Well, other terminal shows data correctly --> there is incompatibility between terminal and data.

Big Endian, little Endian perhaps? I am expecting the "old" terminal to be little Endian because it may have been coded in C. Now you can interpret the data.

Here is some code

#include  <stdio.h>

union myW {
    double x;
    // Recieved as:[0xC0 0x83 0xA1 0xCA 0x66 0x55 0x40 0xBA]
    unsigned char d[8] = {0x83, 0xC0,0xCA, 0xA1, 0x55, 0x66, 0xBA, 0x40};   
};

union myBad {
    double x;
    // Recieved as:[0xC0 0x83 0xA1 0xCA 0x66 0x55 0x40 0xBA]
    unsigned char d[8] = {0xC0, 0x83,0xA1, 0xCA, 0x66, 0x55, 0x40, 0xBA};   
};


int  main(void)
{
    myW value;
    value.x = 1.0;  // check how reasonable number looks like

    printf("Something reasonable: \n");
    for(int i = 0; i < 8; i++)
    {
        printf("%u ", value.d[i]);
    }   

    myW received;
    printf("\nWhat shouldve been displayed:\n");
    for(int i = 0; i < 8; i++)
    {
        printf("%u ", received.d[i]);
    }
    printf("\n%f\n", received.x);

    myBad bad;
    printf("\nBad output as:\n");
    for(int i = 0; i < 8; i++)
    {
        printf("%u ", bad.d[i]);
    }
    printf("\n%0.30f\n", bad.x);
 }

Output:

Something reasonable: 
0 0 0 0 0 0 240 63 
What shouldve been displayed::
131 192 202 161 85 102 186 64 
6758.334500

Bad output as:
192 131 161 202 102 85 64 186 
-0.000000000000000000000000000412

Compiled with g++

Makketronix
  • 1,389
  • 1
  • 11
  • 31
  • I tried reverse bytes + reverse bits + XOR 0x80, and the result is `2.39`... But... don't you think, since it's a problem, the result is likely to be something more "rounded", like `20.0` or something remarkable, like `3.14159`... – Déjà vu Oct 09 '16 at 13:10
  • Why do you expect that? Because it is an "academic" problem? It is within expected range! [0.01 to 10,000.00 seconds] – Makketronix Oct 09 '16 at 15:13