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
| Type | Name | Default | Description |
|---|---|---|---|
| RadioModem | modem | ||
| Real | currentTime | ||
| Boolean | serRxLevel | Logic level read on the RX pin (bytes coming from the microcontroller) | |
| Boolean | airLevel | Level of the radio frame heard (idle = high; already idle on the Modelica side when nothing audible) | |
| Boolean | airJam | Two transmitters or more at once: the frame being received is lost |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | serTxLevel | Level to hold on TX until the next sync point (idle = high) | |
| Boolean | airTxLevel | Bit being transmitted on air (idle = high) | |
| Boolean | carrierOn | A radio frame is being transmitted | |
| Boolean | airRxBusy | A radio frame is being received | |
| Integer | txFill | Bytes waiting in the transmit buffer (UART -> air) | |
| Integer | rxFill | Bytes waiting in the receive buffer (air -> UART) | |
| Real | airId | Identifier of the module (1, 2, 3... one per instance) | |
| Integer | nSent | Radio frames transmitted so far | |
| Integer | nReceived | Radio frames received intact so far | |
| Integer | nDropped | Bytes lost so far because a buffer was full | |
| Integer | nCorrupted | Radio frames lost so far: corrupted, collided, or cut by our own transmission in half duplex | |
| Real | nextWakeTime | Nearest deadline: edge to transmit on either side, middle of a stop bit, byte ready to leave |