Parse input and handle changes of settings.
66 while (((time + 2) >= millis()) && (
Serial6.available() >= 11)) {
81 computedCRC.update(setting);
85 computedCRC.update(rawValue, 2);
86 uint16_t value =
toU16(rawValue);
88 byte rawExpectedCRC[4];
89 Serial6.readBytes(rawExpectedCRC, 4);
90 uint32_t expectedCRC =
toU32(rawExpectedCRC);
95 "Invalid footer for control message; discarding whole message"));
100 if (expectedCRC != computedCRC.finalize()) {
102 "Invalid CRC for control message; discarding whole message"));
107 Serial.print(
"Serial control message: setting = ");
108 Serial.print(setting);
109 Serial.print(
", value = ");
249 Serial.print(
"Unknown control setting: ");
250 Serial.print(setting);
258 DBG_DO(Serial.println(
"Invalid header for control message; discarding a byte"));
263 DBG_DO(Serial.println(
"Invalid header for control message; discarding a byte"));
ActivationController activationController
Instance of the activation controller.
AlarmController alarmController
Instance of the alarm controller.
void changeState(uint16_t state)
Change the current state.
void snooze()
Snooze alarm for 2 minutes.
void onConfirm()
Handle EOL confirm control setting from telemetry.
void onTargetInspiratoryFlow(uint16_t p_targetInspiratoryFlow)
Set the inspiratory flow target.
void onTriggerOffsetSet(uint16_t p_triggerOffset)
Set the desired offset for expiratory trigger.
void onInspiratoryDuration(uint16_t p_inspiratoryDuration)
Set the inspiration duration.
void onCycleSet(uint16_t p_cpm)
Set the desired number of cycles per minute.
void onLowTidalVolumeAlarmThresholdSet(uint16_t p_lowTidalVolumeAlarmThreshold)
Set threshold on tidal volume below which an alarm is raised.
void onlowRespiratoryRateAlarmThresholdSet(uint16_t p_lowRespiratoryRateAlarmThreshold)
Set alarm threshold for low respiratory rate.
void onLeakAlarmThresholdSet(uint16_t p_leakAlarmThreshold)
Set the threshold for leak that raise the alarm.
void onExpiratoryTermSet(uint16_t p_expiratoryTerm)
Set the desired expiratory term.
void onhighRespiratoryRateAlarmThresholdSet(uint16_t p_highRespiratoryRateAlarmThreshold)
Set alarm threshold for high respiratory rate.
void onTiMinSet(uint16_t p_tiMin)
Set min inspiratory time.
void onInspiratoryTriggerFlowSet(uint16_t p_inspiratoryTriggerFlow)
Set inspiratory trigger flow.
void onTiMaxSet(uint16_t p_tiMax)
Set max inspiratory time.
void onPeepSet(int16_t p_peep)
Set the desired PEEP.
void onPeakPressureAlarmThreshold(int16_t p_peakPressureAlarmThreshold)
Set the desired threshold for max peak pressure.
void onLowExpiratoryMinuteVolumeAlarmThresholdSet(uint16_t p_lowExpiratoryMinuteVolumeAlarmThreshold)
Set alarm threshold for low expiratory minute volume.
void onPlateauPressureSet(int16_t p_plateauPressure)
Set the desired plateau pressure.
void onPatientHeight(int16_t p_patientHeight)
Set the desired patient height.
void onPatientGender(int16_t p_patientGender)
Set the desired patient gender.
void onLowInspiratoryMinuteVolumeAlarmThresholdSet(uint16_t p_lowInspiratoryMinuteVolumeAlarmThreshold)
Set alarm threshold for low inspiratory minute volume.
void onHighInspiratoryMinuteVolumeAlarmThresholdSet(uint16_t p_highInspiratoryMinuteVolumeAlarmThreshold)
Set alarm threshold for high inspiratory minute volume.
void onVentilationModeSet(uint16_t p_ventilationControllerMode)
Set ventilation mode.
void onTargetTidalVolumeSet(uint16_t p_targetTidalVolume)
Set target tidal volume (used in VC modes)
void onHighExpiratoryMinuteVolumeAlarmThresholdSet(uint16_t p_highExpiratoryMinuteVolumeAlarmThreshold)
Set alarm threshold for high expiratory minute volume.
void onPlateauDurationSet(uint16_t p_plateauDuration)
Set the duration of Pause at the end of expiration in VC modes.
void onExpiratoryTriggerFlowSet(uint16_t p_expiratoryTriggerFlow)
Set expiratory trigger flow.
void onTriggerModeEnabledSet(uint16_t p_triggerEnabled)
Enable or disable expiratory trigger mode.
void onHighTidalVolumeAlarmThresholdSet(uint16_t p_highTidalVolumeAlarmThreshold)
Set threshold on tidal volume for which an alarm is raised.
void disable()
Disable countdown mode (used for debug)
void resetCountDown()
When the UI software on the Raspberry PI sends a heartbeat, reset countdown.
#define DBG_DO(statement)
Expand arbitrary code only when in debug mode.
MainController mainController
HardwareSerial Serial6(PIN_TELEMETRY_SERIAL_RX, PIN_TELEMETRY_SERIAL_TX)
static const uint8_t header[CONTROL_HEADER_SIZE]
uint16_t toU16(byte bytes[])
Convert an array of 2 bytes to a u16.
static const uint8_t footer[CONTROL_FOOTER_SIZE]
uint32_t toU32(byte bytes[])
Convert an array of 4 bytes to a u32.
#define DISABLE_RPI_WATCHDOG
Special value that can be used in a heartbeat control message to disable RPi watchdog.
@ PatientHeight
Patient's height in centimeters.
@ Heartbeat
Heartbeat used for the RPi watchdog feature (value is ignored except for the special value DISABLE_RP...
@ CyclesPerMinute
Number of cycles per minute (value bounds must be between 5 and 35)
@ TiMin
Minimum duration of inhalation in ms (value bounds must be between 100 and 3000)
@ HighInspiratoryMinuteVolumeAlarmThreshold
Threshold for high inspiratory minute volume alarm in L/min (value bounds must be between 10 and 40)
@ RespirationEnabled
State of the respiration (value must be 1 if enabled and 0 if disabled)
@ ExpiratoryTriggerFlow
Expiratory trigger flow in percent.
@ LowTidalVolumeAlarmThreshold
Threshold for low tidal volume in mL (value bounds must be between 0 and 1000)
@ TriggerEnabled
State of the trigger (value must be 1 if enabled and 0 if disabled)
@ PatientGender
Patient's gender (0 = male, 1 = female)
@ EolConfirm
Confirm end-of-line test step (value bounds must be between 0 and 0)
@ HighRespiratoryRateAlarmThreshold
Threshold for high respiratory rate alarm in cycle per minute (value bounds must be between 15 and 35...
@ LowExpiratoryMinuteVolumeAlarmThreshold
Threshold for low expiratory minute volume alarm in L/min (value bounds must be between 0 and 20)
@ LowInspiratoryMinuteVolumeAlarmThreshold
Threshold for low inspiratory minute volume alarm in L/min (value bounds must be between 0 and 20)
@ TargetTidalVolume
Target tidal volume in mL (value bounds must be between 50 and 2000)
@ LeakAlarmThreshold
Threshold for leak alarm in cL/min (value bounds must be between 0 and 10000)
@ InspiratoryDuration
Duration of inspiration in ms (value bounds must be between 200 and 3000)
@ HighTidalVolumeAlarmThreshold
Threshold for high tidal volume in mL (value bounds must be between 50 and 2000)
@ TargetInspiratoryFlow
Target flow during inspiration in L/min (value bounds must be between 5 and 80)
@ HighExpiratoryMinuteVolumeAlarmThreshold
Threshold for high expiratory minute volume alarm in L/min (value bounds must be between 10 and 40)
@ InspiratoryTriggerFlow
Inspiratory trigger flow in percent.
@ LowRespiratoryRateAlarmThreshold
Threshold for low respiratory rate alarm in cycle per minute (value bounds must be between 5 and 25)
@ Locale
Language of the system; this should be two letters (see ISO 639-1) in ASCII representation as two u8.
@ ExpiratoryTerm
Expiration term in the "Inspiration/Expiration" ratio given that Inspiration = 10 (value bounds must ...
@ PlateauPressure
Plateau pressure in mmH2O (value bounds must be between 100 and 400)
@ TiMax
Maximum duration of inhalation in ms (value bounds must be between 200 and 5000)
@ TriggerOffset
Trigger offset in mmH2O (value bounds must be between 0 and 100)
@ PEEP
PEEP in mmH2O (value bounds must be between 0 and 300)
@ AlarmSnooze
Alarm snooze (value must be 1 to snooze and 0 to unsnooze)
@ VentilationMode
Ventilation mode, must be one of the following:
@ PeakPressureAlarmThreshold
Threshold for peak pressure alarm in mmH2O (value bounds must be between 50 and 700)
@ PlateauDuration
Duration in ms of closing both valves to effectively measure plateau pressure in volume control modes...