Skip to content

Commit 23cb694

Browse files
committed
1 parent be03b4a commit 23cb694

File tree

5 files changed

+70
-10
lines changed

5 files changed

+70
-10
lines changed

src/eez/index.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -241,22 +241,34 @@ const char *Module::getDefaultLabel() {
241241
return moduleName;
242242
}
243243

244-
void Module::setLabel(const char *value, int length) {
244+
eez_err_t Module::getLabel(const char *&label) {
245+
label = this->label;
246+
return SCPI_RES_OK;
247+
}
248+
249+
eez_err_t Module::setLabel(const char *value, int length) {
245250
if (length == -1) {
246251
length = strlen(value);
247252
}
248253
if (length > (int)SLOT_LABEL_MAX_LENGTH) {
249254
length = SLOT_LABEL_MAX_LENGTH;
250255
}
251256
stringCopy(label, length + 1, value);
257+
return SCPI_RES_OK;
252258
}
253259

254260
uint8_t Module::getColor() {
255261
return color;
256262
}
257263

258-
void Module::setColor(uint8_t value) {
264+
eez_err_t Module::getColor(uint8_t &color) {
265+
color = this->color;
266+
return SCPI_RES_OK;
267+
}
268+
269+
eez_err_t Module::setColor(uint8_t value) {
259270
color = value;
271+
return SCPI_RES_OK;
260272
}
261273

262274
size_t Module::getChannelLabelMaxLength(int subchannelIndex) {

src/eez/index.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,14 @@ struct Module {
263263
virtual bool isValidSubchannelIndex(int subchannelIndex);
264264
virtual int getSubchannelIndexFromRelativeChannelIndex(int relativeChannelIndex);
265265

266-
const char * getLabel();
266+
const char *getLabel();
267267
const char *getDefaultLabel();
268268
const char *getLabelOrDefault() {return *label ? label : getDefaultLabel(); }
269-
void setLabel(const char *label, int length = -1);
269+
virtual eez_err_t getLabel(const char *&label);
270+
virtual eez_err_t setLabel(const char *label, int length = -1);
270271
uint8_t getColor();
271-
void setColor(uint8_t color);
272+
virtual eez_err_t getColor(uint8_t &color);
273+
virtual eez_err_t setColor(uint8_t color);
272274

273275
virtual size_t getChannelLabelMaxLength(int subchannelIndex);
274276
virtual const char *getChannelLabel(int subchannelIndex);

src/eez/modules/psu/psu.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,22 @@ bool PsuModule::testAutoRecallValuesMatch(uint8_t *bufferRecall, uint8_t *buffer
628628
recallParameters->i_set == defaultParameters->i_set;
629629
}
630630

631+
eez_err_t PsuModule::getLabel(const char *&label) {
632+
return SCPI_ERROR_HARDWARE_MISSING;
633+
}
634+
635+
eez_err_t PsuModule::setLabel(const char *label, int length) {
636+
return SCPI_ERROR_HARDWARE_MISSING;
637+
}
638+
639+
eez_err_t PsuModule::getColor(uint8_t &color) {
640+
return SCPI_ERROR_HARDWARE_MISSING;
641+
}
642+
643+
eez_err_t PsuModule::setColor(uint8_t color) {
644+
return SCPI_ERROR_HARDWARE_MISSING;
645+
}
646+
631647
size_t PsuModule::getChannelLabelMaxLength(int subchannelIndex) {
632648
return Channel::CHANNEL_LABEL_MAX_LENGTH;
633649
}

src/eez/modules/psu/psu.h

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ struct PsuModule : public Module {
7878
float getProfileISet(uint8_t *buffer) override;
7979
bool testAutoRecallValuesMatch(uint8_t *bufferRecall, uint8_t *bufferDefault) override;
8080

81+
eez_err_t getLabel(const char *&label) override;
82+
eez_err_t setLabel(const char *label, int length = -1) override;
83+
eez_err_t getColor(uint8_t &color) override;
84+
eez_err_t setColor(uint8_t color) override;
85+
8186
size_t getChannelLabelMaxLength(int subchannelIndex) override;
8287
const char *getChannelLabel(int subchannelIndex) override;
8388
const char *getDefaultChannelLabel(int subchannelIndex) override;

src/eez/modules/psu/scpi/syst.cpp

+30-5
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,11 @@ scpi_result_t scpi_cmd_systemSlotLabel(scpi_t *context) {
20862086
return SCPI_RES_ERR;
20872087
}
20882088

2089-
module->setLabel(label, labelLength);
2089+
auto err = module->setLabel(label, labelLength);
2090+
if (err != SCPI_RES_OK) {
2091+
SCPI_ErrorPush(context, err);
2092+
return SCPI_RES_ERR;
2093+
}
20902094

20912095
#if OPTION_DISPLAY
20922096
refreshScreen();
@@ -2101,8 +2105,18 @@ scpi_result_t scpi_cmd_systemSlotLabelQ(scpi_t *context) {
21012105
return SCPI_RES_ERR;
21022106
}
21032107

2104-
const char *label = module->getLabelOrDefault();
2105-
SCPI_ResultText(context, label);
2108+
const char *label;
2109+
auto err = module->getLabel(label);
2110+
if (err != SCPI_RES_OK) {
2111+
SCPI_ErrorPush(context, err);
2112+
return SCPI_RES_ERR;
2113+
}
2114+
2115+
if (*label) {
2116+
SCPI_ResultText(context, label);
2117+
} else {
2118+
SCPI_ResultText(context, module->getDefaultLabel());
2119+
}
21062120

21072121
return SCPI_RES_OK;
21082122
}
@@ -2131,7 +2145,11 @@ scpi_result_t scpi_cmd_systemSlotColor(scpi_t *context) {
21312145
return SCPI_RES_ERR;
21322146
}
21332147

2134-
module->setColor(color);
2148+
auto err = module->setColor(color);
2149+
if (err != SCPI_RES_OK) {
2150+
SCPI_ErrorPush(context, err);
2151+
return SCPI_RES_ERR;
2152+
}
21352153

21362154
#if OPTION_DISPLAY
21372155
refreshScreen();
@@ -2146,7 +2164,14 @@ scpi_result_t scpi_cmd_systemSlotColorQ(scpi_t *context) {
21462164
return SCPI_RES_ERR;
21472165
}
21482166

2149-
SCPI_ResultUInt8(context, module->getColor());
2167+
uint8_t color;
2168+
auto err = module->getColor(color);
2169+
if (err != SCPI_RES_OK) {
2170+
SCPI_ErrorPush(context, err);
2171+
return SCPI_RES_ERR;
2172+
}
2173+
2174+
SCPI_ResultUInt8(context, color);
21502175

21512176
return SCPI_RES_OK;
21522177
}

0 commit comments

Comments
 (0)