Cleanup and fixes
This commit is contained in:
15
firmware/dev_hardware_wires.md
Normal file
15
firmware/dev_hardware_wires.md
Normal file
@@ -0,0 +1,15 @@
|
||||
!! On Swimtracker board the JTAG pins are not labeled correctly !
|
||||
one pin even needs to be soldered manually
|
||||
|
||||
|
||||
------|------|-----------------
|
||||
GND | | schwarz
|
||||
3.3V | | rot
|
||||
IO13 | TCK | weiss
|
||||
IO14 | TMS | grau
|
||||
IO12 | TDI | lila
|
||||
IO15 | TDO | blau
|
||||
EN | | grun
|
||||
IO0 | | braun
|
||||
RXD | | orange
|
||||
TXD | | gelb
|
||||
@@ -14,10 +14,6 @@ void Logger::init()
|
||||
{
|
||||
theLogger = new Logger();
|
||||
#ifdef PLATFORM_ESP32
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
Logger::getInstance()->log(__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define LOG_TRACE(...) \
|
||||
/*#define LOG_TRACE(...) \
|
||||
{ \
|
||||
Logger::getInstance()->log(__VA_ARGS__); \
|
||||
}
|
||||
*/
|
||||
#define LOG_TRACE(...) {}
|
||||
|
||||
#define LOG_WARNING(...) \
|
||||
{ \
|
||||
@@ -55,8 +57,7 @@ public:
|
||||
std::forward<Args>(args)...);
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
||||
//Serial.println(&data_[currentSize_]);
|
||||
Serial.println(&data_[currentSize_]);
|
||||
if(charsWritten > 0)
|
||||
{
|
||||
currentSize_ += charsWritten + 1; // + 1 for trailing zero
|
||||
|
||||
@@ -8,7 +8,7 @@ public:
|
||||
bool measure(uint16_t &measurementOut)
|
||||
{
|
||||
long value = hx711_.read_average(CONFIG_MEASUREMENT_AVG_COUNT);
|
||||
LOG_TRACE("rv %ld\n", value);
|
||||
LOG_TRACE("rv %ld", value);
|
||||
value -= offset_;
|
||||
|
||||
if (value < 0)
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
{
|
||||
auto v1 = hx711_.read_average(3);
|
||||
offset_ = hx711_.read_average(numMeasurementsToAverage);
|
||||
LOG_INFO("Init reading %ld, Tare offset %ld\n", v1, offset_);
|
||||
LOG_INFO("Init reading %ld, Tare offset %ld", v1, offset_);
|
||||
}
|
||||
|
||||
const long &offset() const { return offset_; }
|
||||
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
// use error codes of write instead? anyway: test it!
|
||||
LOG_INFO("%ld saveToFileSystem start", millis());
|
||||
deleteUntilBytesFree(CONFIG_SESSION_MAX_SIZE);
|
||||
LOG_INFO(" %ld after deleteUntilBytesFree()", millis());
|
||||
LOG_INFO("%ld after deleteUntilBytesFree()", millis());
|
||||
|
||||
using fs_string = portablefs::string;
|
||||
fs_string filename = fs_string(CONFIG_DATA_PATH) + "/" + portablefs::to_string(chunk->getStartTime());
|
||||
@@ -105,11 +105,12 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_INFO("Creating new session file");
|
||||
auto file = portablefs::open(filename.c_str(), "w");
|
||||
StreamingMsgPackEncoder<portablefs::File> encoder(&file);
|
||||
chunk->serialize(encoder);
|
||||
}
|
||||
LOG_INFO(" %ld saveToFileSystem done", millis());
|
||||
LOG_INFO("%ld saveToFileSystem done", millis());
|
||||
}
|
||||
|
||||
void deleteUntilBytesFree(size_t requiredSpace)
|
||||
|
||||
@@ -24,9 +24,12 @@ board_upload.flash_size = "16MB"
|
||||
#build_flags = -Wl,-Teagle.flash.2m1m.ld
|
||||
build_flags = -DPLATFORM_ESP32 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
|
||||
framework = arduino
|
||||
monitor_port = /dev/ttyUSB0
|
||||
upload_port = /dev/ttyUSB0
|
||||
monitor_port = /dev/ttyUSB1
|
||||
upload_port = /dev/ttyUSB1
|
||||
monitor_speed = 115200
|
||||
debug_tool = esp-prog
|
||||
#upload_protocol = esp-prog
|
||||
debug_init_break = tbreak setup
|
||||
lib_deps =
|
||||
NTPClient
|
||||
HX711@0.7.4
|
||||
|
||||
@@ -36,14 +36,13 @@ class LoggingAPI
|
||||
if(running_)
|
||||
{
|
||||
const Logger * logger = Logger::getInstance();
|
||||
const auto beginIt = lastEnd_;
|
||||
const auto endIt = logger->end();
|
||||
|
||||
StaticJsonDocument<512> data;
|
||||
for(auto it = beginIt; it != endIt; ++it) {
|
||||
const auto endIt = logger->end();
|
||||
StaticJsonDocument<1024> data;
|
||||
for(auto it = lastEnd_; it != endIt; ++it) {
|
||||
data["time"] = it.time_millis();
|
||||
data["msg"] = it.message();
|
||||
server.template sendToAll<512>(MessageCode::LOG_UPDATE, data);
|
||||
server.template sendToAll<1024>(MessageCode::LOG_UPDATE, data);
|
||||
}
|
||||
lastEnd_ = endIt;
|
||||
}
|
||||
@@ -52,6 +51,6 @@ class LoggingAPI
|
||||
private:
|
||||
bool running_ = false;
|
||||
Logger::iterator lastEnd_ = Logger::iterator(nullptr);
|
||||
bool firstCall_ = false;
|
||||
bool firstCall_ = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -50,14 +50,18 @@ public:
|
||||
|
||||
if (server_.poll())
|
||||
{
|
||||
LOG_INFO("new websocket connection, storing at pos %d - occupancy: ", nextFreeClient_);
|
||||
clients_[nextFreeClient_] = server_.accept();
|
||||
clients_[nextFreeClient_].onMessage(onMessage);
|
||||
this->onClientConnectImpl(clients_[nextFreeClient_]);
|
||||
nextFreeClient_ = (nextFreeClient_ + 1) % MAX_WEBSOCKET_CONNECTIONS;
|
||||
|
||||
for (int i = 0; i < MAX_WEBSOCKET_CONNECTIONS; ++i)
|
||||
LOG_INFO((clients_[i].available()) ? "x" : "o");
|
||||
if(MAX_WEBSOCKET_CONNECTIONS == 3) {
|
||||
LOG_INFO("new websocket connection, storing at pos %d - occupancy: %d%d%d", nextFreeClient_, clients_[0].available(), clients_[1].available(), clients_[2].available());
|
||||
} else {
|
||||
LOG_INFO("new websocket connection, storing at pos %d - occupancy:", nextFreeClient_);
|
||||
for (int i = 0; i < MAX_WEBSOCKET_CONNECTIONS; ++i)
|
||||
LOG_INFO((clients_[i].available()) ? "x" : "o");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_WEBSOCKET_CONNECTIONS; ++i)
|
||||
@@ -69,12 +73,13 @@ public:
|
||||
template <size_t bufferSize>
|
||||
void sendToAll(MessageCode msgCode, const JsonDocument &content)
|
||||
{
|
||||
static_assert(sizeof(MessageCode) == 1);
|
||||
char buffer[bufferSize];
|
||||
buffer[0] = (char)(msgCode);
|
||||
size_t bytesWritten = serializeMsgPack(content, buffer + sizeof(msgCode), bufferSize - sizeof(msgCode));
|
||||
for (int i = 0; i < MAX_WEBSOCKET_CONNECTIONS; ++i)
|
||||
if (clients_[i].available())
|
||||
clients_[i].sendBinary(buffer, bytesWritten);
|
||||
clients_[i].sendBinary(buffer, bytesWritten + sizeof(msgCode));
|
||||
}
|
||||
|
||||
void sendToAll(MessageCode msgCode, const JsonDocument &content)
|
||||
|
||||
@@ -433,6 +433,10 @@ void mdnsSetup(const String &fullHostname)
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
{
|
||||
}
|
||||
// Serial
|
||||
Logger::init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user