【问题标题】:Satellite data processing error卫星数据处理错误
【发布时间】:2017-02-17 18:46:09
【问题描述】:

一个新的卫星数据处理中心刚刚建成,并准备使用从轨道卫星发送下来的实时数据进行初步测试。当第一条消息显示在屏幕上时,您会注意到许多数据值都超出了范围。
例如,在终端屏幕上定义为“增量时间”,它似乎超出了预期范围 [0.01 到 10,000.00 秒],但显示的值(作为双精度值)是 [-4.12318024e- 028 秒]。在进一步调查基于原始字节的数据流后,您会发现从卫星发送的该双字的原始数据为 [0xC0 0x83 0xA1 0xCA 0x66 0x55 0x40 0xBA]。在其中一台旧终端上,此数据显示正确,并且在预期范围内。

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

【问题讨论】:

    标签: time hex double word satellite


    【解决方案1】:

    啊,故障模式分析。确实很重要!

    嗯,其他终端正确显示数据-->终端和数据不兼容。

    也许是大端,小端?我希望“旧”终端是小端序,因为它可能是用 C 编码的。现在您可以解释数据了。

    这是一些代码

    #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);
     }
    

    输出:

    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
    

    用g++编译

    【讨论】:

    • 我试过reverse bytes + reverse bits + XOR 0x80,结果是2.39...但是...你不觉得,既然有问题,结果很可能是更“圆润”的东西,例如 20.0 或非凡的东西,例如 3.14159...
    • 为什么会这样?因为这是一个“学术”问题?在预期范围内! [0.01 到 10,000.00 秒]
    猜你喜欢
    • 2012-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    相关资源
    最近更新 更多