Interface: ComposeFramesOptions
Options for composeAstmFrames.
Properties
startFrameNumber?
readonlyoptionalstartFrameNumber?:number
The frame number to start the sequence at: a whole number from 0 to 7.
Defaults to 1, the number ASTM gives the first frame of a transfer and the
one decodeAstmFrames expects to read first.
Any other value writes a continuation rather than the start of a transfer,
and that is what the option is for: composing one transfer across more than
one call. Concatenating composeAstmFrames(head) with
composeAstmFrames(tail, { startFrameNumber: n }), where n is the number
after the last frame head used, is byte-identical to composing the whole
list in a single call and decodes with an empty warnings array, across the
7 → 0 rollover included.
Decoded on its own, a stream that starts anywhere but 1 opens on a
sequence gap. The decoder never bridges a gap silently, so it warns
(ASTM_FRAME_SEQUENCE_GAP) and does not emit that first record.
What parseFramedAstm does after that varies with the message
shape and no rule is offered for it here. It may throw, under more than
one code, and it may return a message that is simply one record short. The
one thing that does hold is that the record layer never reports the loss:
parseFramedAstm hands the record parser only the frames the codec
vouched for, so message.warnings carries what the surviving records
warrant and nothing about the record that did not survive. Read
frameWarnings. That is the cost of the option rather than a defect in
the caller's records, and it is why 1 is the default.
Finding the number to continue from. Nothing here returns it, and the
frame count is not it once a record splits: decode the part you just
composed and read the last frame's number, then add one modulo 8, as in
((decodeAstmFrames(part).frames.at(-1)?.frameNumber ?? 0) + 1) % 8. A frame
carries no number only when the stream ends immediately after its STX,
which is not something this encoder writes, so that fallback never fires on
a part composed here. Getting the number wrong costs the record at the join,
warned rather than silently.
A value outside 0-7, or one that is not a whole number, is refused with
ASTM_FRAME_INVALID_START_FRAME_NUMBER.