added SD card system logging

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

View File

@ -21,8 +21,6 @@
#include "BintrayClient.h"
// Local logging tag
static const char TAG[] = __FILE__;
BintrayClient::BintrayClient(const String &user, const String &repository, const String &package)
: m_user(user), m_repo(repository), m_package(package),

View File

@ -100,6 +100,8 @@ build_flags_basic =
'-D LIBPAX_WIFI'
'-D LIBPAX_BLE'
'-D LIBPAX_ARDUINO'
'-DUSE_ESP_IDF_LOG'
'-DTAG=__FILE__'
build_flags_all =
${common.build_flags_basic}
-mfix-esp32-psram-cache-issue

View File

@ -1,6 +1,6 @@
[board]
halfile = ttgotdongles3.h
;halfile = ttgotdongledisplays3.h
;halfile = ttgotdongles3.h
halfile = ttgotdongledisplays3.h
;halfile = ttgotdisplays3.h
[platformio]
@ -22,7 +22,7 @@ platform_espressif32 = espressif32@5.2.0
monitor_speed = 115200
upload_speed = 115200 ; set by build.py and taken from hal file
lib_deps_all =
bitbank2/BitBang_I2C@^2.2.1
bitbank2/BitBang_I2C@ ^2.2.1
bitbank2/bb_spi_lcd @ ^2.4.0
fastled/FastLED @ ^3.5.0
;greyrook/libpax @ ^1.0.1
@ -40,6 +40,8 @@ build_flags_basic =
'-D LIBPAX_WIFI'
'-D LIBPAX_BLE'
'-D LIBPAX_ARDUINO'
'-DUSE_ESP_IDF_LOG'
'-DTAG=__FILE__'
build_flags_all =
${common.build_flags_basic}
-mfix-esp32-psram-cache-issue

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;

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};

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);

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;

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"

View File

@ -4,8 +4,6 @@
// Basic config
#include "cyclic.h"
// Local logging tag
static const char TAG[] = __FILE__;
Ticker cyclicTimer;

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) {

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;

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;

View File

@ -2,8 +2,6 @@
#include "globals.h"
#include "i2c.h"
// Local logging tag
static const char TAG[] = __FILE__;
SemaphoreHandle_t I2Caccess;

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];

View File

@ -1,7 +1,5 @@
#include "irqhandler.h"
// Local logging tag
static const char TAG[] = __FILE__;
TaskHandle_t irqHandlerTask = NULL;

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};

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;

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

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

View File

@ -2,8 +2,6 @@
#include "mqttclient.h"
static const char TAG[] = __FILE__;
static QueueHandle_t MQTTSendQueue;
TaskHandle_t mqttTask;

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) {

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

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

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;

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

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

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();

View File

@ -2,8 +2,6 @@
#if (HAS_SDS011)
// Local logging tag
static const char TAG[] = __FILE__;
#include "sds011read.h"

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);

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]

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

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

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),