Worked on firmware
This commit is contained in:
17
lib/basic/Dtypes.h
Normal file
17
lib/basic/Dtypes.h
Normal file
@@ -0,0 +1,17 @@
|
||||
inline void _assert(const char* expression, const char* message, const char* file, int line)
|
||||
{
|
||||
Serial.print("Assert ");
|
||||
Serial.print(file);
|
||||
Serial.print(" : ");
|
||||
Serial.print(line);
|
||||
Serial.print(" '");
|
||||
Serial.print(expression);
|
||||
Serial.println("' failed.");
|
||||
}
|
||||
|
||||
template< typename T>
|
||||
inline String toString(const T & t) {
|
||||
return String(t);
|
||||
}
|
||||
|
||||
#define assert(EXPRESSION, MSG) ((EXPRESSION) ? (void)0 : _assert(#EXPRESSION, #MSG, __FILE__, __LINE__))
|
||||
40
lib/basic/MockDtypes.h
Normal file
40
lib/basic/MockDtypes.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <arpa/inet.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
typedef uint32_t uint_t;
|
||||
|
||||
typedef std::string String;
|
||||
typedef uint8_t byte;
|
||||
typedef const char * PGM_P;
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
inline uint32_t strlen_P(PGM_P str) {
|
||||
return std::strlen(str);
|
||||
}
|
||||
|
||||
inline const char * F( const char * in) { return in; }
|
||||
|
||||
|
||||
inline void _assert(const char* expression, const char* message, const char* file, int line)
|
||||
{
|
||||
std::cerr << "Assert " << file << ":" << line << " '" << expression << "' failed." << std::endl;
|
||||
std::cerr << message << std::endl;
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
template< typename T>
|
||||
inline std::string toString(const T & t) {
|
||||
std::stringstream stream;
|
||||
stream << t;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
#define assert(EXPRESSION, MSG) ((EXPRESSION) ? (void)0 : _assert(#EXPRESSION, #MSG, __FILE__, __LINE__))
|
||||
18
lib/basic/MockSerial.h
Normal file
18
lib/basic/MockSerial.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
class SerialMock {
|
||||
public:
|
||||
template< typename T>
|
||||
static inline void print(const T & str) {
|
||||
std::cout << str;
|
||||
}
|
||||
template< typename T>
|
||||
static inline void println(const T & str) {
|
||||
std::cout << str << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
static SerialMock Serial;
|
||||
Reference in New Issue
Block a user