impure functionRadioModem_sync

Sync point of a radio modem: advances the serial and radio frames, moves the bytes through the buffers, and returns the next deadline

Information

impure: the function carries the state of the modem — like UartDevice_sync. Called again several times at the same simulated instant (Modelica iterates over events), it does nothing more: all its steps are driven by deadlines or consume what they process.

Inputs

TypeNameDefaultDescription
RadioModemmodem
RealcurrentTime
BooleanserRxLevelLogic level read on the RX pin (bytes coming from the microcontroller)
BooleanairLevelLevel of the radio frame heard (idle = high; already idle on the Modelica side when nothing audible)
BooleanairJamTwo transmitters or more at once: the frame being received is lost

Outputs

TypeNameDefaultDescription
BooleanserTxLevelLevel to hold on TX until the next sync point (idle = high)
BooleanairTxLevelBit being transmitted on air (idle = high)
BooleancarrierOnA radio frame is being transmitted
BooleanairRxBusyA radio frame is being received
IntegertxFillBytes waiting in the transmit buffer (UART -> air)
IntegerrxFillBytes waiting in the receive buffer (air -> UART)
RealairIdIdentifier of the module (1, 2, 3... one per instance)
IntegernSentRadio frames transmitted so far
IntegernReceivedRadio frames received intact so far
IntegernDroppedBytes lost so far because a buffer was full
IntegernCorruptedRadio frames lost so far: corrupted, collided, or cut by our own transmission in half duplex
RealnextWakeTimeNearest deadline: edge to transmit on either side, middle of a stop bit, byte ready to leave