Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow raw telem logs for ARM radio with SD. #5789

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion radio/src/gui/128x64/view_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ void menuMainView(event_t event)
}

// And ! in case of unexpected shutdown
#if defined(LOG_TELEMETRY) || defined(WATCHDOG_DISABLED)
#if defined(WATCHDOG_DISABLED)
lcdDrawChar(REBOOT_X, 0*FH, '!', INVERS);
#else
if (unexpectedShutdown) {
Expand Down
40 changes: 37 additions & 3 deletions radio/src/gui/128x64/view_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include "opentx.h"

#if defined(SDCARD)
extern FIL g_telemetryFile;
#endif

#define STATS_1ST_COLUMN 1
#define STATS_2ND_COLUMN 7*FW+FW/2
#define STATS_3RD_COLUMN 14*FW+FW/2
Expand Down Expand Up @@ -113,11 +117,13 @@ void menuStatisticsView(event_t event)
}

#if defined(CPUARM)
#define MENU_DEBUG_COL1_OFS (11*FW-3)
#define MENU_DEBUG_COL1_OFS (12*FW-3)
#define MENU_DEBUG_COL2_OFS (17*FW)
#define MENU_DEBUG_Y_CURRENT (1*FH)
#define MENU_DEBUG_ROW1 (1*FH+1)
#define MENU_DEBUG_ROW2 (2*FH+1)
#define MENU_DEBUG_ROW3 (3*FH+1)
#define MENU_DEBUG_ROW4 (4*FH+1)
#define MENU_DEBUG_Y_MAH (2*FH)
#define MENU_DEBUG_Y_CPU_TEMP (3*FH)
#define MENU_DEBUG_Y_COPROC (4*FH)
Expand Down Expand Up @@ -282,7 +288,20 @@ void menuStatisticsDebug2(event_t event)
TITLE(STR_MENUDEBUG);

switch (event) {
case EVT_KEY_FIRST(KEY_ENTER):
case EVT_KEY_LONG(KEY_ENTER):
if(logTelemetryNeeded) {
f_close(&g_telemetryFile);
}
else {
f_open(&g_telemetryFile, LOGS_PATH "/telemetry.log", FA_OPEN_ALWAYS | FA_WRITE);
if (f_size(&g_telemetryFile) > 0) {
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
}
}
logTelemetryNeeded = !logTelemetryNeeded;
break;

case EVT_KEY_BREAK(KEY_ENTER):
telemetryErrors = 0;
break;

Expand All @@ -302,16 +321,31 @@ void menuStatisticsDebug2(event_t event)
break;

case EVT_KEY_FIRST(KEY_EXIT):
if(logTelemetryNeeded) {
f_close(&g_telemetryFile);
logTelemetryNeeded = false;
}
chainMenu(menuMainView);
break;
}

lcdDrawTextAlignedLeft(MENU_DEBUG_ROW1, "Tlm RX Err");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW1, telemetryErrors, RIGHT);

lcdDrawTextAlignedLeft(MENU_DEBUG_ROW2, "BT status");
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW2, "BT Status");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW2, btChipPresent, RIGHT);

lcdDrawTextAlignedLeft(MENU_DEBUG_ROW3, "Log telem");
if (logTelemetryNeeded) {
lcdDrawText(MENU_DEBUG_COL1_OFS - FW + 1, MENU_DEBUG_ROW3, "Recording");
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW4, "Tlm log size");
lcdDrawNumber(MENU_DEBUG_COL1_OFS- FW + 1, MENU_DEBUG_ROW4, f_size(&g_telemetryFile) / 1024, LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW4, "kb");
}
else {
lcdDrawText(MENU_DEBUG_COL1_OFS - FW, MENU_DEBUG_ROW3, "[ENTER Long]");
}

lcdDrawText(4*FW, 7*FH+1, STR_MENUTORESET);
lcdInvertLastLine();
}
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/212x64/view_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void displayTopBar()

/* Notifs icons */
coord_t x = BAR_NOTIFS_X;
#if defined(LOG_TELEMETRY) || defined(WATCHDOG_DISABLED)
#if defined(WATCHDOG_DISABLED)
LCD_NOTIF_ICON(x, ICON_REBOOT);
x -= 12;
#else
Expand Down
30 changes: 30 additions & 0 deletions radio/src/gui/212x64/view_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "opentx.h"

