Skip to content

Commit 3af7fa1

Browse files
committed
move delete profile lists files to SCPI thread
1 parent ae3ff59 commit 3af7fa1

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/eez/apps/psu/profile.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@
3131
#if OPTION_SD_CARD
3232
#include <eez/apps/psu/sd_card.h>
3333
#endif
34+
#include <eez/scpi/scpi.h>
3435

3536
namespace eez {
37+
38+
using namespace scpi;
39+
3640
namespace psu {
3741
namespace profile {
3842

@@ -113,6 +117,15 @@ void deleteProfileList(Channel &channel, int location) {
113117
}
114118
}
115119

120+
void deleteProfileLists(int location) {
121+
#if OPTION_SD_CARD
122+
for (int i = 0; i < CH_NUM; ++i) {
123+
Channel &channel = Channel::get(i);
124+
deleteProfileList(channel, location);
125+
}
126+
#endif
127+
}
128+
116129
#endif
117130

118131
////////////////////////////////////////////////////////////////////////////////
@@ -537,12 +550,11 @@ bool deleteLocation(int location) {
537550
}
538551
result = persist_conf::saveProfile(location, &profile);
539552

540-
#if OPTION_SD_CARD
541-
for (int i = 0; i < CH_NUM; ++i) {
542-
Channel &channel = Channel::get(i);
543-
deleteProfileList(channel, location);
544-
}
545-
#endif
553+
if (osThreadGetId() != g_scpiTaskHandle) {
554+
osMessagePut(g_scpiMessageQueueId, SCPI_QUEUE_MESSAGE(SCPI_QUEUE_MESSAGE_TARGET_NONE, SCPI_QUEUE_MESSAGE_TYPE_DELETE_PROFILE_LISTS, location), osWaitForever);
555+
return true;
556+
}
557+
546558
}
547559
return result;
548560
}

src/eez/apps/psu/profile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ bool saveAtLocation(int location, const char *name = nullptr);
113113

114114
bool saveToFile(const char *filePath, int *err);
115115

116+
void deleteProfileLists(int location);
117+
116118
bool deleteLocation(int location);
117119
bool deleteAll();
118120

src/eez/scpi/scpi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void oneIter() {
100100
if (!eez::psu::list::saveList(param, &g_listFilePath[param][0], &err)) {
101101
generateError(err);
102102
}
103+
} else if (type == SCPI_QUEUE_MESSAGE_TYPE_DELETE_PROFILE_LISTS) {
104+
profile::deleteProfileLists(param);
103105
}
104106
}
105107
} else {

src/eez/scpi/scpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extern osMessageQId g_scpiMessageQueueId;
4949
#define SCPI_QUEUE_ETHERNET_MESSAGE(type, param) SCPI_QUEUE_MESSAGE(SCPI_QUEUE_MESSAGE_TARGET_ETHERNET, type, param)
5050

5151
#define SCPI_QUEUE_MESSAGE_TYPE_SAVE_LIST 1
52+
#define SCPI_QUEUE_MESSAGE_TYPE_DELETE_PROFILE_LISTS 2
5253

5354
extern char g_listFilePath[CH_MAX][MAX_PATH_LENGTH];
5455

0 commit comments

Comments
 (0)