diff --git a/arduino/common/lib/CommsControl/CommsCommon.h b/arduino/common/lib/CommsControl/CommsCommon.h index 6ab31419237d80cd59d0de9b151168bf90884403..1a0ac7cf939514a4fc783d9f32cbece9e4e5c922 100644 --- a/arduino/common/lib/CommsControl/CommsCommon.h +++ b/arduino/common/lib/CommsControl/CommsCommon.h @@ -41,10 +41,10 @@ // enum of all transfer types enum PRIORITY : uint8_t { - DATA = PACKET_DATA, - CMD = PACKET_CMD, - ALARM = PACKET_ALARM, - UNSET = 0x00 + DATA_ADDR = PACKET_DATA, + CMD_ADDR = PACKET_CMD, + ALARM_ADDR = PACKET_ALARM, + UNSET_ADDR = 0x00 }; // payload consists of type and information @@ -52,7 +52,7 @@ enum PRIORITY : uint8_t { // information is set as information in the protocol class Payload { public: - Payload(PRIORITY type = PRIORITY::UNSET) {_type = type; } + Payload(PRIORITY type = PRIORITY::UNSET_ADDR) {_type = type; } Payload(const Payload &other) { _type = other._type; _size = other._size; @@ -66,7 +66,7 @@ public: } ~Payload() { unset(); } - void unset() { memset( _buffer, 0, PAYLOAD_MAX_SIZE_BUFFER); _type = PRIORITY::UNSET; _size = 0;} + void unset() { memset( _buffer, 0, PAYLOAD_MAX_SIZE_BUFFER); _type = PRIORITY::UNSET_ADDR; _size = 0;} void setType(PRIORITY type) { _type = type; } PRIORITY getType() {return _type; } diff --git a/arduino/common/lib/CommsControl/CommsControl.cpp b/arduino/common/lib/CommsControl/CommsControl.cpp index 58f6a2130e0075ab97b9c8cf3dfafd1e86bc215f..e8f601da3c1bf219338b2df719d98e9cdc301603 100644 --- a/arduino/common/lib/CommsControl/CommsControl.cpp +++ b/arduino/common/lib/CommsControl/CommsControl.cpp @@ -137,7 +137,7 @@ void CommsControl::receiver() { bool CommsControl::writePayload(Payload &pl) { PRIORITY payload_type = pl.getType(); - if (payload_type != PRIORITY::UNSET) { + if (payload_type != PRIORITY::UNSET_ADDR) { // create comms format using payload, the type is deduced from the payload itself CommsFormat comms = CommsFormat(pl); @@ -282,11 +282,11 @@ PRIORITY CommsControl::getInfoType(uint8_t &address) { // get link to queue according to packet format RingBuf<CommsFormat, COMMS_MAX_SIZE_RB_SENDING> *CommsControl::getQueue(PRIORITY &type) { switch (type) { - case PRIORITY::ALARM: + case PRIORITY::ALARM_ADDR: return &_ring_buff_alarm; - case PRIORITY::CMD: + case PRIORITY::CMD_ADDR: return &_ring_buff_cmd; - case PRIORITY::DATA: + case PRIORITY::DATA_ADDR: return &_ring_buff_data; default: return nullptr; diff --git a/arduino/common/lib/CommsControl/CommsFormat.cpp b/arduino/common/lib/CommsControl/CommsFormat.cpp index 94f3c8f726fbd0e47fc541c1e37eaff853cce7ff..01c4c882070e0e7b245f50eb726b93e01a4151d6 100644 --- a/arduino/common/lib/CommsControl/CommsFormat.cpp +++ b/arduino/common/lib/CommsControl/CommsFormat.cpp @@ -8,13 +8,13 @@ CommsFormat::CommsFormat(uint8_t info_size, uint8_t address, uint16_t control) { CommsFormat::CommsFormat(Payload &pl) { uint8_t address; switch (pl.getType()) { - case PRIORITY::ALARM: + case PRIORITY::ALARM_ADDR: address = PACKET_ALARM; break; - case PRIORITY::CMD: + case PRIORITY::CMD_ADDR: address = PACKET_CMD; break; - case PRIORITY::DATA: + case PRIORITY::DATA_ADDR: address = PACKET_DATA; break; default: diff --git a/arduino/hev_prototype_v1/src/UILoop.cpp b/arduino/hev_prototype_v1/src/UILoop.cpp index 6f86f3480221adb6b2ccb809a89f3a204ad57fcd..3cd93a6ee846190cad6070eb471ac8b72885f00e 100644 --- a/arduino/hev_prototype_v1/src/UILoop.cpp +++ b/arduino/hev_prototype_v1/src/UILoop.cpp @@ -25,7 +25,7 @@ void UILoop::receiveCommands() // check any received payload if(_comms->readPayload(_plReceive)) { - if (_plReceive.getType() == PRIORITY::CMD) { + if (_plReceive.getType() == PRIORITY::CMD_ADDR) { // apply received cmd to ui loop cmd_format cmd; _plReceive.getPayload(reinterpret_cast<void*>(&cmd)); @@ -33,7 +33,7 @@ void UILoop::receiveCommands() } // unset received type not to read it again - _plReceive.setType(PRIORITY::UNSET); + _plReceive.setType(PRIORITY::UNSET_ADDR); } } @@ -56,7 +56,7 @@ void UILoop::reportFastReadings() _fast_data.pressure_o2_regulated = readings_avgs.pressure_o2_regulated; _fast_data.pressure_diff_patient = readings_avgs.pressure_diff_patient; - _plSend.setPayload(PRIORITY::DATA, reinterpret_cast<void *>(&_fast_data), sizeof(_fast_data)); + _plSend.setPayload(PRIORITY::DATA_ADDR, reinterpret_cast<void *>(&_fast_data), sizeof(_fast_data)); _comms->writePayload(_plSend); _fast_report_time = tnow; } @@ -107,7 +107,7 @@ void UILoop::reportReadbackValues() // _readback_data.peep = _breathing_loop->peep(); _readback_data.inhale_exhale_ratio = _breathing_loop->getIERatio(); - _plSend.setPayload(PRIORITY::DATA, reinterpret_cast<void *>(&_readback_data), sizeof(_readback_data)); + _plSend.setPayload(PRIORITY::DATA_ADDR, reinterpret_cast<void *>(&_readback_data), sizeof(_readback_data)); _comms->writePayload(_plSend); _readback_report_time = tnow; } @@ -121,7 +121,7 @@ void UILoop::reportCycleReadings() _cycle_data.timestamp = tnow; - _plSend.setPayload(PRIORITY::DATA, reinterpret_cast<void *>(&_cycle_data), sizeof(_cycle_data)); + _plSend.setPayload(PRIORITY::DATA_ADDR, reinterpret_cast<void *>(&_cycle_data), sizeof(_cycle_data)); _comms->writePayload(_plSend); _cycle_report_time = tnow; } diff --git a/arduino/hev_prototype_v1/src/common.h b/arduino/hev_prototype_v1/src/common.h index 23b99e5b0fe62a7d6cda872ddf11a4e45356394a..8a0a38329f16e3605b272504d432b195866ceaa9 100644 --- a/arduino/hev_prototype_v1/src/common.h +++ b/arduino/hev_prototype_v1/src/common.h @@ -32,13 +32,13 @@ const float MAX_VALVE_FRAC_OPEN = 0.68; // input params enum PAYLOAD_TYPE : uint8_t { - UNSET = 0, - DATA = 1, - READBACK = 2, - CYCLE = 3, - THRESHOLDS = 4, - CMD = 5, - ALARM = 6 + UNSET = 0, + DATA = 1, + READBACK = 2, + CYCLE = 3, + THRESHOLDS = 4, + CMD = 5, + ALARM = 6 }; enum CMD_TYPE : uint8_t { @@ -135,13 +135,6 @@ struct alarm_format { }; #pragma pack() -enum DATA_TYPE: uint8_t { - FAST = 1, - READBACK = 2, - CYCLE = 3, - THRESHOLDS = 4 -}; - // struct for all data sent #pragma pack(1) struct fast_data_format {