Native tests run again
This commit is contained in:
parent
d895d85273
commit
5558151c91
|
@ -9,4 +9,4 @@ build:
|
|||
script:
|
||||
- cd firmware
|
||||
- platformio run
|
||||
#- platformio test -v -e native
|
||||
- platformio test -v -e native
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
inline void _assert(const char* expression, const char* message, const char* file, int line)
|
||||
#ifndef PLATFORM_NATIVE
|
||||
|
||||
// ---------------------------------- Arduino -------------------------------------------------------------
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
inline void _assert(const char *expression, const char *message, const char *file, int line)
|
||||
{
|
||||
Serial.print("Assert ");
|
||||
Serial.print(file);
|
||||
|
@ -12,9 +18,58 @@ inline void _assert(const char* expression, const char* message, const char* fil
|
|||
Serial.println(message);
|
||||
}
|
||||
|
||||
template< typename T>
|
||||
inline String toString(const T & t) {
|
||||
template <typename T>
|
||||
inline String toString(const T &t)
|
||||
{
|
||||
return String(t);
|
||||
}
|
||||
|
||||
#define assert_msg(EXPRESSION, MSG) ((EXPRESSION) ? (void)0 : _assert(#EXPRESSION, #MSG, __FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
// ---------------------------------- Native -----------------------------------------------------------------
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <arpa/inet.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
typedef uint32_t uint_t;
|
||||
|
||||
typedef std::string String;
|
||||
typedef uint8_t byte;
|
||||
typedef const char *PGM_P;
|
||||
|
||||
using std::max;
|
||||
using std::min;
|
||||
|
||||
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_msg(EXPRESSION, MSG) ((EXPRESSION) ? (void)0 : _assert(#EXPRESSION, #MSG, __FILE__, __LINE__))
|
||||
|
||||
#endif
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Dtypes.h"
|
||||
|
||||
#ifdef PLATFORM_ESP32
|
||||
#include "SPIFFS.h"
|
||||
|
||||
|
@ -93,7 +95,6 @@ namespace portablefs
|
|||
#include <string>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include "MockDtypes.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <arpa/inet.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
class String : public std::string
|
||||
{};
|
||||
|
||||
#define assert(EXPRESSION, MSG) ((EXPRESSION) ? (void)0 : _assert(#EXPRESSION, #MSG, __FILE__, __LINE__))
|
|
@ -11,8 +11,8 @@ public:
|
|||
if (hx711_.is_ready())
|
||||
{
|
||||
long value = hx711_.read_average(CONFIG_MEASUREMENT_AVG_COUNT) - offset_;
|
||||
if(value > 0)
|
||||
measurementOut = (int16_t)(value / DIVIDER);
|
||||
if(value < 0)
|
||||
measurementOut = (int16_t)(-value / DIVIDER);
|
||||
else
|
||||
measurementOut = 0;
|
||||
return true;
|
||||
|
|
|
@ -126,7 +126,7 @@ private:
|
|||
}
|
||||
|
||||
static String chunkFileName(uint32_t chunkNr, uint32_t startTime) {
|
||||
return("/dat/" + toString(startTime) + "_" + toString(chunkNr));
|
||||
return("/dat/" + toString(startTime) + String("_") + toString(chunkNr));
|
||||
}
|
||||
|
||||
Chunk_T chunks[2];
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef PLATFORM_NATIVE
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
#include "Dtypes.h"
|
||||
|
||||
using SessionIdType = uint32_t;
|
||||
constexpr size_t MAX_USERS = 64;
|
||||
|
|
|
@ -41,8 +41,7 @@ public:
|
|||
|
||||
size_t operator()(uint8_t *buffer, size_t maxLen, size_t index)
|
||||
{
|
||||
Serial.print("index ");
|
||||
Serial.println(index);
|
||||
Serial.printf("%ld index %u\n", millis(), index);
|
||||
|
||||
using namespace webdav_constants;
|
||||
uint8_t *bufferStart = buffer;
|
||||
|
@ -57,6 +56,7 @@ public:
|
|||
}
|
||||
|
||||
bool fileFound = false;
|
||||
Serial.printf("%ld (0)\n", millis());
|
||||
while (dir_.next())
|
||||
{
|
||||
if (isFirstFileOfTrainingGroup())
|
||||
|
@ -71,10 +71,12 @@ public:
|
|||
//toBuffer(buffer, path_.c_str());
|
||||
toBuffer(buffer, RESPONSE_START);
|
||||
toBuffer(buffer, HREF_START);
|
||||
Serial.printf("%ld (1)\n", millis());
|
||||
const auto fileName = dir_.fileName();
|
||||
const auto fileNameWithoutDir = fileName.substring(fileName.lastIndexOf("/") + 1);
|
||||
String fileBaseName = fileNameWithoutDir.substring(0, fileNameWithoutDir.indexOf('_'));
|
||||
fileBaseName += ".st";
|
||||
Serial.printf("%ld (2)\n", millis());
|
||||
toBuffer(buffer, fileBaseName.c_str());
|
||||
toBuffer(buffer, HREF_END);
|
||||
toBuffer(buffer, PROPSTAT_START);
|
||||
|
@ -89,9 +91,11 @@ public:
|
|||
{
|
||||
toBuffer(buffer, CONTENTLEN_START);
|
||||
String fileSizeStr(getFileSize(fileName));
|
||||
toBuffer(buffer, fileSizeStr.c_str());
|
||||
//toBuffer(buffer, fileSizeStr.c_str());
|
||||
toBuffer(buffer, "1");
|
||||
toBuffer(buffer, CONTENTLEN_END);
|
||||
}
|
||||
Serial.printf("%ld (3)\n", millis());
|
||||
|
||||
toBuffer(buffer, PROP_END);
|
||||
toBuffer(buffer, STATUS_OK);
|
||||
|
@ -104,10 +108,10 @@ public:
|
|||
finished_ = true;
|
||||
}
|
||||
|
||||
|
||||
size_t bytesWritten = buffer - bufferStart;
|
||||
assert_msg(bytesWritten < maxLen, "Written too much!");
|
||||
//Serial.print("Bytes written ");
|
||||
//Serial.println(bytesWritten);
|
||||
Serial.printf("%ld Bytes written %u\n", millis(), bytesWritten);
|
||||
//Serial.print("Max bytes ");
|
||||
//Serial.println(maxLen);
|
||||
return bytesWritten;
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
#include <cstdint>
|
||||
|
||||
|
||||
//#define _HW_V_20
|
||||
#define _HW_V_20
|
||||
|
||||
// HX711 load cell
|
||||
#ifdef USE_ESP32
|
||||
#ifdef PLATFORM_ESP32
|
||||
|
||||
#ifdef _HW_V_20
|
||||
const int CONFIG_SCALE_DOUT_PIN = 23;
|
||||
|
@ -20,10 +20,10 @@ const int CONFIG_SCALE_SCK_PIN = 23;
|
|||
const int CONFIG_SCALE_DOUT_PIN = D2;
|
||||
const int CONFIG_SCALE_SCK_PIN = D3;
|
||||
#endif
|
||||
const uint8_t CONFIG_MEASUREMENT_AVG_COUNT = 1; // number of measurements in normal phase
|
||||
const uint8_t CONFIG_TARE_AVG_COUNT = 6; // number of measurements in tare-phase (to find 0 )
|
||||
const int CONFIG_MEASURE_DELAY = 100; // interval in ms between measurements
|
||||
const uint8_t CONFIG_MEASUREMENT_AVG_COUNT = 1; // number of measurements in normal phase
|
||||
const uint8_t CONFIG_TARE_AVG_COUNT = 6; // number of measurements in tare-phase (to find 0 )
|
||||
const int CONFIG_MEASURE_DELAY = 100; // interval in ms between measurements
|
||||
//const int CONFIG_VALUE_DIVIDER = 8; // uint32 measurements are divided by this factor, before stored in uint16_t
|
||||
const int CONFIG_VALUE_DIVIDER = 256; // uint32 measurements are divided by this factor, before stored in uint16_t
|
||||
const int CONFIG_VALUE_DIVIDER = 128; // uint32 measurements are divided by this factor, before stored in uint16_t
|
||||
|
||||
const uint32_t CONFIG_SESSION_CHUNK_SIZE = 1024; //1024*8 - 16 * sizeof(uint32_t);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#define USE_ESP32
|
||||
|
||||
// Arduino & ESP headers
|
||||
#include <Arduino.h>
|
||||
#ifdef USE_ESP32
|
||||
#include "Dtypes.h"
|
||||
|
||||
#ifdef PLATFORM_ESP32
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
|
@ -13,7 +13,6 @@
|
|||
#include <NTPClient.h> // for NTP
|
||||
|
||||
// Own libs
|
||||
#include "Dtypes.h"
|
||||
#include "MockScale.h"
|
||||
#include "Scale.h"
|
||||
#include "MeasurementSession.h"
|
||||
|
@ -207,7 +206,7 @@ void setup()
|
|||
// WiFi
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(CONFIG_WIFI_SSID, CONFIG_WIFI_PASSWORD);
|
||||
#ifdef USE_ESP32
|
||||
#ifdef PLATFORM_ESP32
|
||||
WiFi.setHostname(CONFIG_HOSTNAME);
|
||||
#else
|
||||
WIFI.hostname(CONFIG_HOSTNAME);
|
||||
|
@ -232,6 +231,10 @@ void setup()
|
|||
|
||||
Serial.println("Spiffs listing:");
|
||||
listDir(SPIFFS, "/", 3);
|
||||
|
||||
//
|
||||
Serial.print("Free Heap");
|
||||
Serial.println(ESP.getFreeHeap());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "MockDtypes.h"
|
||||
#include "Dtypes.h"
|
||||
#include "MockSerial.h"
|
||||
#include "MeasurementSession.h"
|
||||
#include "MockStorage.h"
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
Old load cell
|
||||
const int CONFIG_VALUE_DIVIDER = 128;
|
||||
1kg ~= 700
|
||||
=> overflow at 93 kg
|
||||
|
||||
|
Loading…
Reference in New Issue