Worked on firmware

This commit is contained in:
Martin Bauer
2019-08-22 21:33:36 +02:00
parent 9889d41805
commit 6a724b284f
24 changed files with 422 additions and 209 deletions

17
lib/basic/Dtypes.h Normal file
View 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
View 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
View 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;