Skip to content

Big Endianess #141

Description

@guyou

I declared the following packet:

big_endian_packets

// https://ccsds.org/Pubs/133x0b2e2.pdf
struct PacketPrimaryHeader {
  packet_version_number: 3,
  packet_type: 1,
  secondary_header: 1,
  apid: 11,
}

packet CcsdsSpacePacket {
  header: PacketPrimaryHeader,
}

Then I use it in the folowing Rust code:

    let c = ccsds::CcsdsSpacePacket {
        header: PacketPrimaryHeader {
            packet_version_number: 0,
            packet_type: 1,
            secondary_header: 0,
            apid: 1,
        },
    };
    let b = c.encode_to_vec().unwrap();
    let file = File::create("ccsds.bin").unwrap();
    let mut writer = BufWriter::new(file);
    writer.write_all(&b);
    writer.flush();

I'm surprised by the result

$ xxd -b ~/Devel/pdl/pdl-tests/ccsds.bin 
00000000: 00000000 00101000                                      .(

I expected

00000000: 00010000 00000001                                      ..

What's wrong in my declaration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions