flync_4_signal¶
The flync_4_signal module contains the building blocks for
describing communication data at every level of abstraction: from
individual Signals (raw bit-level data elements), through PDUs
(Protocol Data Units that group signals), up to Frames (the
protocol-specific transport units that carry PDUs on a bus).
Signal¶
A Signal is the smallest
data element in FLYNC. It describes a physical or logical value that
is transmitted on a bus, including how raw bits are scaled and
interpreted. Signals are bus-agnostic: the same signal definition can
be reused across CAN, LIN, or Ethernet transport layers.
Signals are not placed directly into PDUs; instead a
SignalInstance wraps a signal
with its placement information (bit offset, byte order, and, for J1939
signals, an optional spn — a reference into SAE J1939-71).
- class SignalDataType¶
Bases:
str,EnumSupported signal base data types for CAN, LIN, FlexRay, and Ethernet.
Enumeration of valid signal data types:
UINT8,UINT16,UINT32,UINT64,INT8,INT16,INT32,INT64,FLOAT32,FLOAT64,CHAR,BYTEARRAY. Each variant exposes the helpersnatural_bit_width(),is_float(),is_unsigned_integer(),is_signed_integer(), andis_complex_datatype().
- class Signal¶
Bases:
FLYNCBaseModelLogical or physical data element transmitted within a communication message.
Parameters¶
- namestr
Name of the signal.
- descriptionstr, optional
Optional textual description of the signal.
- bit_lengthint
Length of the signal in bits. Must be greater than 0.
- data_type
SignalDataType Base data type of the signal.
- factorfloat
Multiplication factor applied to the raw value to obtain the physical value. Defaults to
1.0.- offsetfloat
Additive offset applied after scaling to obtain the physical value. Defaults to
0.0.- lower_limitfloat, optional
Minimum physical value of the signal.
- upper_limitfloat, optional
Maximum physical value of the signal.
- unitstr, optional
Physical unit of the signal (e.g.
"km/h","°C").- initial_valuefloat | int | bytes | str, optional
Optional initial value of the signal at startup, expressed as the raw wire value (no
factor/offsetapplied). Forcharsignals pass astr; forbytearraysignals passbytes.- value_encoding
ValueEncoding, optional Optional conversion from raw values to text labels. One of
TextTable(inclusive range → label; omitto_valuefor a single value, it defaults tofrom_value),BitfieldTextTable(named bitfield groups, one active state per group), orBitmaskFlags(independent on/off flags, multiple may be active simultaneously). May be combined withfactor/offset/unitto express a mixed linear-and-text-table conversion.- spnint, optional
J1939 Suspect Parameter Number (SPN). Identifies the parameter from the SAE J1939-71 database that this signal represents. Only meaningful for signals carried by J1939 Parameter Groups; a PDU packed by a non-J1939 frame must not contain a signal with an SPN.
- class SignalInstance¶
Bases:
InstancePlacementPlacement of a
Signalat a specific bit offset within a PDU.Parameters¶
- signal
Signal Signal being instantiated.
- signal
- class InstancePlacement¶
Bases:
FLYNCBaseModelShared placement metadata for signal and signal-group instances within a PDU.
Parameters¶
- bit_positionint, optional
Non-negative bit offset in the PDU.
- update_indication_bit_positionint, optional
Bit position used to indicate that the value has been updated.
- endiannessLiteral[“BE”, “LE”]
Byte order for this instance. Defaults to
"little_endian".
Value Encodings¶
A Signal may carry an optional ValueEncoding that converts raw integer values into text labels.
Three variants are supported, selected by the type discriminator:
|
Description |
|---|---|
|
Maps single raw values as well as inclusive raw value ranges to text labels.
Use this for ordinary enumerated signals, for reserved sentinel codes such as
|
|
Decodes the signal as a set of named bit-region groups, each with its own enum of mutually exclusive states. Use this when several unrelated small enums are packed into one signal. |
|
Decodes the signal as a set of independent on/off flags, each
identified by a disjoint |
A signal can combine factor/offset/unit with any of the
text-table encodings to express the common “linear conversion plus
reserved sentinel values” pattern (e.g. a speed signal in km/h with
raw 65535 mapped to Signal_Not_Available).
Examples
- class TextTable¶
Bases:
FLYNCBaseModelDecodes the signal as a set of TextEntries.
Parameters¶
- typeLiteral[“text_table”]
Discriminator selecting this value-encoding variant.
- entrieslist of
TextEntry Non-empty list of range-to-label mappings. Ranges must not overlap and labels must be unique within the table.
- class TextEntry¶
Bases:
FLYNCBaseModelMapping of an inclusive raw value range to a label.
For a value range: Use the keys
from_valueandto_valueto define upper and lower bounds.For a single value: Either define
from_valueandto_valuewith the same value or simply use the keyvalue.
Parameters¶
- valueint
Single value. Optional; defaults to None for range entries.
- from_valueint
Inclusive lower bound of the raw value range. Optional; defaults to value for single-value entries.
- to_valueint
Inclusive upper bound of the raw value range. Optional; defaults to value for single-value entries.
- labelstr
Human-readable label for this range (e.g.
"Low","Medium").
- class BitfieldTextTable¶
Bases:
FLYNCBaseModelDecodes a signal as a set of independent
BitfieldGroupregions.Each group occupies a disjoint mask of the signal’s bits and carries its own enum of mutually exclusive states. Use
BitmaskFlagsinstead when the bits represent independent on/off flags rather than sub-enums.Parameters¶
- typeLiteral[“bitfield_text_table”]
Discriminator selecting this value-encoding variant.
- groupslist of
BitfieldGroup Non-empty list of bitfield groups. Group names must be unique and group masks must be pairwise disjoint (no shared bits).
- class BitfieldGroup¶
Bases:
FLYNCBaseModelOne named region of bits within a signal, with its own enum of states.
Matching logic for a state
sof this group iss.from_value <= (raw & mask) <= s.to_value. Exactly one state is active per group at any time.Parameters¶
- namestr
Name of the bitfield group (e.g.
"Problem").- maskint
Bitmask selecting the bits that belong to this group. Must be strictly positive and fit within the owning signal’s
bit_length(checked at signal level).- stateslist of
BitfieldState Non-empty list of states defined for this group. State values must lie inside
maskand may not overlap; labels must be unique within the group.
- class BitfieldState¶
Bases:
FLYNCBaseModelMapping of an inclusive bitfield range to a label of states.
For a bitfield range: Use the keys
from_valueandto_valueto define upper and lower bounds.For a single bit: Either define
from_valueandto_valuewith the same value or simply use the keyvalue.
Parameters¶
- labelstr
Symbolic name of this state (e.g.
"ProblemFailure").- valueint, optional
Single bit. Defaults to None for range entries.
- from_valueint, optional
Inclusive lower bound for
(raw & group.mask). Defaults to value for single-bit entries. Must be greater or equal to 0.- to_valueint, optional
Inclusive upper bound for
(raw & group.mask). Defaults to value for single-bit entries. Must be greater or equal to 0.
- class BitmaskFlags¶
Bases:
FLYNCBaseModelDecodes a signal as a set of independent on/off flags.
Each
BitmaskFlagis active if(raw & flag.mask) == flag.mask; the decoded value of the signal is the set of active flag labels. Several flags can be active at the same time.Typical use case: a function relevance vector where each bit names one vehicle function as currently relevant or awake.
Use
BitfieldTextTableinstead when the bits represent mutually exclusive sub-enums rather than independent flags.Parameters¶
- typeLiteral[“bitmask_flags”]
Discriminator selecting this value-encoding variant.
- flagslist of
BitmaskFlag Non-empty list of flags. Labels must be unique and masks must be pairwise disjoint (no shared bits).
- class BitmaskFlag¶
Bases:
FLYNCBaseModelOne named on/off flag inside a
BitmaskFlagsencoding.A flag is considered active when
(raw & mask) == mask— i.e. every bit ofmaskis set in the raw signal value. A singleBitmaskFlagmay cover one bit (the common case) or several bits that must all be set together.Parameters¶
- maskint
Bitmask identifying this flag. Must be strictly positive and fit within the owning signal’s
bit_length(checked at signal level).- labelstr
Human-readable name of the flag (e.g.
"MirrorLeft").
Signal Groups¶
A SignalGroup collects several
SignalInstance placements that are
always transmitted together. Each contained SignalInstance carries a
bit_position interpreted as an offset relative to the group’s
origin — i.e. the
bit_position
where the group is placed inside a PDU; the absolute PDU offset of a
signal in a placed group is therefore
group_instance.bit_position + signal_instance.bit_position.
A SignalGroupInstance places the
entire group at a single bit offset within a PDU, analogous to how
SignalInstance places a single signal.
The group’s footprint inside a PDU is the largest end-bit reached by any
of its placed signal instances; instances without a bit_position are
treated as unplaced and skipped during footprint and overlap checks.
Signal instances inside the same group are also checked for mutual
overlap, mirroring the placement checks performed at the PDU level.
- class SignalGroup¶
Bases:
FLYNCBaseModelA reusable group of signal instances transmitted together within a PDU.
Each contained
SignalInstancecarries abit_positioninterpreted as an offset relative to the group’s origin — that is, relative to theSignalGroupInstance.bit_positionwhere the group is placed inside a PDU. Signal instances without abit_positionare treated as unplaced and skipped during overlap and footprint checks.Parameters¶
- namestr
Name of the signal group.
- descriptionstr, optional
Optional textual description of the group.
- signalslist of
SignalInstance Non-empty list of placed signal instances contained in this group.
- class SignalGroupInstance¶
Bases:
InstancePlacementPlacement of a
SignalGroupat a specific bit offset within a PDU.Parameters¶
- signal_group
SignalGroup Signal group being instantiated.
- signal_group
PDU¶
A PDU (Protocol Data Unit) is the container that groups signals
for transmission. PDUs are defined independently of any specific bus
and stored in communication/channels/pdus/. A
PDUInstance then places a named
PDU at a given bit offset inside a frame.
There are three PDU types, distinguished by the type discriminator field:
|
Description |
|---|---|
|
Non-multiplexed PDU containing a flat list of signal (group) instances. |
|
PDU with a selector signal; the active signal group depends on its value. |
|
Ethernet Container PDU that packs several other PDUs into one payload. |
- class PDU¶
Bases:
FLYNCBaseModelProtocol Data Unit base class.
Parameters¶
- namestr
Unique name of the PDU.
- lengthint
Length of the PDU payload in bytes. Must be greater than 0.
- pdu_usageLiteral[str], optional
Tag identifying special usage of the PDU. One of: “application”, “bap”, “diag_request”, “diag_response”, “diag_state”, “network_management”, “other”, “service”, “tpl”, “xcp_pre_configured”, “xcp_runtime_configured”.
- descriptionstr, optional
Optional human-readable description.
Standard PDU¶
- class StandardPDU¶
Bases:
PDUNon-multiplexed PDU containing a flat list of signal instances.
Parameters¶
- signalslist of
SignalInstance Signal instances placed within this PDU.
- signal_groupslist of
SignalGroupInstance Signal group instances placed within this PDU.
- signalslist of
Multiplexed PDU¶
- class MultiplexedPDU¶
Bases:
PDUPDU with a selector signal that determines which signal group is active.
Parameters¶
- selector_signal
SignalInstance The selector signal whose value determines the active mux group.
- static_grouplist of
PDUInstance, optional Optional PDU Instances with signals that are always present regardless of the active mux group. A single PDU Instance (unwrapped mapping) is accepted as well and coerced into a one-element list.
- mux_groupslist of
MuxGroup One entry per distinct selector value. Must contain at least one mux group.
- selector_signal
- class MuxGroup¶
Bases:
FLYNCBaseModelSet of signals active for a specific multiplexer selector value.
Parameters¶
- selector_valueint
The value of the selector signal that activates this group. Must be greater than or equal to 0.
- pdu
PDUInstance The PDU Instance that is active for this selector_value.
Container PDU¶
- class ContainerPDUHeader¶
Bases:
FLYNCBaseModelPer-slot header configuration for a
ContainerPDU.Parameters¶
- id_length_bitsint
Bit length of the PDU ID field. Must be a multiple of 8 and at most 32.
- length_field_bitsint
Bit length of the payload-length field. Must be a multiple of 8 and at most 32.
- class ContainerPDU¶
Bases:
PDUEthernet Container PDU that packs multiple PDUs into one frame payload.
Each contained PDU is prefixed with a header carrying its ID and length, allowing the receiver to demultiplex the slots at runtime.
Parameters¶
- pdu_idint
Numeric identifier for this container PDU on the network. Must be greater than or equal to 0.
- header
ContainerPDUHeader Per-slot header format specifying the bit widths of the ID and length fields.
- contained_pduslist of
ContainedPDURef PDUs packed inside this container, each referenced by name.
- class ContainedPDURef¶
Bases:
FLYNCBaseModelReference to a PDU packed inside a
ContainerPDU.Parameters¶
- header_idint
Numeric identifier greater than 0 placed in the slot header for this contained PDU.
- pdu_refstr
Name of the referenced PDU.
- offsetint, optional
Bit offset of this slot (header + payload) within the container payload. When multiple PDUs are packed sequentially this encodes the start position of each slot so receivers can locate it without parsing preceding slots. Must be greater than or equal to 0.
- class PDUInstance¶
Bases:
FLYNCBaseModelPlacement of a PDU at a specific bit offset within a CAN or LIN frame.
Parameters¶
- pdu_refstr
Name of the referenced PDU.
- bit_positionint, optional
Bit offset where this PDU begins within the frame. Must be greater than or equal to 0.
- update_bit_positionint, optional
Bit position of the update indication bit, when applicable. Must be greater than or equal to 0.
Frame¶
A Frame is the protocol-specific transport unit that carries one
or more PDUs on a physical bus. CAN and CAN FD frames are defined
inside communication/channels/can/; LIN frames inside
communication/channels/lin/; J1939 frames alongside CAN frames in
communication/channels/can/. All frame types reference PDUs by
name via PDUInstance.
For Ethernet, there is no frame layer — sockets reference a
ContainerPDU directly via a
pdu_sender or pdu_receiver deployment.
- class Frame¶
Bases:
FLYNCBaseModelProtocol-agnostic frame base class.
Parameters¶
- namestr
Unique name of the frame.
- lengthint
Length of the frame payload in bytes.
- frame_usageLiteral[str], optional
Tag identifying special usage of the frame. One of:
"application"marks the frame as carrying regular application traffic."bap"marks the frame as carrying BAP (FIBEX compatibility)."diag_request"marks the frame as diagnostics request."diag_response"marks the frame as diagnostics response."diag_state"marks the frame as diagnostics state."network_management"marks the frame as carrying Network Management traffic."other"marks the frame as other usage."service"marks the frame as service."tpl"marks the frame as carrying a transport protocol."xcp_pre_configured"marks the frame as static XCP."xcp_runtime_configured"marks the frame as dynamic XCP.
- descriptionstr, optional
Optional human-readable description.
- packed_pduslist of
PDUInstance PDU instances placed at fixed bit offsets within this frame.
- class CANFrameBase¶
Bases:
FrameShared fields for CAN 2.0 and CAN FD frames.
Parameters¶
- can_idint
CAN message identifier.
- id_formatLiteral[“standard_11bit”, “extended_29bit”]
Identifier format.
- timing
FrameTransmissionTiming, optional Transmission timing for this frame.
- class CANFrame¶
Bases:
CANFrameBaseClassical CAN frame (CAN 2.0A/B).
Parameters¶
- can_idint
CAN message identifier. Range: [0, 0x7FF] for
"standard_11bit", [0, 0x1FFFFFFF] for"extended_29bit".- id_formatLiteral[“standard_11bit”, “extended_29bit”]
Identifier format.
- is_remote_framebool
Whether this is a Remote Transmission Request (RTR) frame. Defaults to
False.
- class CANFDFrame¶
Bases:
CANFrameBaseCAN FD frame.
Supports payloads up to 64 bytes and an optional bit-rate switch for the data phase.
Parameters¶
- can_idint
CAN message identifier. Same range rules as
CANFrame.- id_formatLiteral[“standard_11bit”, “extended_29bit”]
Identifier format.
- bit_rate_switchbool
Enables a higher bit rate during the data phase. Defaults to
True.- error_state_indicatorbool
Error State Indicator flag. Defaults to
False.
- class J1939Frame¶
Bases:
FrameBasic J1939 Frame.
Parameters¶
- typeLiteral[“j1939”]
Discriminator tag selecting this frame kind when parsed from a CAN bus frame list.
- priorityint
J1939 message priority.
- pdu_formatint
PDU Format (PF) field. Values below 240 select the PDU1 format, where
pdu_specificis a Destination Address; values 240-255 select the PDU2 format, wherepdu_specificis a Group Extension.- pdu_specific: int
Message PDU Specific (PS) field. For PDU1 (
pdu_format< 240) it is a Destination Address; for PDU2 (pdu_format>= 240) it is a Group Extension that groups related messages.- data_page: int
Message data page.
- extended_data_page: int
Message extended data page.
- destination_type: Literal[“global”, “specific”]
Destination type. For PDU1 (
pdu_format< 240) thepdu_specificfield is a destination address:"specific"targets a single node (DA 0-254) and"global"broadcasts to every node (DA = 255). For PDU2 (pdu_format>= 240) the message is always a group broadcast, so this must be"global".- timing
FrameTransmissionTiming, optional Transmission timing for this frame.
Notes¶
A J1939 message carries exactly one Parameter Group (one PGN) in its 8-byte data field, so
packed_pdusmay contain at most one entry. This is unlike classical CAN, where a single frame may pack several PDUs.
- class LINFrame¶
Bases:
FrameLIN unconditional frame.
Parameters¶
- lin_idint
6-bit LIN frame identifier in the range [0, 0x3F].
- checksum_typeLiteral[“classic”, “enhanced”]
LIN checksum model. Defaults to
"enhanced".- timing
FrameTransmissionTiming, optional Transmission timing for this frame.
PDU Sender / Receiver Deployments¶
- class PDUSender¶
Bases:
FLYNCBaseModelDeployment that publishes a PDU onto a socket.
Transport (TCP/UDP, IP address, port) is owned by the enclosing socket; this model only binds a PDU to that socket. The publishing ECU is the owner of the socket carrying this deployment.
Parameters¶
- deployment_typeLiteral[“pdu_sender”]
Discriminator value for
DeploymentUnion.- pdu_refstr
Name of a PDU declared under
communication.channels— any ofStandardPDU,MultiplexedPDU, orContainerPDU. Validated at workspace level once the full model is assembled.
- class PDUReceiver¶
Bases:
FLYNCBaseModelDeployment that subscribes to a PDU on a socket.
Transport (TCP/UDP, IP address, port) is owned by the enclosing socket; this model only binds a PDU to that socket. The receiving ECU is the owner of the socket carrying this deployment.
Parameters¶
- deployment_typeLiteral[“pdu_receiver”]
Discriminator value for
DeploymentUnion.- pdu_refstr
Name of a PDU declared under
communication.channels— any ofStandardPDU,MultiplexedPDU, orContainerPDU. Validated at workspace level once the full model is assembled.
PDU Forwarder Deployments¶
A PDU Forwarder is a third per-PDU role (alongside pdu_sender
and pdu_receiver) that consumes a PDU on its parent carrier and re-emits
it on one or more egresses. The same primitive exists on both sides of the
modeled network:
PDUForwarderis an Ethernet-side deployment that lives inside a socket’sdeploymentsblock.CANFrameForwarderis a CAN-interface list entry underforwarder_framesonCANInterface.
Each forwarder lists one or more
ForwarderEgress items — a discriminated
union of CANFrameEgress (re-emit on a CAN
frame) and EthSocketEgress (re-emit on an
Ethernet socket). Optional extract_pdu_ref on an egress selects a single
inner PDU when the ingress is a
ContainerPDU.
- class PDUForwarder¶
Bases:
FLYNCBaseModelSocket deployment that consumes a PDU on its parent socket and re-emits it on one or more egresses.
Parameters¶
- deployment_typeLiteral[“pdu_forwarder”]
Type discriminator for this forwarder.
- pdu_refstr
Reference to the PDU being forwarded.
- egressesList[
ForwarderEgress] List of egress targets where the forwarded PDU is re-emitted. Must contain at least one egress.
- class CANFrameForwarder¶
Bases:
FLYNCBaseModelCAN-interface forwarder that consumes an ingress frame and re-emits it on one or more egresses.
Parameters¶
- frame_refstr
Reference to the CAN frame being forwarded.
- egressesList[
ForwarderEgress] List of egress targets where the forwarded frame is re-emitted. Must contain at least one egress.
- class ForwarderEgress¶
Bases:
RootModelDiscriminated-union wrapper over a single forwarder egress (
CANFrameEgressorEthSocketEgress).
- class CANFrameEgress¶
Bases:
FLYNCBaseModelForwarder egress that re-emits the forwarded PDU on a CAN frame.
Parameters¶
- egress_typeLiteral[“can_frame”]
Type discriminator for this egress.
- bus_refstr
Reference to the target CAN bus.
- frame_refint
Reference to the target CAN frame.
- extract_pdu_refstr, optional
Optional reference to a PDU to extract from the forwarded data.
- class EthSocketEgress¶
Bases:
FLYNCBaseModelForwarder egress that re-emits the forwarded PDU on an Ethernet socket (unicast/multicast follows the target’s endpoint_address).
Parameters¶
- egress_typeLiteral[“eth_socket”]
Type discriminator for this egress.
- socket_refstr
Reference to the target Ethernet socket.
- extract_pdu_refstr, optional
Optional reference to a PDU to extract from the forwarded data.
Frame Timing¶
Transmission timing is configured at the frame layer for every
protocol. Each CAN, CAN FD, or LIN frame may carry an optional
timing field that drives cyclic, event-driven, and debounce
scheduling of the frame as a whole on the wire.
- class FrameTransmissionTiming¶
Bases:
FLYNCBaseModelFrame transmission timing configuration.
Parameters¶
- debounce_timefloat, optional
Debounce delay in seconds before transmission occurs.
- cyclic_timingslist of
FrameCyclicTiming Cyclic timing configurations.
- event_timingslist of
FrameEventTiming Event-driven timing configurations.
- class FrameCyclicTiming¶
Bases:
FLYNCBaseModelCyclic transmission timing.
Parameters¶
- cyclefloat
Cycle time in seconds. Must be greater than 0.
- class FrameEventTiming¶
Bases:
FLYNCBaseModelEvent-based transmission timing.
Parameters¶
- final_repetitionsint
Number of repetitions after an event is triggered. Defaults to
0.- repeating_time_rangefloat
Time interval in seconds between repetitions. Defaults to
0.0.