Skip to content

Commit

Permalink
mio dlog
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Feb 18, 2021
1 parent 8b31d95 commit b2b8b56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/eez/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
#include <eez/modules/psu/serial_psu.h>
#include <eez/modules/psu/sd_card.h>

////////////////////////////////////////////////////////////////////////////////
volatile uint32_t g_debugVarBufferDiff;

////////////////////////////////////////////////////////////////////////////////

#if !defined(__EMSCRIPTEN__)

Expand Down
33 changes: 18 additions & 15 deletions src/eez/modules/psu/dlog_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#include <eez/memory.h>

volatile static uint32_t g_debugVarBufferDiff;
volatile extern uint32_t g_debugVarBufferDiff;

namespace eez {

Expand Down Expand Up @@ -133,16 +133,17 @@ static float getValue(uint32_t rowIndex, uint8_t columnIndex, float *max) {

////////////////////////////////////////////////////////////////////////////////

static File file;

static int fileTruncate() {
File file;
if (!file.open(g_parameters.filePath, FILE_OPEN_APPEND | FILE_WRITE)) {
event_queue::pushEvent(event_queue::EVENT_ERROR_DLOG_FILE_OPEN_ERROR);
// TODO replace with more specific error
return SCPI_ERROR_MASS_STORAGE_ERROR;
}

bool result = file.truncate(0);
file.close();
// file.close();
if (!result) {
event_queue::pushEvent(event_queue::EVENT_ERROR_DLOG_TRUNCATE_ERROR);
// TODO replace with more specific error
Expand Down Expand Up @@ -227,29 +228,29 @@ void fileWrite(bool flush) {

int err = 0;

File file;
if (file.open(g_recording.parameters.filePath, FILE_OPEN_APPEND | FILE_WRITE)) {
if (file.seek(g_lastSavedBufferIndex)) {
// File file;
// if (file.open(g_recording.parameters.filePath, FILE_OPEN_APPEND | FILE_WRITE)) {
// if (file.seek(g_lastSavedBufferIndex)) {
size_t written = file.write(buffer, bufferSize);

if (written != bufferSize) {
err = event_queue::EVENT_ERROR_DLOG_WRITE_ERROR;
}

if (!file.close()) {
err = event_queue::EVENT_ERROR_DLOG_WRITE_ERROR;
}
// if (!file.close()) {
// err = event_queue::EVENT_ERROR_DLOG_WRITE_ERROR;
// }

if (!err) {
g_lastSavedBufferIndex += bufferSize;
g_lastSavedBufferTickCount = millis();
}
} else {
err = event_queue::EVENT_ERROR_DLOG_SEEK_ERROR;
}
} else {
err = event_queue::EVENT_ERROR_DLOG_FILE_REOPEN_ERROR;
}
// } else {
// err = event_queue::EVENT_ERROR_DLOG_SEEK_ERROR;
// }
// } else {
// err = event_queue::EVENT_ERROR_DLOG_FILE_REOPEN_ERROR;
// }

if (err) {
//DebugTrace("write error\n");
Expand Down Expand Up @@ -497,6 +498,8 @@ static void doFinish(bool afterError) {
}
}

file.close();

resetFilePath();

for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) {
Expand Down

0 comments on commit b2b8b56

Please sign in to comment.