Exmbus.Parser.Apl.CompactFrame (Exmbus v0.3.0)

View Source

Parser for a CompactFrame.

A CompactFrame contains only the data bytes of a full frame. It must be used in conbination with a FormatFrame to create a full frame.

Summary

Functions

Given some options and a parsed context with a CompactFrame on top, will expand the top CompactFrame struct into a FullFrame struct and return {:ok, [%FullFrame{} | rest]}

This function will expand the compact frame into a full frame. If the APL in the context is not a CompactFrame, it will return {:next, ctx}

Functions

expand(ctx)

Given some options and a parsed context with a CompactFrame on top, will expand the top CompactFrame struct into a FullFrame struct and return {:ok, [%FullFrame{} | rest]}

The option :format_frame_fn must be set to a 2-arity function that receives a format signature and the remaining options, and return {:ok, %FormatFrame{}}

The Full-Frame-CRC from the compact frame will be verified against the expanded FullFrame, and an error returned if they do not match. This behaviour can be disabled with the option :verify_full_frame_crc

maybe_expand(ctx)

This function will expand the compact frame into a full frame. If the APL in the context is not a CompactFrame, it will return {:next, ctx}

parse(ctx)