diff --git a/modular-psu-firmware.eez-project b/modular-psu-firmware.eez-project index 644788d37..25430c294 100644 --- a/modular-psu-firmware.eez-project +++ b/modular-psu-firmware.eez-project @@ -534215,7 +534215,7 @@ "response": {} }, { - "name": "SENSe:DLOG:TRACe:COMMent", + "name": "SENSe:DLOG:TRACe:REMark", "parameters": [ { "name": "comment", @@ -534227,6 +534227,22 @@ } ], "response": {} + }, + { + "name": "SENSe:DLOG:TRACe:REMark?", + "parameters": [ + { + "name": "comment", + "type": [ + { + "type": "quoted-string" + } + ] + } + ], + "response": { + "type": "quoted-string" + } } ] }, diff --git a/scripts/Curve Tracer/Curve Tracer.py b/scripts/Curve Tracer/Curve Tracer.py index dca20aabd..6726df548 100644 --- a/scripts/Curve Tracer/Curve Tracer.py +++ b/scripts/Curve Tracer/Curve Tracer.py @@ -126,7 +126,7 @@ def start_BJT(cgnd): scpi("CURR " + str(Ic_max)) scpi("SENS:CURR:RANG DEFault") - scpi('SENS:DLOG:TRAC:COMMent "Device name = ' + deviceName + '; Uce,max = ' + str(Uce_max) + '; Ic,max = ' + str(Ic_max) + '"') + scpi('SENS:DLOG:TRAC:REM "Device name = ' + deviceName + '; Uce,max = ' + str(Uce_max) + '; Ic,max = ' + str(Ic_max) + '"') scpi("SENS:DLOG:TRAC:X:UNIT VOLT") scpi("SENS:DLOG:TRAC:X:RANG:MIN " + str(Uce_min)) @@ -217,7 +217,7 @@ def start_MOSFET(cgnd): scpi("VOLT 0") scpi("CURR " + str(Id_max)) - scpi('SENS:DLOG:TRAC:COMMent "Device name = ' + deviceName + '; Uds,max = ' + str(Uds_max) + '; Id,max = ' + str(Id_max) + '"') + scpi('SENS:DLOG:TRAC:REM "Device name = ' + deviceName + '; Uds,max = ' + str(Uds_max) + '; Id,max = ' + str(Id_max) + '"') scpi("SENS:DLOG:TRAC:X:UNIT VOLT") scpi("SENS:DLOG:TRAC:X:RANG:MIN " + str(Uds_logMin)) diff --git a/scripts/Diode Tester/Diode Tester.py b/scripts/Diode Tester/Diode Tester.py index 4f4eae81d..c4027d169 100644 --- a/scripts/Diode Tester/Diode Tester.py +++ b/scripts/Diode Tester/Diode Tester.py @@ -66,7 +66,7 @@ def start(): scpi("VOLT 0") scpi("CURR " + str(I_SET)) - scpi('SENS:DLOG:TRAC:COMMent "Diode name = ' + diode_name + '; U step = ' + str(U_step) + '"') + scpi('SENS:DLOG:TRAC:REM "Diode name = ' + diode_name + '; U step = ' + str(U_step) + '"') scpi("SENS:DLOG:TRAC:X:UNIT VOLT") scpi("SENS:DLOG:TRAC:X:STEP " + str(U_step)) diff --git a/scripts/transfer-curve (NPN).py b/scripts/transfer-curve (NPN).py index 27aa9a381..eb0be5f22 100644 --- a/scripts/transfer-curve (NPN).py +++ b/scripts/transfer-curve (NPN).py @@ -37,7 +37,7 @@ def start(deviceName): scpi("CURR " + str(Ic_max)) scpi("SENS:CURR:RANG DEFault") - scpi('SENS:DLOG:TRAC:COMMent "NPN Transfer curve for ' + deviceName + '"') + scpi('SENS:DLOG:TRAC:REM "NPN Transfer curve for ' + deviceName + '"') scpi("SENS:DLOG:TRAC:X:UNIT VOLT") scpi("SENS:DLOG:TRAC:X:RANG:MIN " + str(Ube_min + Ube_step)) diff --git a/src/eez/modules/psu/dlog_view.cpp b/src/eez/modules/psu/dlog_view.cpp index 39f30ab99..071e96aa4 100644 --- a/src/eez/modules/psu/dlog_view.cpp +++ b/src/eez/modules/psu/dlog_view.cpp @@ -563,7 +563,7 @@ void scaleToFit(Recording &recording) { } } -void openFile(const char *filePath) { +bool openFile(const char *filePath, int *err) { if (osThreadGetId() != g_scpiTaskHandle) { g_state = STATE_LOADING; g_loadingStartTickCount = millis(); @@ -572,11 +572,13 @@ void openFile(const char *filePath) { memset(&g_recording, 0, sizeof(Recording)); osMessagePut(g_scpiMessageQueueId, SCPI_QUEUE_MESSAGE(SCPI_QUEUE_MESSAGE_TARGET_NONE, SCPI_QUEUE_MESSAGE_DLOG_SHOW_FILE, 0), osWaitForever); - return; + return true; } + g_state = STATE_LOADING; + File file; - if (file.open(g_filePath, FILE_OPEN_EXISTING | FILE_READ)) { + if (file.open(filePath != nullptr ? filePath : g_filePath, FILE_OPEN_EXISTING | FILE_READ)) { uint8_t * buffer = FILE_VIEW_BUFFER; uint32_t read = file.read(buffer, DLOG_VERSION1_HEADER_SIZE); if (read == DLOG_VERSION1_HEADER_SIZE) { @@ -749,13 +751,26 @@ void openFile(const char *filePath) { } } } + + if (g_state != STATE_READY) { + if (err) { + // TODO + *err = SCPI_ERROR_MASS_STORAGE_ERROR; + } + } + } else { + if (err) { + *err = SCPI_ERROR_FILE_NOT_FOUND; + } } file.close(); - if (g_state == STATE_LOADING) { + if (g_state != STATE_READY) { g_state = STATE_ERROR; } + + return g_state != STATE_ERROR; } Recording &getRecording() { diff --git a/src/eez/modules/psu/dlog_view.h b/src/eez/modules/psu/dlog_view.h index 61c71ef56..b50f326d9 100644 --- a/src/eez/modules/psu/dlog_view.h +++ b/src/eez/modules/psu/dlog_view.h @@ -208,7 +208,7 @@ extern bool g_showLegend; extern bool g_showLabels; // open dlog file for viewing -void openFile(const char *filePath); +bool openFile(const char *filePath, int *err = nullptr); extern State getState(); diff --git a/src/eez/modules/psu/scpi/display.cpp b/src/eez/modules/psu/scpi/display.cpp index 66008da13..1d3b6eefd 100644 --- a/src/eez/modules/psu/scpi/display.cpp +++ b/src/eez/modules/psu/scpi/display.cpp @@ -27,6 +27,7 @@ #include #endif +#include #include #include @@ -197,7 +198,29 @@ scpi_result_t scpi_cmd_displayDataQ(scpi_t *context) { scpi_result_t scpi_cmd_displayWindowDlog(scpi_t *context) { #if OPTION_DISPLAY - dlog_view::g_showLatest = true; + char filePath[MAX_PATH_LENGTH + 1]; + bool isFilePathSpecified; + if (!getFilePath(context, filePath, false, &isFilePathSpecified)) { + return SCPI_RES_ERR; + } + + if (isFilePathSpecified) { + psu::dlog_view::g_showLatest = false; + int err; + if (!psu::dlog_view::openFile(filePath, &err)) { + SCPI_ErrorPush(context, err); + return SCPI_RES_ERR; + } + + } else { + dlog_view::g_showLatest = true; + if (!dlog_record::isExecuting()) { + if (dlog_record::getLatestFilePath()) { + dlog_view::openFile(dlog_record::getLatestFilePath()); + } + } + } + psu::gui::pushPage(PAGE_ID_DLOG_VIEW); return SCPI_RES_OK; #else diff --git a/src/eez/modules/psu/scpi/dlog.cpp b/src/eez/modules/psu/scpi/dlog.cpp index 5a666e10f..fb12f0778 100644 --- a/src/eez/modules/psu/scpi/dlog.cpp +++ b/src/eez/modules/psu/scpi/dlog.cpp @@ -229,7 +229,7 @@ scpi_result_t scpi_cmd_senseDlogTimeQ(scpi_t *context) { return SCPI_RES_OK; } -scpi_result_t scpi_cmd_senseDlogTraceComment(scpi_t *context) { +scpi_result_t scpi_cmd_senseDlogTraceRemark(scpi_t *context) { if (!dlog_record::isIdle()) { SCPI_ErrorPush(context, SCPI_ERROR_CANNOT_CHANGE_TRANSIENT_TRIGGER); return SCPI_RES_ERR; @@ -252,7 +252,7 @@ scpi_result_t scpi_cmd_senseDlogTraceComment(scpi_t *context) { return SCPI_RES_OK; } -scpi_result_t scpi_cmd_senseDlogTraceCommentQ(scpi_t *context) { +scpi_result_t scpi_cmd_senseDlogTraceRemarkQ(scpi_t *context) { SCPI_ResultText(context, dlog_record::g_parameters.comment); return SCPI_RES_OK; } diff --git a/src/eez/modules/psu/scpi/params.cpp b/src/eez/modules/psu/scpi/params.cpp index 09538822f..b03f39f8c 100644 --- a/src/eez/modules/psu/scpi/params.cpp +++ b/src/eez/modules/psu/scpi/params.cpp @@ -204,8 +204,6 @@ uint32_t param_channels(scpi_t *context, scpi_parameter_t *parameter, scpi_bool_ } Channel *set_channel_from_command_number(scpi_t *context) { - scpi_psu_t *psu_context = (scpi_psu_t *)context->user_context; - int32_t channelIndex; SCPI_CommandNumbers(context, &channelIndex, 1, -1); if (channelIndex != -1) { @@ -734,7 +732,7 @@ void cleanupPath(char *filePath) { *q = 0; } -bool getFilePath(scpi_t *context, char *filePath, bool mandatory) { +bool getFilePath(scpi_t *context, char *filePath, bool mandatory, bool *isParameterSpecified) { scpi_psu_t *psuContext = (scpi_psu_t *)context->user_context; const char *filePathParam; @@ -763,11 +761,17 @@ bool getFilePath(scpi_t *context, char *filePath, bool mandatory) { strncpy(filePath + currentDirectoryLen + 1, filePathParam, filePathParamLen); filePath[filePathLen] = 0; } + if (isParameterSpecified) { + *isParameterSpecified = true; + } } else { if (SCPI_ParamErrorOccurred(context)) { return false; } strcpy(filePath, psuContext->currentDirectory); + if (isParameterSpecified) { + *isParameterSpecified = false; + } } cleanupPath(filePath); diff --git a/src/eez/modules/psu/scpi/params.h b/src/eez/modules/psu/scpi/params.h index 622e30634..a04cfac18 100644 --- a/src/eez/modules/psu/scpi/params.h +++ b/src/eez/modules/psu/scpi/params.h @@ -63,7 +63,8 @@ bool get_profile_location_param(scpi_t *context, int &location, bool all_locatio void outputOnTime(scpi_t* context, uint32_t time); bool checkPassword(scpi_t *context, const char *againstPassword); -bool getFilePath(scpi_t *context, char *filePath, bool mandatory); +// returns current directory if parameter is not specified +bool getFilePath(scpi_t *context, char *filePath, bool mandatory, bool *isParameterSpecified = nullptr); } } diff --git a/src/eez/scpi/commands_simulator.h b/src/eez/scpi/commands_simulator.h index 42851fd47..b346ea925 100644 --- a/src/eez/scpi/commands_simulator.h +++ b/src/eez/scpi/commands_simulator.h @@ -163,7 +163,8 @@ SCPI_COMMAND("SENSe:DLOG:TRACe:Y:SCALe", scpi_cmd_senseDlogTraceYScale) \ SCPI_COMMAND("SENSe:DLOG:TRACe:Y:SCALe?", scpi_cmd_senseDlogTraceYScaleQ) \ SCPI_COMMAND("SENSe:DLOG:TRACe[:DATA]", scpi_cmd_senseDlogTraceData) \ - SCPI_COMMAND("SENSe:DLOG:TRACe:COMMent", scpi_cmd_senseDlogTraceComment) \ + SCPI_COMMAND("SENSe:DLOG:TRACe:REMark", scpi_cmd_senseDlogTraceRemark) \ + SCPI_COMMAND("SENSe:DLOG:TRACe:REMark?", scpi_cmd_senseDlogTraceRemarkQ) \ SCPI_COMMAND("[SOURce#]:CURRent:LIMit[:POSitive][:IMMediate][:AMPLitude]", scpi_cmd_sourceCurrentLimitPositiveImmediateAmplitude) \ SCPI_COMMAND("[SOURce#]:CURRent:LIMit[:POSitive][:IMMediate][:AMPLitude]?", scpi_cmd_sourceCurrentLimitPositiveImmediateAmplitudeQ) \ SCPI_COMMAND("[SOURce#]:CURRent:MODE", scpi_cmd_sourceCurrentMode) \ diff --git a/src/eez/scpi/commands_stm32.h b/src/eez/scpi/commands_stm32.h index 42851fd47..b346ea925 100644 --- a/src/eez/scpi/commands_stm32.h +++ b/src/eez/scpi/commands_stm32.h @@ -163,7 +163,8 @@ SCPI_COMMAND("SENSe:DLOG:TRACe:Y:SCALe", scpi_cmd_senseDlogTraceYScale) \ SCPI_COMMAND("SENSe:DLOG:TRACe:Y:SCALe?", scpi_cmd_senseDlogTraceYScaleQ) \ SCPI_COMMAND("SENSe:DLOG:TRACe[:DATA]", scpi_cmd_senseDlogTraceData) \ - SCPI_COMMAND("SENSe:DLOG:TRACe:COMMent", scpi_cmd_senseDlogTraceComment) \ + SCPI_COMMAND("SENSe:DLOG:TRACe:REMark", scpi_cmd_senseDlogTraceRemark) \ + SCPI_COMMAND("SENSe:DLOG:TRACe:REMark?", scpi_cmd_senseDlogTraceRemarkQ) \ SCPI_COMMAND("[SOURce#]:CURRent:LIMit[:POSitive][:IMMediate][:AMPLitude]", scpi_cmd_sourceCurrentLimitPositiveImmediateAmplitude) \ SCPI_COMMAND("[SOURce#]:CURRent:LIMit[:POSitive][:IMMediate][:AMPLitude]?", scpi_cmd_sourceCurrentLimitPositiveImmediateAmplitudeQ) \ SCPI_COMMAND("[SOURce#]:CURRent:MODE", scpi_cmd_sourceCurrentMode) \