fixed mock uart driver for standalone unit tests

This commit is contained in:
proddy
2020-06-14 14:43:43 +02:00
parent a710080c46
commit d08cd09f4e
2 changed files with 9 additions and 12 deletions

View File

@@ -56,7 +56,7 @@ void EMSuart::send_poll(uint8_t data) {
* buf contains the CRC and len is #bytes including the CRC * buf contains the CRC and len is #bytes including the CRC
* returns code, 0=success, 1=brk error, 2=watchdog timeout * returns code, 0=success, 1=brk error, 2=watchdog timeout
*/ */
EMSUART_STATUS EMSuart::transmit(uint8_t * buf, uint8_t len) { uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
if (len == 0) { if (len == 0) {
return EMS_TX_STATUS_OK; // nothing to send return EMS_TX_STATUS_OK; // nothing to send
} }

View File

@@ -23,25 +23,22 @@
namespace emsesp { namespace emsesp {
typedef enum { #define EMS_TX_STATUS_ERR 0
EMS_TX_STATUS_OK = 1, #define EMS_TX_STATUS_OK 1
EMS_TX_WTD_TIMEOUT, // watchdog timeout during send
EMS_TX_BRK_DETECT, // incoming BRK during Tx
} EMSUART_STATUS;
class EMSuart { class EMSuart {
public: public:
EMSuart() = default; EMSuart() = default;
~EMSuart() = default; ~EMSuart() = default;
static void start(uint8_t tx_mode); static void start(uint8_t tx_mode);
static void stop(); static void stop();
static void restart(); static void restart();
static void send_poll(uint8_t data); static void send_poll(uint8_t data);
static EMSUART_STATUS transmit(uint8_t * buf, uint8_t len); static uint16_t transmit(uint8_t * buf, uint8_t len);
private: private:
static char * hextoa(char * result, const uint8_t value); static char * hextoa(char * result, const uint8_t value);
}; };
} // namespace emsesp } // namespace emsesp