Skip to content

Commit

Permalink
#19
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed May 28, 2021
1 parent 37c6edf commit 1af9d99
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/eez/modules/psu/scpi/syst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2410,6 +2410,7 @@ scpi_result_t scpi_cmd_systemCommunicateUartReceiveQ(scpi_t *context) {
static scpi_choice_def_t g_uartModeChoice[] = {
{ "BUFFer", uart::UART_MODE_BUFFER },
{ "SCPI", uart::UART_MODE_SCPI },
{ "BOOKmark", uart::UART_MODE_BOOKMARK },
SCPI_CHOICE_LIST_END
};

Expand Down
20 changes: 19 additions & 1 deletion src/eez/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <eez/modules/psu/psu.h>
#include <eez/modules/psu/io_pins.h>
#include <eez/modules/psu/dlog_record.h>
#include <eez/modules/psu/scpi/psu.h>
#include <eez/modules/bp3c/flash_slave.h>

Expand Down Expand Up @@ -235,6 +236,23 @@ void tick() {
auto ch = (char)g_inputBuffer.get();
input(g_scpiContext, &ch, 1);
}
} else if (persist_conf::devConf.uartMode == UART_MODE_BOOKMARK) {
static char bookmarkText[dlog_file::MAX_BOOKMARK_TEXT_LEN];
static unsigned bookmarkTextLen;

while (!g_inputBuffer.isEmpty()) {
auto ch = (char)g_inputBuffer.get();
if (ch == '\r' || ch == '\n') {
if (bookmarkTextLen > 0) {
dlog_record::logBookmark(bookmarkText, bookmarkTextLen);
bookmarkTextLen = 0;
}
} else {
if (bookmarkTextLen < dlog_file::MAX_BOOKMARK_TEXT_LEN) {
bookmarkText[bookmarkTextLen++] = ch;
}
}
}
}
}
}
Expand Down Expand Up @@ -327,7 +345,7 @@ HAL_StatusTypeDef receive(uint8_t *data, uint16_t size, uint32_t timeout, uint16
}

bool receiveFromBuffer(uint8_t *data, uint16_t size, uint16_t &n, int *err) {
if (!g_initialized || bp3c::flash_slave::g_bootloaderMode || persist_conf::devConf.uartMode == UART_MODE_SCPI) {
if (!g_initialized || bp3c::flash_slave::g_bootloaderMode || persist_conf::devConf.uartMode != UART_MODE_BUFFER) {
if (*err) {
*err = SCPI_ERROR_EXECUTION_ERROR;
}
Expand Down
1 change: 1 addition & 0 deletions src/eez/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void onQueueMessage(uint32_t type, uint32_t param);
enum UartMode {
UART_MODE_BUFFER,
UART_MODE_SCPI,
UART_MODE_BOOKMARK,
};

} // uart
Expand Down

0 comments on commit 1af9d99

Please sign in to comment.