Skip to content

Commit 495ab6f

Browse files
committed
1 parent 27a6a4d commit 495ab6f

File tree

5 files changed

+49
-35
lines changed

5 files changed

+49
-35
lines changed

src/eez/modules/psu/channel_dispatcher.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ float getUMaxOvpLevel(const Channel &channel) {
645645

646646
float getUProtectionLevel(const Channel &channel) {
647647
if (channel.channelIndex < 2 && g_couplingType == COUPLING_TYPE_SERIES) {
648-
return Channel::get(0).prot_conf.u_level + Channel::get(1).prot_conf.u_level;
648+
return Channel::get(0).prot_conf.u_level + Channel::get(1).prot_conf.u_level + 0.01;
649649
}
650650
return channel.prot_conf.u_level;
651651
}

src/eez/modules/psu/gui/psu.cpp

+13-14
Original file line numberDiff line numberDiff line change
@@ -931,21 +931,19 @@ bool PsuAppContext::dialogOpen(int *err) {
931931
}
932932

933933
DialogActionResult PsuAppContext::dialogAction(uint32_t timeoutMs, const char *&selectedActionName) {
934-
if (timeoutMs == 0) {
935-
timeoutMs = 1000;
936-
}
937-
timeoutMs = millis() + timeoutMs;
938-
939-
while ((int32_t)(millis() - timeoutMs) < 0) {
940-
if (g_externalActionId != ACTION_ID_NONE) {
941-
break;
942-
}
943-
944-
if (!isPageOnStack(getExternalAssetsFirstPageId())) {
945-
break;
946-
}
934+
if (timeoutMs != 0) {
935+
timeoutMs = millis() + timeoutMs;
936+
if (timeoutMs == 0) {
937+
timeoutMs = 1;
938+
}
939+
}
947940

948-
osDelay(5);
941+
while (
942+
(timeoutMs == 0 || (int32_t)(millis() - timeoutMs) < 0) &&
943+
g_externalActionId == ACTION_ID_NONE &&
944+
isPageOnStack(getExternalAssetsFirstPageId())
945+
) {
946+
osDelay(5);
949947
}
950948

951949
if (g_externalActionId != ACTION_ID_NONE) {
@@ -957,6 +955,7 @@ DialogActionResult PsuAppContext::dialogAction(uint32_t timeoutMs, const char *&
957955
return isPageOnStack(getExternalAssetsFirstPageId()) ? DIALOG_ACTION_RESULT_TIMEOUT : DIALOG_ACTION_RESULT_EXIT;
958956
}
959957

958+
960959
void PsuAppContext::dialogResetDataItemValues() {
961960
for (uint32_t i = 0; i < MAX_NUM_EXTERNAL_DATA_ITEM_VALUES; i++) {
962961
g_externalDataItemValues[i].value = Value();

src/eez/mp.cpp

+24-20
Original file line numberDiff line numberDiff line change
@@ -318,29 +318,33 @@ bool scpi(const char *commandOrQueryText, const char **resultText, size_t *resul
318318
// DebugTrace("> %s\n", commandOrQueryText);
319319

320320
g_scpiDataLen = 0;
321-
322321
g_lastError = 0;
323322

324-
#if 1
325-
g_commandOrQueryText = commandOrQueryText;
326-
sendMessageToLowPriorityThread(MP_EXECUTE_SCPI);
327-
328-
static const uint32_t SCPI_TIMEOUT = 3000;
329-
330-
while (true) {
331-
osEvent event = osMessageGet(g_mpMessageQueueId, SCPI_TIMEOUT);
332-
if (event.status == osEventMessage && event.value.v == QUEUE_MESSAGE_SCPI_RESULT) {
333-
break;
334-
} else {
335-
static char g_scpiError[48];
336-
snprintf(g_scpiError, sizeof(g_scpiError), "SCPI timeout");
337-
mp_raise_ValueError(g_scpiError);
338-
}
323+
bool executeInLowPriorityThread = true;
324+
if (startsWithNoCase(commandOrQueryText, "DISP:INPUT?") || startsWithNoCase(commandOrQueryText, "DISP:DIALOG:ACTION?")) {
325+
executeInLowPriorityThread = false;
326+
}
327+
328+
if (executeInLowPriorityThread) {
329+
g_commandOrQueryText = commandOrQueryText;
330+
sendMessageToLowPriorityThread(MP_EXECUTE_SCPI);
331+
332+
static const uint32_t SCPI_TIMEOUT = 3000;
333+
334+
while (true) {
335+
osEvent event = osMessageGet(g_mpMessageQueueId, SCPI_TIMEOUT);
336+
if (event.status == osEventMessage && event.value.v == QUEUE_MESSAGE_SCPI_RESULT) {
337+
break;
338+
} else {
339+
static char g_scpiError[48];
340+
snprintf(g_scpiError, sizeof(g_scpiError), "SCPI timeout");
341+
mp_raise_ValueError(g_scpiError);
342+
}
343+
}
344+
} else {
345+
input(g_scpiContext, (const char *)commandOrQueryText, strlen(commandOrQueryText));
346+
input(g_scpiContext, "\r\n", 2);
339347
}
340-
#else
341-
input(g_scpiContext, (const char *)commandOrQueryText, strlen(commandOrQueryText));
342-
input(g_scpiContext, "\r\n", 2);
343-
#endif
344348

345349
if (g_lastError != 0) {
346350
static char g_scpiError[48];

src/eez/util.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,16 @@ bool startsWith(const char *str, const char *prefix) {
567567
return strncmp(str, prefix, prefixLen) == 0;
568568
}
569569

570+
bool startsWithNoCase(const char *str, const char *prefix) {
571+
if (!str || !prefix)
572+
return false;
573+
size_t strLen = strlen(str);
574+
size_t prefixLen = strlen(prefix);
575+
if (prefixLen > strLen)
576+
return false;
577+
return strncicmp(str, prefix, prefixLen) == 0;
578+
}
579+
570580
bool endsWith(const char *str, const char *suffix) {
571581
if (!str || !suffix)
572582
return false;

src/eez/util.h

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ int strcicmp(char const *a, char const *b);
124124
int strncicmp(char const *a, char const *b, int n);
125125
bool isStringEmpty(char const *a);
126126
bool startsWith(const char *str, const char *prefix);
127+
bool startsWithNoCase(const char *str, const char *prefix);
127128
bool endsWith(const char *str, const char *suffix);
128129
bool endsWithNoCase(const char *str, const char *suffix);
129130

0 commit comments

Comments
 (0)