Crate mil_std_1553b

source ·
Expand description

§MIL STD 1553B

tests passing docs passing crates.io code coverage

This library implements a complete set of Rust structs for parsing or constructing messages that comply with the MIL STD 1553B communication protocal.

§Features

The following features make this library useable in constrained embedded systems for government, commercial, or military projects that can’t have virally licensed dependencies.

  • Does not use the standard library (no_std)
  • Does not allocate dynamic memory
  • Has no dependencies *
  • MIT licensed

* No runtime dependencies. If you use the derive feature flag, you will have to build proc-macro dependencies, but these are built and used on the host, not on the target system.

§Basic usage

§Creating a message

A message can be built using the constructor methods of Message, CommandWord, StatusWord, and DataWord.

    use mil_std_1553b::*;

    let message = Message::<3>::new()
        .with_command(CommandWord::new()
            .with_address(Address::Value(12))
            .with_subaddress(SubAddress::Value(5))
            .with_word_count(2)
            .build().unwrap()
        )
        .with_data(DataWord::new())
        .with_data(DataWord::new())
        .build()
        .unwrap();

    assert_eq!(message.length(),3);

§Parsing a message

§Command messages

Messages can be parsed as command messages, and the leading command word will determine how many data words will be parsed from the buffer.

    use mil_std_1553b::*;

    let message: Message = Message::read_command(&[
        0b10000011, 
        0b00001100, 
        0b00100010, 
        0b11010000, 
        0b11010010
    ])
    .unwrap();

    assert_eq!(message.length(),2);
§Status messages
    use mil_std_1553b::*;

    let message: Message = Message::read_status(&[
        0b10000011, 
        0b00001100, 
        0b01000010, 
        0b11010000, 
        0b11010010
    ])
    .unwrap();

    assert_eq!(message.length(), 2);

§Parsing a word

Words can be parsed from two-byte byte arrays or u16s. Data words can also be created from strings.

    use mil_std_1553b::*;

    let word = DataWord::new()
        .with_bytes([0b01001000, 0b01001001])
        .with_calculated_parity()
        .build()
        .unwrap();

    assert_eq!(word.as_string(),Ok("HI"));

§Roadmap

§1.0.0

  • Words implemented
    • Command, Status, and Data words created
    • Words can be parsed from binary
    • Words can be converted into binary
    • Words have parsing tests
    • Words have conversion tests
    • Documentation exists for words
  • Messages implemented
    • Message struct is created
    • Messages can be constructed from words
    • Messages can be parsed from binary
    • Messages have parsing tests
    • Messages have conversion tests
    • Documentation exists for messages
  • Conveniance, standardization, documentation
    • Derive/macro creation of custom words for a message
    • Small fixes for enum and flag standardization
    • Fully documented code base
    • Maximum lints enforced and no unsafe code
  • Integration tests implemented
    • CI/CD pipelines building for all host -> cross compile targets
    • Round-trip tests (binary -> struct -> binary) exist for messages
    • Round-trip tests (binary -> struct -> binary) exist for words
    • Configuration tests (JSON) exist for words
    • Configuration tests (JSON) exist for messages

§2.0.0

  • Message pattern constructors designed
  • Directed pattern constructors implemented
    • BC - RT pattern implemented
    • BC - RT pattern tests implemented
    • RT - BC pattern implemented
    • RT - BC pattern tests implemented
    • RT - RT pattern implemented
    • RT - RT pattern tests implemented
    • Mode W/O Data (T) pattern implemented
    • Mode W/O Data (T) pattern tests implemented
    • Mode With Data (T) pattern implemented
    • Mode With Data (T) pattern tests implemented
    • Mode With Data (R) pattern implemented
    • Mode With Data (R) pattern tests implemented
  • Broadcast pattern constructors implemented
    • BC - RT pattern implemented
    • BC - RT pattern tests implemented
    • RT - RT pattern implemented
    • RT - RT pattern tests implemented
    • Mode W/O Data pattern implemented
    • Mode W/O Data pattern tests implemented
    • Mode With Data pattern implemented
    • Mode With Data pattern tests implemented

§Notes

§Words

A “word” in the 1553B standard is made up of twenty bits, total. Three sync bits, 16 bits of data (in one of three different formats), and a trailing parity bit 1. This means that there are two ways of referencing a particular bit- either with a bit index offset from the beginning of the word data or as a “bit time” offset from the beginning of the word, including the sync bits.

IndexSync1Sync2Sync30123456789101112131415Parity
Time---45678910111213141516171819-
Offset---0123456789101112131415-

The bit-time reference is used in the standard, but because we’re only dealing with the 16-bit data from each word in this project we’ll be using a zero-indexed reference in the actual code.

Structs§

  • Specifies the function that a remote terminal is to perform
  • Contains data that is being transmitted in a message.
  • Represents a field inside of a 16-bit word
  • A message sent between two terminals on the bus
  • A packet of data parsed from binary
  • Sent in response to a valid message from the bus controller

Enums§

  • The address of a remote terminal
  • Indicates that the remote terminal has received a valid broadcast command.
  • Informs the bus controller that the terminal has accepted bus control.
  • An error deriving from the software itself, rather than a terminal.
  • Used to differentiate between a command and status word.
  • This flag is set when a receiving terminal detects an error in a message.
  • A flag used by the bus controller to manage remote terminals on the bus.
  • Reserved bits that should always be zero
  • Used by a remote terminal to tell the bus controller that it needs to be serviced.
  • The address of a subsystem within a remote terminal.
  • This flag provides health data regarding subsystems of a remote terminal.
  • An error deriving from a remote terminal or bus controller.
  • Indicates that the remote terminal is busy
  • This flag is to inform the bus controller of faults in a remote terminal
  • The direction of message transmission from the point of view of the remote terminal.
  • Container enum for the different kinds of words

Traits§

  • Common functionality for service words
  • Common functionality for all words

Type Aliases§

  • A result type which uses the Error enum as the error type.