Skip to content

Commit

Permalink
#27
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed May 22, 2020
1 parent 40b39bc commit 9104177
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
17 changes: 17 additions & 0 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -72646,6 +72646,23 @@
"type": "quoted-string"
}
},
{
"name": "SYSTem:SLOT:FIRMware?",
"helpLink": "EEZ BB3 SCPI reference 5.16 - SYSTem.html#syst_cpu_mod",
"parameters": [
{
"name": "slot_index",
"type": [
{
"type": "nr1"
}
]
}
],
"response": {
"type": "quoted-string"
}
},
{
"name": "SYSTem:CHANnel:INFOrmation:CURRent?",
"helpLink": "EEZ BB3 SCPI reference 5.16 - SYSTem.html#syst_chan_curr",
Expand Down
44 changes: 31 additions & 13 deletions src/eez/modules/psu/scpi/syst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,19 +409,26 @@ scpi_result_t scpi_cmd_systemSlotCountQ(scpi_t *context) {
return SCPI_RES_OK;
}

scpi_result_t scpi_cmd_systemSlotModelQ(scpi_t *context) {
Module *getModuleFromSlotIndexParam(scpi_t *context) {
int32_t slotIndex;
if (!SCPI_ParamInt(context, &slotIndex, TRUE)) {
return SCPI_RES_ERR;
return nullptr;
}
if (slotIndex < 0 && slotIndex > NUM_SLOTS) {
SCPI_ErrorPush(context, SCPI_ERROR_ILLEGAL_PARAMETER_VALUE);
return nullptr;
}
return g_slots[slotIndex - 1];
}

scpi_result_t scpi_cmd_systemSlotModelQ(scpi_t *context) {
auto module = getModuleFromSlotIndexParam(context);
if (!module) {
return SCPI_RES_ERR;
}
slotIndex--;

if (g_slots[slotIndex]->moduleInfo->moduleType != MODULE_TYPE_NONE) {
SCPI_ResultText(context, g_slots[slotIndex]->moduleInfo->moduleName);
if (module->moduleInfo->moduleType != MODULE_TYPE_NONE) {
SCPI_ResultText(context, module->moduleInfo->moduleName);
} else {
SCPI_ResultText(context, "");
}
Expand All @@ -430,20 +437,31 @@ scpi_result_t scpi_cmd_systemSlotModelQ(scpi_t *context) {
}

scpi_result_t scpi_cmd_systemSlotVersionQ(scpi_t *context) {
int32_t slotIndex;
if (!SCPI_ParamInt(context, &slotIndex, TRUE)) {
auto module = getModuleFromSlotIndexParam(context);
if (!module) {
return SCPI_RES_ERR;
}
if (slotIndex < 0 && slotIndex > NUM_SLOTS) {
SCPI_ErrorPush(context, SCPI_ERROR_ILLEGAL_PARAMETER_VALUE);

if (module->moduleInfo->moduleType != MODULE_TYPE_NONE) {
char text[50];
sprintf(text, "R%dB%d", (int)(module->moduleRevision >> 8), (int)(module->moduleRevision & 0xFF));
SCPI_ResultText(context, text);
} else {
SCPI_ResultText(context, "");
}

return SCPI_RES_OK;
}

scpi_result_t scpi_cmd_systemSlotFirmwareQ(scpi_t *context) {
auto module = getModuleFromSlotIndexParam(context);
if (!module) {
return SCPI_RES_ERR;
}
slotIndex--;

auto slot = g_slots[slotIndex];
if (g_slots[slotIndex]->moduleInfo->moduleType != MODULE_TYPE_NONE) {
if (module->moduleInfo->moduleType != MODULE_TYPE_NONE) {
char text[50];
sprintf(text, "R%dB%d", (int)(slot->moduleRevision >> 8), (int)(slot->moduleRevision & 0xFF));
sprintf(text, "%d.%d", (int)(module->firmwareMajorVersion), (int)(module->firmwareMinorVersion));
SCPI_ResultText(context, text);
} else {
SCPI_ResultText(context, "");
Expand Down
1 change: 1 addition & 0 deletions src/eez/scpi/commands_simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
SCPI_COMMAND("SYSTem:SLOT[:COUNt]?", scpi_cmd_systemSlotCountQ) \
SCPI_COMMAND("SYSTem:SLOT:MODel?", scpi_cmd_systemSlotModelQ) \
SCPI_COMMAND("SYSTem:SLOT:VERSion?", scpi_cmd_systemSlotVersionQ) \
SCPI_COMMAND("SYSTem:SLOT:FIRMware?", scpi_cmd_systemSlotFirmwareQ) \
SCPI_COMMAND("SYSTem:CHANnel:INFOrmation:CURRent?", scpi_cmd_systemChannelInformationCurrentQ) \
SCPI_COMMAND("SYSTem:CHANnel:INFOrmation:ONTime:LAST?", scpi_cmd_systemChannelInformationOntimeLastQ) \
SCPI_COMMAND("SYSTem:CHANnel:INFOrmation:ONTime:TOTal?", scpi_cmd_systemChannelInformationOntimeTotalQ) \
Expand Down
1 change: 1 addition & 0 deletions src/eez/scpi/commands_stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
SCPI_COMMAND("SYSTem:SLOT[:COUNt]?", scpi_cmd_systemSlotCountQ) \
SCPI_COMMAND("SYSTem:SLOT:MODel?", scpi_cmd_systemSlotModelQ) \
SCPI_COMMAND("SYSTem:SLOT:VERSion?", scpi_cmd_systemSlotVersionQ) \
SCPI_COMMAND("SYSTem:SLOT:FIRMware?", scpi_cmd_systemSlotFirmwareQ) \
SCPI_COMMAND("SYSTem:CHANnel:INFOrmation:CURRent?", scpi_cmd_systemChannelInformationCurrentQ) \
SCPI_COMMAND("SYSTem:CHANnel:INFOrmation:ONTime:LAST?", scpi_cmd_systemChannelInformationOntimeLastQ) \
SCPI_COMMAND("SYSTem:CHANnel:INFOrmation:ONTime:TOTal?", scpi_cmd_systemChannelInformationOntimeTotalQ) \
Expand Down

0 comments on commit 9104177

Please sign in to comment.