extern FIL g_telemetryFile;

#define STATS_1ST_COLUMN FW/2
#define STATS_2ND_COLUMN 12*FW+FW/2
#define STATS_3RD_COLUMN 24*FW+FW/2
Expand Down Expand Up @@ -97,6 +99,7 @@ void menuStatisticsView(event_t event)
}

#define MENU_DEBUG_COL1_OFS (11*FW-2)
#define MENU_DEBUG_COL2_OFS (19*FW-2)
#define MENU_DEBUG_ROW1 (2*FH-3)
#define MENU_DEBUG_ROW2 (3*FH-2)
#define MENU_DEBUG_ROW3 (4*FH-1)
Expand Down Expand Up @@ -224,10 +227,27 @@ void menuStatisticsDebug2(event_t event)


case EVT_KEY_FIRST(KEY_EXIT):
if(logTelemetryNeeded) {
f_close(&g_telemetryFile);
logTelemetryNeeded = false;
}
chainMenu(menuMainView);
break;

case EVT_KEY_LONG(KEY_ENTER):
if(logTelemetryNeeded) {
f_close(&g_telemetryFile);
}
else {
f_open(&g_telemetryFile, LOGS_PATH "/telemetry.log", FA_OPEN_ALWAYS | FA_WRITE);
if (f_size(&g_telemetryFile) > 0) {
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
}
}
logTelemetryNeeded = !logTelemetryNeeded;
break;

case EVT_KEY_BREAK(KEY_ENTER):
telemetryErrors = 0;
break;
}
Expand All @@ -236,6 +256,16 @@ void menuStatisticsDebug2(event_t event)
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW1, "Tlm RX Err");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW1, telemetryErrors, RIGHT);

lcdDrawTextAlignedLeft(MENU_DEBUG_ROW3, "Raw telemetry log");
if (logTelemetryNeeded) {
lcdDrawText(MENU_DEBUG_COL2_OFS - FW + 1, MENU_DEBUG_ROW3, "Recording");
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW4, "Telemetry log size");
lcdDrawNumber(MENU_DEBUG_COL2_OFS- FW + 1, MENU_DEBUG_ROW4, f_size(&g_telemetryFile) / 1024, LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW4, "kb");
}
else {
lcdDrawText(MENU_DEBUG_COL2_OFS - FW, MENU_DEBUG_ROW3, "[ENTER Long]");
}

lcdDrawText(3*FW, 7*FH+1, STR_MENUTORESET);
lcdInvertLastLine();
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/480x272/themes/default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class DefaultTheme: public Theme

void loadIcons() const
{
#if defined(LOG_TELEMETRY) || defined(WATCHDOG_DISABLED)
#if defined(WATCHDOG_DISABLED)
loadMenuIcon(ICON_OPENTX, "mask_opentx_testmode.png", TEXT_COLOR);
#else
loadMenuIcon(ICON_OPENTX, "mask_opentx.png");
Expand Down
27 changes: 26 additions & 1 deletion radio/src/gui/480x272/view_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "opentx.h"
#include "stamp.h"

extern FIL g_telemetryFile;

#define MENU_STATS_COLUMN1 (MENUS_MARGIN_LEFT + 120)
#define MENU_STATS_COLUMN2 (LCD_W/2)
#define MENU_STATS_COLUMN3 (LCD_W/2 + 120)
Expand Down Expand Up @@ -97,7 +99,20 @@ bool menuStatsDebug(event_t event)
{
switch(event)
{
case EVT_KEY_FIRST(KEY_ENTER):
case EVT_KEY_LONG(KEY_ENTER):
if(logTelemetryNeeded) {
f_close(&g_telemetryFile);
}
else {
f_open(&g_telemetryFile, LOGS_PATH "/telemetry.log", FA_OPEN_ALWAYS | FA_WRITE);
if (f_size(&g_telemetryFile) > 0) {
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
}
}
logTelemetryNeeded = !logTelemetryNeeded;
break;

case EVT_KEY_BREAK(KEY_ENTER):
maxMixerDuration = 0;
#if defined(LUA)
maxLuaInterval = 0;
Expand Down Expand Up @@ -152,6 +167,16 @@ bool menuStatsDebug(event_t event)
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+line*FH, "Tlm RX Errs");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+line*FH, telemetryErrors, LEFT);

lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+(line+1)*FH, "Telemetry raw log");
if(logTelemetryNeeded) {
lcdDrawText(MENU_STATS_COLUMN2, MENU_CONTENT_TOP+(line+1)*FH, "Recording [");
lcdDrawNumber(lcdNextPos, MENU_CONTENT_TOP+(line+1)*FH, f_size(&g_telemetryFile) / 1024, LEFT);
lcdDrawText(lcdNextPos, MENU_CONTENT_TOP+(line+1)*FH, "kb]");
}
else {
lcdDrawText(MENU_STATS_COLUMN2, MENU_CONTENT_TOP+(line+1)*FH, "[ENTER Long] to start");
}

lcdDrawText(LCD_W/2, MENU_FOOTER_TOP, STR_MENUTORESET, MENU_TITLE_COLOR | CENTERED);
return true;
}
Expand Down
6 changes: 1 addition & 5 deletions radio/src/targets/common/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(TIMERS 3 CACHE STRING "Timers count (2 or 3)")
set_property(CACHE TIMERS PROPERTY STRINGS 2 3)
option(CLI "Command Line Interface" OFF)
option(DEBUG "Debug mode" OFF)
option(LOG_TELEMETRY "Telemetry Logs on SD card" OFF)
option(TRACE_SD_CARD "Traces SD enabled" OFF)
option(TRACE_FATFS "Traces FatFS enabled" OFF)
option(TRACE_AUDIO "Traces audio enabled" OFF)
Expand All @@ -19,9 +18,6 @@ if(TIMERS EQUAL 3)
else()
add_definitions(-DTIMERS=2)
endif()
if(LOG_TELEMETRY)
add_definitions(-DLOG_TELEMETRY)
endif()
if(TRACE_SD_CARD)
add_definitions(-DTRACE_SD_CARD)
set(DEBUG ON)
Expand Down Expand Up @@ -132,4 +128,4 @@ set(PULSES_SRC
pxx_arm.cpp
dsm2_arm.cpp
sbus_arm.cpp
)
)
23 changes: 6 additions & 17 deletions radio/src/targets/horus/diskio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
Expand Down Expand Up @@ -309,9 +309,7 @@ DRESULT disk_ioctl (
// TODO everything here should not be in the driver layer ...

FATFS g_FATFS_Obj __DMA; // initialized in boardInit()
#if defined(LOG_TELEMETRY)
FIL g_telemetryFile = {};
#endif
extern FIL g_telemetryFile;

#if defined(BOOT)
void sdInit(void)
Expand All @@ -324,7 +322,7 @@ void sdInit(void)
void sdInit()
{
TRACE("sdInit");

ioMutex = CoCreateMutex();
if (ioMutex >= CFG_MAX_MUTEX) {
// sd error
Expand All @@ -336,19 +334,12 @@ void sdInit()
void sdMount()
{
TRACE("sdMount");

diskCache.clear();

if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
// call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called
sdGetFreeSectors();

#if defined(LOG_TELEMETRY)
f_open(&g_telemetryFile, LOGS_PATH "/telemetry.log", FA_OPEN_ALWAYS | FA_WRITE);
if (f_size(&g_telemetryFile) > 0) {
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
}
#endif
}
else {
TRACE("f_mount() failed");
Expand All @@ -358,12 +349,10 @@ void sdMount()
void sdDone()
{
TRACE("sdDone");

if (sdMounted()) {
audioQueue.stopSD();
#if defined(LOG_TELEMETRY)
f_close(&g_telemetryFile);
#endif
f_mount(NULL, "", 0); // unmount SD
}
}
Expand Down
10 changes: 1 addition & 9 deletions radio/src/targets/simu/simudisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,10 @@ void sdInit(void)
// return;
// }


if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
// call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called
sdGetFreeSectors();

#if defined(LOG_TELEMETRY)
f_open(&g_telemetryFile, LOGS_PATH "/telemetry.log", FA_OPEN_ALWAYS | FA_WRITE);
if (f_size(&g_telemetryFile) > 0) {
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
}
#endif
}
else {
TRACE_SIMPGMSPACE("f_mount() failed");
Expand All @@ -224,9 +218,7 @@ void sdDone()
{
if (sdMounted()) {
audioQueue.stopSD();
#if defined(LOG_TELEMETRY)
f_close(&g_telemetryFile);
#endif
f_mount(NULL, "", 0); // unmount SD
}
}
Expand Down