Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support big and little endian DAF files #282

Open
5 tasks
ChristopherRabotin opened this issue Jul 16, 2024 · 0 comments
Open
5 tasks

Support big and little endian DAF files #282

ChristopherRabotin opened this issue Jul 16, 2024 · 0 comments
Labels
API: rust Related to the Rust API CLI-tools Command line interface Kind: new feature

Comments

@ChristopherRabotin
Copy link
Member

High level description

NAIF provides the SPACIT utility that converts any platform-compatible DAF file into its "transfer format" equivalent. The user then needs to run the same SPACIT tool on the other platform to rebuild a DAF file there. For example, a user may run this tool on a little endian platform to build the transfer file, and then run SPACIT on the big endian machine to build a DAF encoded in big endian.

The underlying mechanism to read and write byte arrays in ANISE is the zerocopy crate. This crate supports byte ordering with the byteorder crate feature. Hence, it should be possible to read and write in both byte orders regardless of the platform byte ordering.

Note: this revives an idea that was planned in #2.

Requirements

  • Add an CLI option to convert to DAF for little endian into a DAF for big endian machines
  • If possible, support reading little and big endian DAF files directly in ANISE without conversion

Test plans

  • Build a big endian SPK from a little endian SPK, and convert back again, ensuring that the CRC32 match after the round trip conversion
  • If the second requirement is completed, test loading the big endian SPK on the little endian platform used by Github actions
  • Find a big endian machine and convert a public DAF file into big endian, checking that it matches the one converted by ANISE

Design

This should rely on https://docs.rs/zerocopy/latest/zerocopy/byteorder/index.html. One idea would be to parse the endian flag and set an enum in the DAF structure. Then use that enum to set the type of the byte ordering for the FileRecord and other structures where byte ordering matters, i.e. where there are integers (signed or not). Floating point values do not have any byte ordering issues thanks to the IEEE754 specification: https://doc.rust-lang.org/std/primitive.f64.html#method.from_bits.

@ChristopherRabotin ChristopherRabotin added CLI-tools Command line interface API: rust Related to the Rust API Kind: new feature labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: rust Related to the Rust API CLI-tools Command line interface Kind: new feature
Projects
None yet
Development

No branches or pull requests

1 participant