[avr + fsync] check against MAX_ANALOG_SENSOR
This commit is contained in:
parent
13fad26051
commit
23b47bd955
|
@ -339,7 +339,7 @@ void ctrlCmdGet(uint8_t cmd)
|
|||
|
||||
cli();
|
||||
tmp32 = sensor[i].counter;
|
||||
tmp32_bis = (i < 3) ? state[i].power : state[i].timestamp;
|
||||
tmp32_bis = (i < MAX_ANALOG_SENSORS) ? state[i].power : state[i].timestamp;
|
||||
state[i].flags &= ~(STATE_PULSE | STATE_POWER);
|
||||
sei();
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#define DISABLE_PORT 0xff
|
||||
|
||||
#define MAX_SENSORS 6
|
||||
#define MAX_ANALOG_SENSORS 3
|
||||
|
||||
#define ENABLE_ALL_SENSORS ((1 << MAX_SENSORS) - 1)
|
||||
#define DISABLE_ALL_SENSORS 0x00
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ int main(void)
|
|||
spi_status &= ~SPI_NEW_CTRL_MSG;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SENSORS; i++) {
|
||||
for (i = 0; i < MAX_ANALOG_SENSORS; i++) {
|
||||
if (state[i].flags & STATE_POWER_CALC) {
|
||||
calculate_power(&state[i]);
|
||||
state[i].flags &= ~STATE_POWER_CALC;
|
||||
|
|
|
@ -4,6 +4,7 @@ config settings main
|
|||
option sw_major 1
|
||||
option sw_minor 0
|
||||
option max_sensors 6
|
||||
option max_analog_sensors 3
|
||||
option reset_counters 0
|
||||
|
||||
### sensor config options
|
||||
|
|
|
@ -102,6 +102,7 @@ local flukso = uci:get_all('flukso')
|
|||
local HW_CHECK_OVERRIDE = (arg[1] == '-f')
|
||||
|
||||
local MAX_SENSORS = tonumber(flukso.main.max_sensors)
|
||||
local MAX_ANALOG_SENSORS = tonumber(flukso.main.max_analog_sensors)
|
||||
local METERCONST_FACTOR = 0.449
|
||||
|
||||
local GET_HW_VERSION = 'gh'
|
||||
|
@ -145,14 +146,20 @@ local phy_to_log = {}
|
|||
|
||||
for i = 1, MAX_SENSORS do
|
||||
if flukso[tostring(i)] ~= nil then
|
||||
if flukso[tostring(i)]['type'] == 'analog' and i > MAX_ANALOG_SENSORS then
|
||||
print(string.format('Error. Analog sensor %s should be less than or equal to max_analog_sensors (%s)', i, MAX_ANALOG_SENSORS))
|
||||
os.exit(4)
|
||||
end
|
||||
|
||||
local ports = flukso[tostring(i)].port or {}
|
||||
|
||||
for j = 1, #ports do
|
||||
if tonumber(ports[j]) <= MAX_SENSORS then
|
||||
phy_to_log[toc(tonumber(ports[j]))] = toc(i)
|
||||
else
|
||||
if tonumber(ports[j]) > MAX_SENSORS then
|
||||
print(string.format('Error. Port numbering in sensor %s should be less than or equal to max_sensors (%s)', i, MAX_SENSORS))
|
||||
os.exit(4)
|
||||
os.exit(5)
|
||||
|
||||
else
|
||||
phy_to_log[toc(tonumber(ports[j]))] = toc(i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue