added SD card system logging

This commit is contained in:
cyberman54 committed 2022-11-27 21:50:38 +01:00
1 parent b6f4399138
commit b8c87f0acf
33 files changed
+17 -83

No files matched your search

-2
View File
@@ -4,8 +4,6 @@
#include <Arduino.h>
// Local logging tag
static const char TAG[] = __FILE__;
typedef enum { ANTENNA_INT = 0, ANTENNA_EXT } antenna_type_t;
-2
View File
@@ -2,8 +2,6 @@
#include "bmesensor.h"
// Local logging tag
static const char TAG[] = __FILE__;
bmeStatus_t bme_status = {0, 0, 0, 0, 0, 0, 0, 0};
-2
View File
@@ -1,8 +1,6 @@
#include "boot.h"
#include "reset.h"
// Local logging tag
static const char TAG[] = __FILE__;
static hw_timer_t *wdTimer = NULL;
static WebServer server(80);
-2
View File
@@ -3,8 +3,6 @@
#include "globals.h"
#include "button.h"
// Local logging tag
static const char TAG[] = __FILE__;
OneButton button(HAS_BUTTON, !BUTTON_ACTIVEHIGH, !!BUTTON_PULLUP);
TaskHandle_t buttonLoopTask;
-2
View File
@@ -3,8 +3,6 @@
#include "globals.h"
#include "configmanager.h"
// Local logging tag
static const char TAG[] = __FILE__;
// namespace for device runtime preferences
#define DEVCONFIG "paxcntcfg"
-2
View File
@@ -4,8 +4,6 @@
// Basic config
#include "cyclic.h"
// Local logging tag
static const char TAG[] = __FILE__;
Ticker cyclicTimer;
-2
View File
@@ -13,8 +13,6 @@ https://github.com/udoklein/dcf77
#include "dcf77.h"
// Local logging tag
static const char TAG[] = __FILE__;
// triggered by second timepulse to ticker out DCF signal
void DCF77_Pulse(uint8_t bit) {
-2
View File
@@ -37,8 +37,6 @@ MY_FONT_LARGE: 16x32px = 8 chars / line @ 2 lines
#include "globals.h"
#include "display.h"
// local Tag for logging
static const char TAG[] = __FILE__;
static uint8_t plotbuf[PLOTBUFFERSIZE] = {0};
uint8_t DisplayIsOn = 0;
-2
View File
@@ -3,8 +3,6 @@
#include "globals.h"
#include "gpsread.h"
// Local logging tag
static const char TAG[] = __FILE__;
TinyGPSPlus gps;
TaskHandle_t GpsTask;
-2
View File
@@ -2,8 +2,6 @@
#include "globals.h"
#include "i2c.h"
// Local logging tag
static const char TAG[] = __FILE__;
SemaphoreHandle_t I2Caccess;
-2
View File
@@ -81,8 +81,6 @@ not evaluated by model BU-190, use "F" instead for this model
#include "if482.h"
// Local logging tag
static const char TAG[] = __FILE__;
String IF482_Frame(time_t t) {
char mon, out[IF482_FRAME_SIZE + 1], buf[IF482_FRAME_SIZE - 3];
-2
View File
@@ -1,7 +1,5 @@
#include "irqhandler.h"
// Local logging tag
static const char TAG[] = __FILE__;
TaskHandle_t irqHandlerTask = NULL;
-2
View File
@@ -6,8 +6,6 @@
#define MATRIX_DISPLAY_PAGES (2) // number of display pages
#define LINE_DIAGRAM_DIVIDER (2) // scales pax numbers to led rows
// local Tag for logging
static const char TAG[] = __FILE__;
uint8_t MatrixDisplayIsOn = 0;
static uint8_t displaybuf[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / 8] = {0};
-2
View File
@@ -1,7 +1,5 @@
#include "libpax_helpers.h"
// Local logging tag
static const char TAG[] = __FILE__;
// libpax payload
struct count_payload_t count_from_libpax;
-2
View File
@@ -3,8 +3,6 @@
#if (HAS_LORA)
#include "lorawan.h"
// Local logging Tag
static const char TAG[] = __FILE__;
#if CLOCK_ERROR_PROCENTAGE > 7
#warning CLOCK_ERROR_PROCENTAGE value in lmic_config.h is too high; values > 7 will cause side effects
-2
View File
@@ -79,8 +79,6 @@ BME_IRQ <- setBMEIRQ() <- Ticker.h
// Basic Config
#include "main.h"
// local Tag for logging
static const char TAG[] = __FILE__;
char clientId[20] = {0}; // unique ClientID
-2
View File
@@ -2,8 +2,6 @@
#include "mqttclient.h"
static const char TAG[] = __FILE__;
static QueueHandle_t MQTTSendQueue;
TaskHandle_t mqttTask;
-2
View File
@@ -32,8 +32,6 @@ const int port = 443;
int volatile contentLength = 0;
bool volatile isValidContentType = false;
// Local logging tag
static const char TAG[] = __FILE__;
// helper function to extract header value from header
inline String getHeaderValue(String header, String headerName) {
+1
View File
@@ -13,6 +13,7 @@
#define BOOTMENU 0 // 0 = no bootmenu, 1 = device brings up boot menu before starting application
#define BOOTDELAY 30 // time [seconds] while devices waits in boot menue for input
#define BOOTTIMEOUT 300 // time [seconds] while devices waits to finish upload a firmware file
#define SDLOGGING 0 // set to 1 for system logging to SD card (if device has one)
// Payload send cycle and encoding
#define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255
-2
View File
@@ -2,8 +2,6 @@
#include "globals.h"
#include "power.h"
// Local logging tag
static const char TAG[] = __FILE__;
int8_t batt_level = -1; // percent batt level, global variable, -1 means no batt
-2
View File
@@ -2,8 +2,6 @@
#include "globals.h"
#include "rcommand.h"
// Local logging tag
static const char TAG[] = __FILE__;
static QueueHandle_t RcmdQueue;
TaskHandle_t rcmdTask;
-2
View File
@@ -2,8 +2,6 @@
#include "globals.h"
#include "reset.h"
// Local logging tag
static const char TAG[] = __FILE__;
// Conversion factor for micro seconds to seconds
#define uS_TO_S_FACTOR 1000000ULL
-2
View File
@@ -2,8 +2,6 @@
#include "rtctime.h"
// Local logging tag
static const char TAG[] = __FILE__;
RtcDS3231<TwoWire> Rtc(Wire); // RTC hardware i2c interface
+9 -22
View File
@@ -5,9 +5,6 @@
// check whether your card reader supports SPI oder SDMMC and select appropriate
// SD interface in board hal file
// Local logging tag
static const char TAG[] = __FILE__;
#include "sdcard.h"
sdmmc_card_t *card;
@@ -17,9 +14,9 @@ static bool useSDCard = false;
// This file stream will be used for payload logging
static FILE *data_file;
// This file stream will be used for system logging
#ifdef SD_LOGGING
#if (SDLOGGING)
// This file stream will be used for system logging
static FILE *log_file;
// Save UART stdout stream
@@ -30,7 +27,6 @@ static FILE *uart_stdout = stdout;
// @important Do NOT use the ESP_LOG* macro's in this function ELSE
// recursive loop and stack overflow! So use printf() instead for debug
// messages.
// CURRENTLY NOT WORKING DUE TO AN ISSUE IN ARDUINO-ESP32
int print_to_sd_card(const char *fmt, va_list args) {
static bool static_fatal_error = false;
static const uint32_t WRITE_CACHE_CYCLE = 5;
@@ -53,12 +49,8 @@ int print_to_sd_card(const char *fmt, va_list args) {
}
// #2 Smart commit after x writes
counter_write++;
if (counter_write % WRITE_CACHE_CYCLE == 0) {
printf("%s() fsync'ing log file (WRITE_CACHE_CYCLE=%u)\n",
WRITE_CACHE_CYCLE);
if (counter_write++ % WRITE_CACHE_CYCLE == 0)
fsync(fileno(log_file));
}
}
// #3 ALWAYS Write to stdout!
@@ -119,7 +111,8 @@ bool sdcard_init(bool create) {
return false;
}
// Use settings defined above to initialize SD card and mount FAT filesystem.
// Use settings defined above to initialize SD card and mount FAT
// filesystem.
ret = esp_vfs_fat_sdspi_mount(mount_point, &host, &slot_config, &mount_config,
&card);
@@ -188,16 +181,12 @@ bool sdcard_init(bool create) {
useSDCard = false;
}
#ifdef SD_LOGGING
#if (SDLOGGING)
snprintf(bufferFilename, sizeof(bufferFilename), "/%s.log", SDCARD_FILE_NAME);
if (openFile(&log_file, bufferFilename)) {
ESP_LOGI(TAG, "redirecting serial output to SD-card");
esp_log_set_vprintf(&print_to_sd_card);
// Change stdout for THIS TASK ONLY
// stdout = log_file;
// Change stdout for all new tasks which will be created
//_GLOBAL_REENT->_stdout = log_file;
} else {
useSDCard = false;
}
@@ -209,7 +198,7 @@ bool sdcard_init(bool create) {
void sdcard_flush(void) {
if (data_file)
fsync(fileno(data_file));
#ifdef SD_LOGGING
#if (SDLOGGING)
if (log_file)
fsync(fileno(log_file));
#endif
@@ -220,11 +209,9 @@ void sdcard_close(void) {
return;
ESP_LOGI(TAG, "closing SD-card");
sdcard_flush();
#ifdef SD_LOGGING
// Reset logging output back to normal
#if (SDLOGGING)
// Redirect logging output back to console
ESP_LOGI(TAG, "redirect console back to serial output");
// stdout = uart_stdout;
//_GLOBAL_REENT->_stdout = uart_stdout;
esp_log_set_vprintf(&vprintf);
#endif
fcloseall();
-2
View File
@@ -2,8 +2,6 @@
#if (HAS_SDS011)
// Local logging tag
static const char TAG[] = __FILE__;
#include "sds011read.h"
-2
View File
@@ -1,8 +1,6 @@
// Basic Config
#include "senddata.h"
// Local logging tag
static const char TAG[] = __FILE__;
void setSendIRQ(TimerHandle_t xTimer) {
xTaskNotify(irqHandlerTask, SENDCYCLE_IRQ, eSetBits);
-2
View File
@@ -2,8 +2,6 @@
#include "globals.h"
#include "sensor.h"
// Local logging tag
static const char TAG[] = __FILE__;
#define SENSORBUFFER \
10 // max. size of user sensor data buffer in bytes [default=20]
-2
View File
@@ -30,8 +30,6 @@ licenses. Refer to LICENSE.txt file in repository for more details.
#include <sys/param.h>
#include <rom/crc.h>
static const char TAG[] = __FILE__;
#define HEADER_SIZE 4
// SPI transaction size needs to be at least 8 bytes and dividable by 4, see
// https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/spi_slave.html
-2
View File
@@ -4,8 +4,6 @@
#error You must define at most one of IF482 or DCF77!
#endif
// Local logging tag
static const char TAG[] = __FILE__;
// symbol to display current time source
// G = GPS / R = RTC / L = LORA / * = no sync / ? = never synced
-2
View File
@@ -21,8 +21,6 @@ accept this.
#include "timesync.h"
// Local logging tag
static const char TAG[] = __FILE__;
static bool timeSyncPending = false;
static uint8_t time_sync_seqNo = (uint8_t)random(TIME_SYNC_MAX_SEQNO),