From 02534678297085feba5b84c1738079e5a01e3619 Mon Sep 17 00:00:00 2001 From: Tom Price Date: Sun, 17 Sep 2023 16:26:07 -0400 Subject: [PATCH] Change error codes to lower case consistent with other enums (#145) * Change error codes to lower case consistent with other enums * Update com.cpp * migrate enum AYAB_API to enum class --- src/ayab/com.cpp | 64 ++++++++++++++++-------------- src/ayab/com.h | 62 ++++++++++++++--------------- src/ayab/fsm.cpp | 2 +- src/ayab/fsm.h | 50 ++++++++++++------------ src/ayab/knitter.cpp | 22 +++++------ src/ayab/knitter.h | 6 +-- src/ayab/tester.cpp | 90 +++++++++++++++++++++---------------------- test/test_com.cpp | 58 ++++++++++++++-------------- test/test_knitter.cpp | 20 +++++----- test/test_tester.cpp | 16 ++++---- 10 files changed, 198 insertions(+), 192 deletions(-) diff --git a/src/ayab/com.cpp b/src/ayab/com.cpp index b7c1482b2..a7cab9a62 100644 --- a/src/ayab/com.cpp +++ b/src/ayab/com.cpp @@ -85,7 +85,8 @@ void Com::sendMsg(AYAB_API_t id, char *msg) { * \param error Error code (0 = success). */ void Com::send_reqLine(const uint8_t lineNumber, Err_t error) const { - uint8_t payload[REQLINE_LEN] = {reqLine_msgid, lineNumber, static_cast(error)}; + // `payload` will be allocated on stack since length is compile-time constant + uint8_t payload[REQLINE_LEN] = {static_cast(AYAB_API::reqLine), lineNumber, static_cast(error)}; send(static_cast(payload), REQLINE_LEN); } @@ -99,8 +100,9 @@ void Com::send_indState(Carriage_t carriage, uint8_t position, Err_t error) const { uint16_t leftHallValue = GlobalEncoders::getHallValue(Direction_t::Left); uint16_t rightHallValue = GlobalEncoders::getHallValue(Direction_t::Right); + // `payload` will be allocated on stack since length is compile-time constant uint8_t payload[INDSTATE_LEN] = { - indState_msgid, + static_cast(AYAB_API::indState), static_cast(error), static_cast(GlobalFsm::getState()), highByte(leftHallValue), @@ -121,67 +123,67 @@ void Com::send_indState(Carriage_t carriage, uint8_t position, */ void Com::onPacketReceived(const uint8_t *buffer, size_t size) { switch (buffer[0]) { - case reqInit_msgid: + case static_cast(AYAB_API::reqInit): h_reqInit(buffer, size); break; - case reqStart_msgid: + case static_cast(AYAB_API::reqStart): h_reqStart(buffer, size); break; - case cnfLine_msgid: + case static_cast(AYAB_API::cnfLine): h_cnfLine(buffer, size); break; - case reqInfo_msgid: + case static_cast(AYAB_API::reqInfo): h_reqInfo(); break; - case reqTest_msgid: + case static_cast(AYAB_API::reqTest): h_reqTest(buffer, size); break; - case helpCmd_msgid: + case static_cast(AYAB_API::helpCmd): GlobalTester::helpCmd(); break; - case sendCmd_msgid: + case static_cast(AYAB_API::sendCmd): GlobalTester::sendCmd(); break; - case beepCmd_msgid: + case static_cast(AYAB_API::beepCmd): GlobalTester::beepCmd(); break; - case setSingleCmd_msgid: + case static_cast(AYAB_API::setSingleCmd): GlobalTester::setSingleCmd(buffer, size); break; - case setAllCmd_msgid: + case static_cast(AYAB_API::setAllCmd): GlobalTester::setAllCmd(buffer, size); break; - case readEOLsensorsCmd_msgid: + case static_cast(AYAB_API::readEOLsensorsCmd): GlobalTester::readEOLsensorsCmd(); break; - case readEncodersCmd_msgid: + case static_cast(AYAB_API::readEncodersCmd): GlobalTester::readEncodersCmd(); break; - case autoReadCmd_msgid: + case static_cast(AYAB_API::autoReadCmd): GlobalTester::autoReadCmd(); break; - case autoTestCmd_msgid: + case static_cast(AYAB_API::autoTestCmd): GlobalTester::autoTestCmd(); break; - case stopCmd_msgid: + case static_cast(AYAB_API::stopCmd): GlobalTester::stopCmd(); break; - case quitCmd_msgid: + case static_cast(AYAB_API::quitCmd): GlobalTester::quitCmd(); break; @@ -201,7 +203,7 @@ void Com::onPacketReceived(const uint8_t *buffer, size_t size) { void Com::h_reqInit(const uint8_t *buffer, size_t size) { if (size < 3U) { // Need 3 bytes from buffer below. - send_cnfInit(ErrorCode::ERR_EXPECTED_LONGER_MESSAGE); + send_cnfInit(ErrorCode::expected_longer_message); return; } @@ -210,7 +212,7 @@ void Com::h_reqInit(const uint8_t *buffer, size_t size) { uint8_t crc8 = buffer[2]; // Check crc on bytes 0-4 of buffer. if (crc8 != CRC8(buffer, 2)) { - send_cnfInit(ErrorCode::ERR_CHECKSUM_ERROR); + send_cnfInit(ErrorCode::checksum_error); return; } @@ -228,7 +230,7 @@ void Com::h_reqInit(const uint8_t *buffer, size_t size) { void Com::h_reqStart(const uint8_t *buffer, size_t size) { if (size < 5U) { // Need 5 bytes from buffer below. - send_cnfStart(ErrorCode::ERR_EXPECTED_LONGER_MESSAGE); + send_cnfStart(ErrorCode::expected_longer_message); return; } @@ -239,7 +241,7 @@ void Com::h_reqStart(const uint8_t *buffer, size_t size) { uint8_t crc8 = buffer[4]; // Check crc on bytes 0-4 of buffer. if (crc8 != CRC8(buffer, 4)) { - send_cnfStart(ErrorCode::ERR_CHECKSUM_ERROR); + send_cnfStart(ErrorCode::checksum_error); return; } @@ -264,8 +266,8 @@ void Com::h_reqStart(const uint8_t *buffer, size_t size) { * \todo sl: Assert size? Handle error? */ void Com::h_cnfLine(const uint8_t *buffer, size_t size) { - auto m = static_cast(GlobalKnitter::getMachineType()); - uint8_t lenLineBuffer = LINE_BUFFER_LEN[m]; + auto machineType = static_cast(GlobalKnitter::getMachineType()); + uint8_t lenLineBuffer = LINE_BUFFER_LEN[machineType]; if (size < lenLineBuffer + 5U) { // message is too short // TODO(sl): handle error? @@ -316,7 +318,7 @@ void Com::h_reqInfo() const { void Com::h_reqTest(const uint8_t *buffer, size_t size) const { if (size < 2U) { // message is too short - send_cnfTest(ErrorCode::ERR_EXPECTED_LONGER_MESSAGE); + send_cnfTest(ErrorCode::expected_longer_message); return; } @@ -343,8 +345,9 @@ void Com::h_unrecognized() const { */ void Com::send_cnfInfo() const { // Max. length of suffix string: 16 bytes + \0 + // `payload` will be allocated on stack since length is compile-time constant uint8_t payload[22]; - payload[0] = cnfInfo_msgid; + payload[0] = static_cast(AYAB_API::cnfInfo); payload[1] = API_VERSION; payload[2] = FW_VERSION_MAJ; payload[3] = FW_VERSION_MIN; @@ -358,8 +361,9 @@ void Com::send_cnfInfo() const { * \param error Error code (0 = success, other values = error). */ void Com::send_cnfInit(Err_t error) const { + // `payload` will be allocated on stack since length is compile-time constant uint8_t payload[2]; - payload[0] = cnfInit_msgid; + payload[0] = static_cast(AYAB_API::cnfInit); payload[1] = static_cast(error); send(payload, 2); } @@ -370,8 +374,9 @@ void Com::send_cnfInit(Err_t error) const { * \param error Error code (0 = success, other values = error). */ void Com::send_cnfStart(Err_t error) const { + // `payload` will be allocated on stack since length is compile-time constant uint8_t payload[2]; - payload[0] = cnfStart_msgid; + payload[0] = static_cast(AYAB_API::cnfStart); payload[1] = static_cast(error); send(payload, 2); } @@ -381,8 +386,9 @@ void Com::send_cnfStart(Err_t error) const { * \param error Error code (0 = success, other values = error). */ void Com::send_cnfTest(Err_t error) const { + // `payload` will be allocated on stack since length is compile-time constant uint8_t payload[2]; - payload[0] = cnfTest_msgid; + payload[0] = static_cast(AYAB_API::cnfTest); payload[1] = static_cast(error); send(payload, 2); } diff --git a/src/ayab/com.h b/src/ayab/com.h index b476cd98a..343c06fcf 100644 --- a/src/ayab/com.h +++ b/src/ayab/com.h @@ -46,31 +46,31 @@ constexpr uint32_t SERIAL_BAUDRATE = 115200U; constexpr uint8_t MAX_LINE_BUFFER_LEN = 25U; constexpr uint8_t MAX_MSG_BUFFER_LEN = 255U; -enum AYAB_API { - reqStart_msgid = 0x01, - cnfStart_msgid = 0xC1, - reqLine_msgid = 0x82, - cnfLine_msgid = 0x42, - reqInfo_msgid = 0x03, - cnfInfo_msgid = 0xC3, - reqTest_msgid = 0x04, - cnfTest_msgid = 0xC4, - indState_msgid = 0x84, - helpCmd_msgid = 0x25, - sendCmd_msgid = 0x26, - beepCmd_msgid = 0x27, - setSingleCmd_msgid = 0x28, - setAllCmd_msgid = 0x29, - readEOLsensorsCmd_msgid = 0x2A, - readEncodersCmd_msgid = 0x2B, - autoReadCmd_msgid = 0x2C, - autoTestCmd_msgid = 0x2D, - stopCmd_msgid = 0x2E, - quitCmd_msgid = 0x2F, - reqInit_msgid = 0x05, - cnfInit_msgid = 0xC5, - testRes_msgid = 0xEE, - debug_msgid = 0x9F +enum class AYAB_API : unsigned char { + reqStart = 0x01, + cnfStart = 0xC1, + reqLine = 0x82, + cnfLine = 0x42, + reqInfo = 0x03, + cnfInfo = 0xC3, + reqTest = 0x04, + cnfTest = 0xC4, + indState = 0x84, + helpCmd = 0x25, + sendCmd = 0x26, + beepCmd = 0x27, + setSingleCmd = 0x28, + setAllCmd = 0x29, + readEOLsensorsCmd = 0x2A, + readEncodersCmd = 0x2B, + autoReadCmd = 0x2C, + autoTestCmd = 0x2D, + stopCmd = 0x2E, + quitCmd = 0x2F, + reqInit = 0x05, + cnfInit = 0xC5, + testRes = 0xEE, + debug = 0x9F }; using AYAB_API_t = enum AYAB_API; @@ -89,9 +89,9 @@ class ComInterface { virtual void sendMsg(AYAB_API_t id, const char *msg) = 0; virtual void sendMsg(AYAB_API_t id, char *msg) = 0; virtual void send_reqLine(const uint8_t lineNumber, - Err_t error = ErrorCode::SUCCESS) const = 0; + Err_t error = ErrorCode::success) const = 0; virtual void send_indState(Carriage_t carriage, uint8_t position, - Err_t error = ErrorCode::SUCCESS) const = 0; + Err_t error = ErrorCode::success) const = 0; virtual void onPacketReceived(const uint8_t *buffer, size_t size) = 0; }; @@ -114,9 +114,9 @@ class GlobalCom final { static void send(uint8_t *payload, size_t length); static void sendMsg(AYAB_API_t id, const char *msg); static void sendMsg(AYAB_API_t id, char *msg); - static void send_reqLine(const uint8_t lineNumber, Err_t error = ErrorCode::SUCCESS); + static void send_reqLine(const uint8_t lineNumber, Err_t error = ErrorCode::success); static void send_indState(Carriage_t carriage, uint8_t position, - Err_t error = ErrorCode::SUCCESS); + Err_t error = ErrorCode::success); static void onPacketReceived(const uint8_t *buffer, size_t size); private: @@ -130,9 +130,9 @@ class Com : public ComInterface { void send(uint8_t *payload, size_t length) const final; void sendMsg(AYAB_API_t id, const char *msg) final; void sendMsg(AYAB_API_t id, char *msg) final; - void send_reqLine(const uint8_t lineNumber, Err_t error = ErrorCode::SUCCESS) const final; + void send_reqLine(const uint8_t lineNumber, Err_t error = ErrorCode::success) const final; void send_indState(Carriage_t carriage, uint8_t position, - Err_t error = ErrorCode::SUCCESS) const final; + Err_t error = ErrorCode::success) const final; void onPacketReceived(const uint8_t *buffer, size_t size) final; private: diff --git a/src/ayab/fsm.cpp b/src/ayab/fsm.cpp index f625ebc70..698cacdb3 100644 --- a/src/ayab/fsm.cpp +++ b/src/ayab/fsm.cpp @@ -45,7 +45,7 @@ void Fsm::init() { m_nextState = OpState::wait_for_machine; m_flash = false; m_flashTime = millis(); - m_error = ErrorCode::SUCCESS; + m_error = ErrorCode::success; } /*! diff --git a/src/ayab/fsm.h b/src/ayab/fsm.h index c0855854c..d699dff6f 100644 --- a/src/ayab/fsm.h +++ b/src/ayab/fsm.h @@ -35,46 +35,46 @@ enum class OpState : unsigned char { using OpState_t = enum OpState; // As of APIv6, the only important distinction -// is between `SUCCESS` (0) and any other value. +// is between `ErrorCode::success` (0) and any other value. // Informative error codes are provided for // diagnostic purposes (that is, for debugging). // Non-zero error codes are subject to change. // Such changes will be considered non-breaking. enum class ErrorCode : unsigned char { - SUCCESS = 0x00, + success = 0x00, // message not understood - ERR_EXPECTED_LONGER_MESSAGE = 0x01, - ERR_UNRECOGNIZED_MSGID = 0x02, - ERR_UNEXPECTED_MSGID = 0x03, - ERR_CHECKSUM_ERROR = 0x04, + expected_longer_message = 0x01, + unrecognized_msgid = 0x02, + unexpected_msgid = 0x03, + checksum_error = 0x04, // invalid arguments - ERR_MACHINE_TYPE_INVALID = 0x10, - ERR_NEEDLE_VALUE_INVALID = 0x11, - ERR_NULL_POINTER_ARGUMENT = 0x12, - ERR_ARGUMENT_INVALID = 0x13, - ERR_ARGUMENTS_INCOMPATIBLE = 0x13, + machine_type_invalid = 0x10, + needle_value_invalid = 0x11, + null_pointer_argument = 0x12, + argument_invalid = 0x13, + arguments_incompatible = 0x13, // device not initialized - ERR_NO_MACHINE_TYPE = 0x20, - ERR_NO_CARRIAGE = 0x21, - ERR_NO_DIRECTION = 0x22, - ERR_NO_BELTSHIFT = 0x23, + no_machine_type = 0x20, + no_carriage = 0x21, + no_direction = 0x22, + no_beltshift = 0x23, // machine in wrong FSM state - ERR_MACHINE_STATE_INIT = 0xE0, - ERR_MACHINE_STATE_READY = 0xE1, - ERR_MACHINE_STATE_KNIT = 0xE2, - ERR_MACHINE_STATE_TEST = 0xE3, - ERR_WRONG_MACHINE_STATE = 0xEF, + machine_state_init = 0xE0, + machine_state_ready = 0xE1, + machine_state_knit = 0xE2, + machine_state_test = 0xE3, + wrong_machine_state = 0xEF, // generic error codes - WARNING = 0xF0, // ignorable error - RECOVERABLE_ERROR = 0xF1, - CRITICAL_ERROR = 0xF2, - FATAL_ERROR = 0xF3, - UNSPECIFIED_FAILURE = 0xFF + warning = 0xF0, // ignorable error + recoverable_error = 0xF1, + critical_error = 0xF2, + fatal_error = 0xF3, + unspecified_failure = 0xFF }; using Err_t = enum ErrorCode; diff --git a/src/ayab/knitter.cpp b/src/ayab/knitter.cpp index 384092440..c1a48ac2c 100644 --- a/src/ayab/knitter.cpp +++ b/src/ayab/knitter.cpp @@ -121,10 +121,10 @@ void Knitter::isr() { */ Err_t Knitter::initMachine(Machine_t machineType) { if (GlobalFsm::getState() != OpState::wait_for_machine) { - return ErrorCode::ERR_WRONG_MACHINE_STATE; + return ErrorCode::wrong_machine_state; } if (machineType == Machine_t::NoMachine) { - return ErrorCode::ERR_NO_MACHINE_TYPE; + return ErrorCode::no_machine_type; } m_machineType = machineType; @@ -134,7 +134,7 @@ Err_t Knitter::initMachine(Machine_t machineType) { // Now that we have enough start state, we can set up interrupts setUpInterrupt(); - return ErrorCode::SUCCESS; + return ErrorCode::success; } /*! @@ -149,13 +149,13 @@ Err_t Knitter::startKnitting(uint8_t startNeedle, uint8_t stopNeedle, uint8_t *pattern_start, bool continuousReportingEnabled) { if (GlobalFsm::getState() != OpState::ready) { - return ErrorCode::ERR_WRONG_MACHINE_STATE; + return ErrorCode::wrong_machine_state; } if (pattern_start == nullptr) { - return ErrorCode::ERR_NULL_POINTER_ARGUMENT; + return ErrorCode::null_pointer_argument; } if ((startNeedle >= stopNeedle) || (stopNeedle >= NUM_NEEDLES[static_cast(m_machineType)])) { - return ErrorCode::ERR_NEEDLE_VALUE_INVALID; + return ErrorCode::needle_value_invalid; } // record argument values @@ -175,7 +175,7 @@ Err_t Knitter::startKnitting(uint8_t startNeedle, GlobalBeeper::ready(); // success - return ErrorCode::SUCCESS; + return ErrorCode::success; } /*! @@ -189,7 +189,7 @@ void Knitter::encodePosition() { // store current encoder position for next call of this function m_sOldPosition = m_position; calculatePixelAndSolenoid(); - indState(ErrorCode::UNSPECIFIED_FAILURE); + indState(ErrorCode::unspecified_failure); } } @@ -223,7 +223,7 @@ bool Knitter::isReady() { #endif // DBG_NOMACHINE GlobalSolenoids::setSolenoids(SOLENOIDS_BITMASK); - indState(ErrorCode::SUCCESS); + indState(ErrorCode::success); return true; // move to `OpState::ready` } @@ -266,7 +266,7 @@ void Knitter::knit() { if (m_continuousReportingEnabled) { // send current position to GUI - indState(ErrorCode::SUCCESS); + indState(ErrorCode::success); } if (!calculatePixelAndSolenoid()) { @@ -382,7 +382,7 @@ void Knitter::setMachineType(Machine_t machineType) { * \param lineNumber Line number requested. */ void Knitter::reqLine(uint8_t lineNumber) { - GlobalCom::send_reqLine(lineNumber, ErrorCode::SUCCESS); + GlobalCom::send_reqLine(lineNumber, ErrorCode::success); m_lineRequested = true; } diff --git a/src/ayab/knitter.h b/src/ayab/knitter.h index b431c5c68..70c04792c 100644 --- a/src/ayab/knitter.h +++ b/src/ayab/knitter.h @@ -45,7 +45,7 @@ class KnitterInterface { virtual void encodePosition() = 0; virtual bool isReady() = 0; virtual void knit() = 0; - virtual void indState(Err_t error = ErrorCode::SUCCESS) = 0; + virtual void indState(Err_t error = ErrorCode::success) = 0; virtual uint8_t getStartOffset(const Direction_t direction) = 0; virtual Machine_t getMachineType() = 0; virtual bool setNextLine(uint8_t lineNumber) = 0; @@ -80,7 +80,7 @@ class GlobalKnitter final { static void encodePosition(); static bool isReady(); static void knit(); - static void indState(Err_t error = ErrorCode::SUCCESS); + static void indState(Err_t error = ErrorCode::success); static uint8_t getStartOffset(const Direction_t direction); static Machine_t getMachineType(); static bool setNextLine(uint8_t lineNumber); @@ -100,7 +100,7 @@ class Knitter : public KnitterInterface { void encodePosition() final; bool isReady() final; void knit() final; - void indState(Err_t error = ErrorCode::SUCCESS) final; + void indState(Err_t error = ErrorCode::success) final; uint8_t getStartOffset(const Direction_t direction) final; Machine_t getMachineType() final; bool setNextLine(uint8_t lineNumber) final; diff --git a/src/ayab/tester.cpp b/src/ayab/tester.cpp index 185cd7439..0c68182e5 100644 --- a/src/ayab/tester.cpp +++ b/src/ayab/tester.cpp @@ -36,35 +36,35 @@ * \brief Help command handler. */ void Tester::helpCmd() { - GlobalCom::sendMsg(testRes_msgid, "The following commands are available:\n"); - GlobalCom::sendMsg(testRes_msgid, "setSingle [0..15] [1/0]\n"); - GlobalCom::sendMsg(testRes_msgid, "setAll [0..FFFF]\n"); - GlobalCom::sendMsg(testRes_msgid, "readEOLsensors\n"); - GlobalCom::sendMsg(testRes_msgid, "readEncoders\n"); - GlobalCom::sendMsg(testRes_msgid, "beep\n"); - GlobalCom::sendMsg(testRes_msgid, "autoRead\n"); - GlobalCom::sendMsg(testRes_msgid, "autoTest\n"); - GlobalCom::sendMsg(testRes_msgid, "send\n"); - GlobalCom::sendMsg(testRes_msgid, "stop\n"); - GlobalCom::sendMsg(testRes_msgid, "quit\n"); - GlobalCom::sendMsg(testRes_msgid, "help\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "The following commands are available:\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "setSingle [0..15] [1/0]\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "setAll [0..FFFF]\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "readEOLsensors\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "readEncoders\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "beep\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "autoRead\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "autoTest\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "send\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "stop\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "quit\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "help\n"); } /*! * \brief Send command handler. */ void Tester::sendCmd() { - GlobalCom::sendMsg(testRes_msgid, "Called send\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Called send\n"); uint8_t p[] = {0x31, 0x32, 0x33}; GlobalCom::send(p, 3); - GlobalCom::sendMsg(testRes_msgid, "\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "\n"); } /*! * \brief Beep command handler. */ void Tester::beepCmd() { - GlobalCom::sendMsg(testRes_msgid, "Called beep\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Called beep\n"); beep(); } @@ -74,21 +74,21 @@ void Tester::beepCmd() { * \param size Number of bytes of data in the buffer. */ void Tester::setSingleCmd(const uint8_t *buffer, size_t size) { - GlobalCom::sendMsg(testRes_msgid, "Called setSingle\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Called setSingle\n"); if (size < 3U) { - GlobalCom::sendMsg(testRes_msgid, "Error: invalid arguments\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Error: invalid arguments\n"); return; } uint8_t solenoidNumber = buffer[1]; if (solenoidNumber > 15) { snprintf(buf, BUFFER_LEN, "Error: invalid solenoid index %i\n", solenoidNumber); - GlobalCom::sendMsg(testRes_msgid, buf); + GlobalCom::sendMsg(AYAB_API::testRes, buf); return; } uint8_t solenoidState = buffer[2]; if (solenoidState > 1) { snprintf(buf, BUFFER_LEN, "Error: invalid solenoid value %i\n", solenoidState); - GlobalCom::sendMsg(testRes_msgid, buf); + GlobalCom::sendMsg(AYAB_API::testRes, buf); return; } GlobalSolenoids::setSolenoid(solenoidNumber, solenoidState); @@ -100,9 +100,9 @@ void Tester::setSingleCmd(const uint8_t *buffer, size_t size) { * \param size Number of bytes of data in the buffer. */ void Tester::setAllCmd(const uint8_t *buffer, size_t size) { - GlobalCom::sendMsg(testRes_msgid, "Called setAll\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Called setAll\n"); if (size < 3U) { - GlobalCom::sendMsg(testRes_msgid, "Error: invalid arguments\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Error: invalid arguments\n"); return; } uint16_t solenoidState = (buffer[1] << 8) + buffer[2]; @@ -113,25 +113,25 @@ void Tester::setAllCmd(const uint8_t *buffer, size_t size) { * \brief Read EOL sensors command handler. */ void Tester::readEOLsensorsCmd() { - GlobalCom::sendMsg(testRes_msgid, "Called readEOLsensors\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Called readEOLsensors\n"); readEOLsensors(); - GlobalCom::sendMsg(testRes_msgid, "\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "\n"); } /*! * \brief Read encoders command handler. */ void Tester::readEncodersCmd() { - GlobalCom::sendMsg(testRes_msgid, "Called readEncoders\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Called readEncoders\n"); readEncoders(); - GlobalCom::sendMsg(testRes_msgid, "\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "\n"); } /*! * \brief Auto read command handler. */ void Tester::autoReadCmd() { - GlobalCom::sendMsg(testRes_msgid, "Called autoRead, send stop to quit\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Called autoRead, send stop to quit\n"); m_autoReadOn = true; } @@ -139,7 +139,7 @@ void Tester::autoReadCmd() { * \brief Auto test command handler. */ void Tester::autoTestCmd() { - GlobalCom::sendMsg(testRes_msgid, "Called autoTest, send stop to quit\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Called autoTest, send stop to quit\n"); m_autoTestOn = true; } @@ -170,9 +170,9 @@ Err_t Tester::startTest(Machine_t machineType) { GlobalFsm::setState(OpState::test); GlobalKnitter::setMachineType(machineType); setUp(); - return ErrorCode::SUCCESS; + return ErrorCode::success; } - return ErrorCode::ERR_WRONG_MACHINE_STATE; + return ErrorCode::wrong_machine_state; } /*! @@ -202,13 +202,13 @@ void Tester::encoderAChange() { */ void Tester::setUp() { // Print welcome message - GlobalCom::sendMsg(testRes_msgid, "AYAB Hardware Test, "); + GlobalCom::sendMsg(AYAB_API::testRes, "AYAB Hardware Test, "); snprintf(buf, BUFFER_LEN, "Firmware v%hhu", FW_VERSION_MAJ); - GlobalCom::sendMsg(testRes_msgid, buf); + GlobalCom::sendMsg(AYAB_API::testRes, buf); snprintf(buf, BUFFER_LEN, ".%hhu", FW_VERSION_MIN); - GlobalCom::sendMsg(testRes_msgid, buf); + GlobalCom::sendMsg(AYAB_API::testRes, buf); snprintf(buf, BUFFER_LEN, " API v%hhu\n\n", API_VERSION); - GlobalCom::sendMsg(testRes_msgid, buf); + GlobalCom::sendMsg(AYAB_API::testRes, buf); helpCmd(); // attach interrupt for ENC_PIN_A(=2), interrupt #0 @@ -237,15 +237,15 @@ void Tester::beep() const { * \brief Read the Hall sensors that determine which carriage is in use. */ void Tester::readEncoders() const { - GlobalCom::sendMsg(testRes_msgid, " ENC_A: "); + GlobalCom::sendMsg(AYAB_API::testRes, " ENC_A: "); bool state = digitalRead(ENC_PIN_A); - GlobalCom::sendMsg(testRes_msgid, state ? "HIGH" : "LOW"); - GlobalCom::sendMsg(testRes_msgid, " ENC_B: "); + GlobalCom::sendMsg(AYAB_API::testRes, state ? "HIGH" : "LOW"); + GlobalCom::sendMsg(AYAB_API::testRes, " ENC_B: "); state = digitalRead(ENC_PIN_B); - GlobalCom::sendMsg(testRes_msgid, state ? "HIGH" : "LOW"); - GlobalCom::sendMsg(testRes_msgid, " ENC_C: "); + GlobalCom::sendMsg(AYAB_API::testRes, state ? "HIGH" : "LOW"); + GlobalCom::sendMsg(AYAB_API::testRes, " ENC_C: "); state = digitalRead(ENC_PIN_C); - GlobalCom::sendMsg(testRes_msgid, state ? "HIGH" : "LOW"); + GlobalCom::sendMsg(AYAB_API::testRes, state ? "HIGH" : "LOW"); } /*! @@ -254,27 +254,27 @@ void Tester::readEncoders() const { void Tester::readEOLsensors() { auto hallSensor = static_cast(analogRead(EOL_PIN_L)); snprintf(buf, BUFFER_LEN, " EOL_L: %hu", hallSensor); - GlobalCom::sendMsg(testRes_msgid, buf); + GlobalCom::sendMsg(AYAB_API::testRes, buf); hallSensor = static_cast(analogRead(EOL_PIN_R)); snprintf(buf, BUFFER_LEN, " EOL_R: %hu", hallSensor); - GlobalCom::sendMsg(testRes_msgid, buf); + GlobalCom::sendMsg(AYAB_API::testRes, buf); } /*! * \brief Read both carriage sensors and End of Line sensors. */ void Tester::autoRead() { - GlobalCom::sendMsg(testRes_msgid, "\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "\n"); readEOLsensors(); readEncoders(); - GlobalCom::sendMsg(testRes_msgid, "\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "\n"); } /*! * \brief Set even-numbered solenoids. */ void Tester::autoTestEven() const { - GlobalCom::sendMsg(testRes_msgid, "Set even solenoids\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Set even solenoids\n"); digitalWrite(LED_PIN_A, HIGH); digitalWrite(LED_PIN_B, HIGH); GlobalSolenoids::setSolenoids(0xAAAA); @@ -284,7 +284,7 @@ void Tester::autoTestEven() const { * \brief Set odd-numbered solenoids. */ void Tester::autoTestOdd() const { - GlobalCom::sendMsg(testRes_msgid, "Set odd solenoids\n"); + GlobalCom::sendMsg(AYAB_API::testRes, "Set odd solenoids\n"); digitalWrite(LED_PIN_A, LOW); digitalWrite(LED_PIN_B, LOW); GlobalSolenoids::setSolenoids(0x5555); diff --git a/test/test_com.cpp b/test/test_com.cpp index 817f61413..80d1a23bb 100644 --- a/test/test_com.cpp +++ b/test/test_com.cpp @@ -91,7 +91,7 @@ class ComTest : public ::testing::Test { } void reqInit(Machine_t machine) { - uint8_t buffer[] = {reqInit_msgid, static_cast(machine)}; + uint8_t buffer[] = {static_cast(AYAB_API::reqInit), static_cast(machine)}; EXPECT_CALL(*fsmMock, setState(OpState::init)); expected_write_onPacketReceived(buffer, sizeof(buffer), true); } @@ -104,8 +104,8 @@ TEST_F(ComTest, test_API) { */ TEST_F(ComTest, test_reqInit_too_short_error) { - uint8_t buffer[] = {reqInit_msgid, static_cast(Machine_t::Kh910)}; - //EXPECT_CALL(*serialMock, write(cnfInit_msgid)); + uint8_t buffer[] = {static_cast(AYAB_API::reqInit), static_cast(Machine_t::Kh910)}; + //EXPECT_CALL(*serialMock, write(static_cast(AYAB_API::cnfInit))); //EXPECT_CALL(*serialMock, write(EXPECTED_LONGER_MESSAGE)); //EXPECT_CALL(*serialMock, write(SLIP::END)); EXPECT_CALL(*fsmMock, setState(OpState::init)).Times(0); @@ -116,8 +116,8 @@ TEST_F(ComTest, test_reqInit_too_short_error) { } TEST_F(ComTest, test_reqInit_checksum_error) { - uint8_t buffer[] = {reqInit_msgid, static_cast(Machine_t::Kh910), 0}; - //EXPECT_CALL(*serialMock, write(cnfInit_msgid)); + uint8_t buffer[] = {static_cast(AYAB_API::reqInit), static_cast(Machine_t::Kh910), 0}; + //EXPECT_CALL(*serialMock, write(static_cast(AYAB_API::cnfInit))); //EXPECT_CALL(*serialMock, write(CHECKSUM_ERROR)); //EXPECT_CALL(*serialMock, write(SLIP::END)); EXPECT_CALL(*fsmMock, setState(OpState::init)).Times(0); @@ -129,7 +129,7 @@ TEST_F(ComTest, test_reqInit_checksum_error) { TEST_F(ComTest, test_reqtest_fail) { // no machineType - uint8_t buffer[] = {reqTest_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::reqTest)}; EXPECT_CALL(*fsmMock, setState(OpState::test)).Times(0); expected_write_onPacketReceived(buffer, sizeof(buffer), true); @@ -138,7 +138,7 @@ TEST_F(ComTest, test_reqtest_fail) { } TEST_F(ComTest, test_reqtest_success_KH270) { - uint8_t buffer[] = {reqTest_msgid, static_cast(Machine_t::Kh270)}; + uint8_t buffer[] = {static_cast(AYAB_API::reqTest), static_cast(Machine_t::Kh270)}; EXPECT_CALL(*fsmMock, setState(OpState::test)); EXPECT_CALL(*knitterMock, setMachineType(Machine_t::Kh270)); EXPECT_CALL(*arduinoMock, millis); @@ -151,7 +151,7 @@ TEST_F(ComTest, test_reqtest_success_KH270) { TEST_F(ComTest, test_reqstart_fail1) { // checksum wrong - uint8_t buffer[] = {reqStart_msgid, 0, 10, 1, 0x73}; + uint8_t buffer[] = {static_cast(AYAB_API::reqStart), 0, 10, 1, 0x73}; EXPECT_CALL(*knitterMock, startKnitting).Times(0); expected_write_onPacketReceived(buffer, sizeof(buffer), true); @@ -161,7 +161,7 @@ TEST_F(ComTest, test_reqstart_fail1) { TEST_F(ComTest, test_reqstart_fail2) { // not enough bytes - uint8_t buffer[] = {reqStart_msgid, 0, 1, 0x74}; + uint8_t buffer[] = {static_cast(AYAB_API::reqStart), 0, 1, 0x74}; EXPECT_CALL(*knitterMock, startKnitting).Times(0); expected_write_onPacketReceived(buffer, sizeof(buffer) - 1, true); @@ -171,7 +171,7 @@ TEST_F(ComTest, test_reqstart_fail2) { TEST_F(ComTest, test_reqstart_success_KH910) { reqInit(Machine_t::Kh910); - uint8_t buffer[] = {reqStart_msgid, 0, 10, 1, 0x36}; + uint8_t buffer[] = {static_cast(AYAB_API::reqStart), 0, 10, 1, 0x36}; EXPECT_CALL(*knitterMock, startKnitting); expected_write_onPacketReceived(buffer, sizeof(buffer), false); @@ -181,7 +181,7 @@ TEST_F(ComTest, test_reqstart_success_KH910) { TEST_F(ComTest, test_reqstart_success_KH270) { reqInit(Machine_t::Kh270); - uint8_t buffer[] = {reqStart_msgid, 0, 10, 1, 0x36}; + uint8_t buffer[] = {static_cast(AYAB_API::reqStart), 0, 10, 1, 0x36}; EXPECT_CALL(*knitterMock, startKnitting); expected_write_onPacketReceived(buffer, sizeof(buffer), false); @@ -190,46 +190,46 @@ TEST_F(ComTest, test_reqstart_success_KH270) { } TEST_F(ComTest, test_reqinfo) { - uint8_t buffer[] = {reqInfo_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::reqInfo)}; expected_write_onPacketReceived(buffer, sizeof(buffer), true); } TEST_F(ComTest, test_helpCmd) { - uint8_t buffer[] = {helpCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::helpCmd)}; expected_write_onPacketReceived(buffer, sizeof(buffer), false); } TEST_F(ComTest, test_sendCmd) { - uint8_t buffer[] = {sendCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::sendCmd)}; expected_write_onPacketReceived(buffer, sizeof(buffer), false); } TEST_F(ComTest, test_beepCmd) { - uint8_t buffer[] = {beepCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::beepCmd)}; EXPECT_CALL(*arduinoMock, analogWrite(PIEZO_PIN, _)).Times(AtLeast(1)); EXPECT_CALL(*arduinoMock, delay(BEEP_DELAY)).Times(AtLeast(1)); expected_write_onPacketReceived(buffer, sizeof(buffer), true); } TEST_F(ComTest, test_setSingleCmd) { - uint8_t buffer[] = {setSingleCmd_msgid, 0, 0}; + uint8_t buffer[] = {static_cast(AYAB_API::setSingleCmd), 0, 0}; expected_write_onPacketReceived(buffer, sizeof(buffer), true); } TEST_F(ComTest, test_setAllCmd) { - uint8_t buffer[] = {setAllCmd_msgid, 0, 0}; + uint8_t buffer[] = {static_cast(AYAB_API::setAllCmd), 0, 0}; expected_write_onPacketReceived(buffer, sizeof(buffer), true); } TEST_F(ComTest, test_readEOLsensorsCmd) { - uint8_t buffer[] = {readEOLsensorsCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::readEOLsensorsCmd)}; EXPECT_CALL(*arduinoMock, analogRead(EOL_PIN_L)); EXPECT_CALL(*arduinoMock, analogRead(EOL_PIN_R)); expected_write_onPacketReceived(buffer, sizeof(buffer), false); } TEST_F(ComTest, test_readEncodersCmd) { - uint8_t buffer[] = {readEncodersCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::readEncodersCmd)}; EXPECT_CALL(*arduinoMock, digitalRead(ENC_PIN_A)); EXPECT_CALL(*arduinoMock, digitalRead(ENC_PIN_B)); EXPECT_CALL(*arduinoMock, digitalRead(ENC_PIN_C)); @@ -237,22 +237,22 @@ TEST_F(ComTest, test_readEncodersCmd) { } TEST_F(ComTest, test_autoReadCmd) { - uint8_t buffer[] = {autoReadCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::autoReadCmd)}; expected_write_onPacketReceived(buffer, sizeof(buffer), true); } TEST_F(ComTest, test_autoTestCmd) { - uint8_t buffer[] = {autoTestCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::autoTestCmd)}; expected_write_onPacketReceived(buffer, sizeof(buffer), true); } TEST_F(ComTest, test_stopCmd) { - uint8_t buffer[] = {stopCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::stopCmd)}; com->onPacketReceived(buffer, sizeof(buffer)); } TEST_F(ComTest, test_quitCmd) { - uint8_t buffer[] = {quitCmd_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::quitCmd)}; EXPECT_CALL(*knitterMock, setUpInterrupt); EXPECT_CALL(*fsmMock, setState(OpState::init)); com->onPacketReceived(buffer, sizeof(buffer)); @@ -272,7 +272,7 @@ TEST_F(ComTest, test_cnfline_kh910) { uint8_t pattern[] = {1}; // message for machine with 200 needles - uint8_t buffer[30] = {cnfLine_msgid /* 0x42 */, + uint8_t buffer[30] = {static_cast(AYAB_API::cnfLine) /* 0x42 */, 0, 0, 1, @@ -345,7 +345,7 @@ TEST_F(ComTest, test_cnfline_kh270) { // message for KH270 // CRC8 calculated with // http://tomeko.net/online_tools/crc8.php?lang=en - uint8_t buffer[20] = {cnfLine_msgid, 0, 0, 1, + uint8_t buffer[20] = {static_cast(AYAB_API::cnfLine), 0, 0, 1, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -357,7 +357,7 @@ TEST_F(ComTest, test_cnfline_kh270) { */ TEST_F(ComTest, test_debug) { - uint8_t buffer[] = {debug_msgid}; + uint8_t buffer[] = {static_cast(AYAB_API::debug)}; com->onPacketReceived(buffer, sizeof(buffer)); } @@ -374,13 +374,13 @@ TEST_F(ComTest, test_send) { TEST_F(ComTest, test_sendMsg1) { expect_write(true); - com->sendMsg(testRes_msgid, "abc"); + com->sendMsg(AYAB_API::testRes, "abc"); } TEST_F(ComTest, test_sendMsg2) { char buf[] = "abc\0"; expect_write(true); - com->sendMsg(testRes_msgid, buf); + com->sendMsg(AYAB_API::testRes, buf); } TEST_F(ComTest, test_send_reqLine) { @@ -392,5 +392,5 @@ TEST_F(ComTest, test_send_indState) { EXPECT_CALL(*arduinoMock, analogRead(EOL_PIN_L)); EXPECT_CALL(*arduinoMock, analogRead(EOL_PIN_R)); expect_write(true); - com->send_indState(Carriage::Knit, 0, ErrorCode::SUCCESS); + com->send_indState(Carriage::Knit, 0, ErrorCode::success); } diff --git a/test/test_knitter.cpp b/test/test_knitter.cpp index 804775267..be9a29e75 100644 --- a/test/test_knitter.cpp +++ b/test/test_knitter.cpp @@ -179,7 +179,7 @@ class KnitterTest : public ::testing::Test { void expected_init_machine(Machine_t m) { // Init the machine - ASSERT_EQ(knitter->initMachine(m), ErrorCode::SUCCESS); + ASSERT_EQ(knitter->initMachine(m), ErrorCode::success); expected_dispatch_wait_for_machine(); ASSERT_EQ(fsm->getState(), OpState::init); @@ -199,7 +199,7 @@ class KnitterTest : public ::testing::Test { get_to_ready(m); uint8_t pattern[] = {1}; EXPECT_CALL(*beeperMock, ready); - ASSERT_EQ(knitter->startKnitting(0, NUM_NEEDLES[static_cast(m)] - 1, pattern, false), ErrorCode::SUCCESS); + ASSERT_EQ(knitter->startKnitting(0, NUM_NEEDLES[static_cast(m)] - 1, pattern, false), ErrorCode::success); expected_dispatch_ready(); // ends in state `OpState::knit` @@ -281,9 +281,9 @@ TEST_F(KnitterTest, test_startKnitting_NoMachine) { uint8_t pattern[] = {1}; Machine_t m = knitter->getMachineType(); ASSERT_EQ(m, Machine_t::NoMachine); - ASSERT_TRUE(knitter->initMachine(m) != ErrorCode::SUCCESS); + ASSERT_TRUE(knitter->initMachine(m) != ErrorCode::success); ASSERT_TRUE( - knitter->startKnitting(0, NUM_NEEDLES[static_cast(m)] - 1, pattern, false) != ErrorCode::SUCCESS); + knitter->startKnitting(0, NUM_NEEDLES[static_cast(m)] - 1, pattern, false) != ErrorCode::success); // test expectations without destroying instance ASSERT_TRUE(Mock::VerifyAndClear(solenoidsMock)); @@ -291,8 +291,8 @@ TEST_F(KnitterTest, test_startKnitting_NoMachine) { TEST_F(KnitterTest, test_startKnitting_invalidMachine) { uint8_t pattern[] = {1}; - ASSERT_TRUE(knitter->initMachine(Machine_t::NoMachine) != ErrorCode::SUCCESS); - ASSERT_TRUE(knitter->startKnitting(0, 1, pattern, false) != ErrorCode::SUCCESS); + ASSERT_TRUE(knitter->initMachine(Machine_t::NoMachine) != ErrorCode::success); + ASSERT_TRUE(knitter->startKnitting(0, 1, pattern, false) != ErrorCode::success); // test expectations without destroying instance ASSERT_TRUE(Mock::VerifyAndClear(solenoidsMock)); @@ -301,7 +301,7 @@ TEST_F(KnitterTest, test_startKnitting_invalidMachine) { TEST_F(KnitterTest, test_startKnitting_notReady) { uint8_t pattern[] = {1}; ASSERT_TRUE(knitter->startKnitting(0, NUM_NEEDLES[static_cast(Machine_t::Kh910)] - 1, pattern, - false) != ErrorCode::SUCCESS); + false) != ErrorCode::success); // test expectations without destroying instance ASSERT_TRUE(Mock::VerifyAndClear(solenoidsMock)); @@ -332,15 +332,15 @@ TEST_F(KnitterTest, test_startKnitting_failures) { get_to_ready(Machine_t::Kh910); // `m_stopNeedle` lower than `m_startNeedle` - ASSERT_TRUE(knitter->startKnitting(1, 0, pattern, false) != ErrorCode::SUCCESS); + ASSERT_TRUE(knitter->startKnitting(1, 0, pattern, false) != ErrorCode::success); // `m_stopNeedle` out of range ASSERT_TRUE(knitter->startKnitting(0, NUM_NEEDLES[static_cast(Machine_t::Kh910)], pattern, - false) != ErrorCode::SUCCESS); + false) != ErrorCode::success); // null pattern ASSERT_TRUE(knitter->startKnitting(0, NUM_NEEDLES[static_cast(Machine_t::Kh910)] - 1, nullptr, - false) != ErrorCode::SUCCESS); + false) != ErrorCode::success); // test expectations without destroying instance ASSERT_TRUE(Mock::VerifyAndClear(solenoidsMock)); diff --git a/test/test_tester.cpp b/test/test_tester.cpp index a566aa81a..a96d7d2cc 100644 --- a/test/test_tester.cpp +++ b/test/test_tester.cpp @@ -77,7 +77,7 @@ class TesterTest : public ::testing::Test { // `setUp()` must have been called to reach `millis()` EXPECT_CALL(*arduinoMock, millis).WillOnce(Return(t)); - ASSERT_TRUE(tester->startTest(Machine_t::Kh930) == ErrorCode::SUCCESS); + ASSERT_TRUE(tester->startTest(Machine_t::Kh930) == ErrorCode::success); } void expect_write(bool once) { @@ -124,37 +124,37 @@ TEST_F(TesterTest, test_beepCmd) { } TEST_F(TesterTest, test_setSingleCmd_fail1) { - const uint8_t buf[] = {setSingleCmd_msgid, 0}; + const uint8_t buf[] = {static_cast(AYAB_API::setSingleCmd), 0}; expect_write(false); tester->setSingleCmd(buf, 2); } TEST_F(TesterTest, test_setSingleCmd_fail2) { - const uint8_t buf[] = {setSingleCmd_msgid, 16, 0}; + const uint8_t buf[] = {static_cast(AYAB_API::setSingleCmd), 16, 0}; expect_write(false); tester->setSingleCmd(buf, 3); } TEST_F(TesterTest, test_setSingleCmd_fail3) { - const uint8_t buf[] = {setSingleCmd_msgid, 15, 2}; + const uint8_t buf[] = {static_cast(AYAB_API::setSingleCmd), 15, 2}; expect_write(false); tester->setSingleCmd(buf, 3); } TEST_F(TesterTest, test_setSingleCmd_success) { - const uint8_t buf[] = {setSingleCmd_msgid, 15, 1}; + const uint8_t buf[] = {static_cast(AYAB_API::setSingleCmd), 15, 1}; expect_write(true); tester->setSingleCmd(buf, 3); } TEST_F(TesterTest, test_setAllCmd_fail1) { - const uint8_t buf[] = {setAllCmd_msgid, 0}; + const uint8_t buf[] = {static_cast(AYAB_API::setAllCmd), 0}; expect_write(false); tester->setAllCmd(buf, 2); } TEST_F(TesterTest, test_setAllCmd_success) { - const uint8_t buf[] = {setAllCmd_msgid, 0xff, 0xff}; + const uint8_t buf[] = {static_cast(AYAB_API::setAllCmd), 0xff, 0xff}; expect_write(true); tester->setAllCmd(buf, 3); } @@ -245,7 +245,7 @@ TEST_F(TesterTest, test_loop_autoTest) { TEST_F(TesterTest, test_startTest_fail) { // can't start test from state `OpState::knit` EXPECT_CALL(*fsmMock, getState).WillOnce(Return(OpState::knit)); - ASSERT_TRUE(tester->startTest(Machine_t::Kh910) != ErrorCode::SUCCESS); + ASSERT_TRUE(tester->startTest(Machine_t::Kh910) != ErrorCode::success); // test expectations without destroying instance ASSERT_TRUE(Mock::VerifyAndClear(fsmMock));