Skip to content

Commit 0485078

Browse files
committed
scpi meas temp
1 parent c0ae863 commit 0485078

File tree

8 files changed

+52
-26
lines changed

8 files changed

+52
-26
lines changed

src/eez/firmware.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ void boot() {
171171
}
172172
}
173173

174+
for (int i = psu::CH_NUM; i < CH_MAX; i++) {
175+
psu::Channel::get(i).slotIndex = INVALID_SLOT_INDEX;
176+
}
177+
174178
psu::persist_conf::init();
175179

176180
#if OPTION_DISPLAY

src/eez/index.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,17 @@ ModuleInfo *getModuleInfo(uint16_t moduleType) {
135135
return &g_modules[0];
136136
}
137137

138-
SlotInfo g_slots[NUM_SLOTS] = {
138+
SlotInfo g_slots[NUM_SLOTS + 1] = {
139139
{
140140
&g_modules[0]
141141
},
142142
{
143143
&g_modules[0]
144144
},
145+
{
146+
&g_modules[0]
147+
},
148+
// invalid slot
145149
{
146150
&g_modules[0]
147151
}

src/eez/index.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ struct SlotInfo {
218218
};
219219

220220
static const int NUM_SLOTS = 3;
221-
extern SlotInfo g_slots[NUM_SLOTS];
221+
static const int INVALID_SLOT_INDEX = NUM_SLOTS;
222+
extern SlotInfo g_slots[NUM_SLOTS + 1]; // one more for invalid slot
222223

223224
} // namespace eez

src/eez/modules/psu/profile.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,7 @@ static void saveState(Parameters &profile, List *lists) {
636636
if (i < temp_sensor::NUM_TEMP_SENSORS) {
637637
memcpy(profile.tempProt + i, &temperature::sensors[i].prot_conf, sizeof(temperature::ProtectionConfiguration));
638638
} else {
639-
profile.tempProt[i].sensor = i;
640-
if (profile.tempProt[i].sensor == temp_sensor::AUX) {
639+
if (i == temp_sensor::AUX) {
641640
profile.tempProt[i].delay = OTP_AUX_DEFAULT_DELAY;
642641
profile.tempProt[i].level = OTP_AUX_DEFAULT_LEVEL;
643642
profile.tempProt[i].state = OTP_AUX_DEFAULT_STATE;
@@ -1002,10 +1001,11 @@ static bool profileWrite(WriteContext &ctx, const Parameters &parameters, List *
10021001
}
10031002

10041003
for (int i = 0; i < temp_sensor::NUM_TEMP_SENSORS; ++i) {
1005-
auto &tempSensorProt = parameters.tempProt[i];
1006-
auto &sensor = temperature::sensors[tempSensorProt.sensor];
1004+
auto &sensor = temperature::sensors[i];
10071005
if (sensor.isInstalled()) {
1008-
ctx.group("tempsensor", tempSensorProt.sensor + 1);
1006+
auto &tempSensorProt = parameters.tempProt[i];
1007+
1008+
ctx.group("tempsensor", i + 1);
10091009

10101010
ctx.property("name", sensor.getName());
10111011
ctx.property("delay", tempSensorProt.delay);
@@ -1388,8 +1388,6 @@ static bool profileReadCallback(ReadContext &ctx, Parameters &parameters, List *
13881388

13891389
auto &tempSensorProt = parameters.tempProt[tempSensorIndex];
13901390

1391-
tempSensorProt.sensor = tempSensorIndex;
1392-
13931391
READ_PROPERTY(delay, tempSensorProt.delay);
13941392
READ_PROPERTY(level, tempSensorProt.level);
13951393
READ_PROPERTY(state, tempSensorProt.state);

src/eez/modules/psu/psu.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,7 @@ bool psuReset() {
387387
// TEMP:PROT:STAT[AUX]
388388
for (int i = 0; i < temp_sensor::NUM_TEMP_SENSORS; ++i) {
389389
temperature::ProtectionConfiguration &temp_prot = temperature::sensors[i].prot_conf;
390-
temp_prot.sensor = i;
391-
if (temp_prot.sensor == temp_sensor::AUX) {
390+
if (i == temp_sensor::AUX) {
392391
temp_prot.delay = OTP_AUX_DEFAULT_DELAY;
393392
temp_prot.level = OTP_AUX_DEFAULT_LEVEL;
394393
temp_prot.state = OTP_AUX_DEFAULT_STATE;

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include <eez/modules/psu/channel_dispatcher.h>
2222
#include <eez/modules/psu/scpi/psu.h>
23-
#include <eez/modules/psu/temperature.h>
2423

2524
namespace eez {
2625
namespace psu {
@@ -67,19 +66,6 @@ scpi_result_t scpi_cmd_measureScalarVoltageDcQ(scpi_t *context) {
6766
return SCPI_RES_OK;
6867
}
6968

70-
scpi_result_t scpi_cmd_measureScalarTemperatureThermistorDcQ(scpi_t *context) {
71-
int32_t sensor;
72-
if (!param_temp_sensor(context, sensor)) {
73-
return SCPI_RES_ERR;
74-
}
75-
76-
char buffer[256] = { 0 };
77-
strcatFloat(buffer, temperature::sensors[sensor].measure());
78-
SCPI_ResultCharacters(context, buffer, strlen(buffer));
79-
80-
return SCPI_RES_OK;
81-
}
82-
8369
} // namespace scpi
8470
} // namespace psu
8571
} // namespace eez

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
#endif
4040
#include <eez/modules/psu/io_pins.h>
4141
#include <eez/modules/psu/ontime.h>
42+
#include <eez/modules/psu/temperature.h>
4243

44+
#include <eez/modules/aux_ps/fan.h>
4345
#include <eez/modules/mcu/battery.h>
4446

4547
namespace eez {
@@ -1750,6 +1752,39 @@ scpi_result_t scpi_cmd_systemTimeFormatQ(scpi_t *context) {
17501752
return SCPI_RES_OK;
17511753
}
17521754

1755+
scpi_result_t scpi_cmd_systemFanStatusQ(scpi_t *context) {
1756+
SCPI_ResultInt(context, aux_ps::fan::getStatus());
1757+
return SCPI_RES_OK;
1758+
}
1759+
1760+
scpi_result_t scpi_cmd_systemFanSpeedQ(scpi_t *context) {
1761+
SCPI_ResultInt(context, aux_ps::fan::g_rpm);
1762+
return SCPI_RES_OK;
1763+
}
1764+
1765+
scpi_result_t scpi_cmd_systemMeasureScalarTemperatureThermistorDcQ(scpi_t *context) {
1766+
int32_t sensor;
1767+
if (!param_temp_sensor(context, sensor)) {
1768+
return SCPI_RES_ERR;
1769+
}
1770+
1771+
if (!temperature::sensors[sensor].isInstalled()) {
1772+
SCPI_ErrorPush(context, SCPI_ERROR_HARDWARE_MISSING);
1773+
return SCPI_RES_ERR;
1774+
}
1775+
1776+
if (!temperature::sensors[sensor].isTestOK()) {
1777+
SCPI_ErrorPush(context, SCPI_ERROR_HARDWARE_ERROR);
1778+
return SCPI_RES_ERR;
1779+
}
1780+
1781+
char buffer[256] = { 0 };
1782+
strcatFloat(buffer, temperature::sensors[sensor].measure());
1783+
SCPI_ResultCharacters(context, buffer, strlen(buffer));
1784+
1785+
return SCPI_RES_OK;
1786+
}
1787+
17531788
} // namespace scpi
17541789
} // namespace psu
17551790
} // namespace eez

src/eez/modules/psu/temperature.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace temperature {
3030

3131
/// Configuration data for the temperature protection.
3232
struct ProtectionConfiguration {
33-
int8_t sensor;
3433
float delay;
3534
float level;
3635
bool state;

0 commit comments

Comments
 (0)