thermocouple: Minor fixes

Send the temperature before checking for an out of range error (that
makes it easier to debug).

The query_thermocouple clock parameter is unpredictable and a value of
zero can't be used to disable the query - use rest_ticks instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-07-25 09:06:50 -04:00
parent 7d0f3649f3
commit 7a9553b38a
1 changed files with 5 additions and 6 deletions

View File

@ -68,9 +68,9 @@ command_query_thermocouple(uint32_t *args)
sched_del_timer(&spi->timer); sched_del_timer(&spi->timer);
spi->timer.waketime = args[1]; spi->timer.waketime = args[1];
if (! spi->timer.waketime)
return;
spi->rest_time = args[2]; spi->rest_time = args[2];
if (! spi->rest_time)
return;
spi->min_value = args[3]; spi->min_value = args[3];
spi->max_value = args[4]; spi->max_value = args[4];
sched_add_timer(&spi->timer); sched_add_timer(&spi->timer);
@ -83,12 +83,11 @@ static void
thermocouple_respond(struct thermocouple_spi *spi, uint32_t next_begin_time thermocouple_respond(struct thermocouple_spi *spi, uint32_t next_begin_time
, uint32_t value, uint8_t fault, uint8_t oid) , uint32_t value, uint8_t fault, uint8_t oid)
{ {
/* check the result and stop if below or above allowed range */
if (value < spi->min_value || value > spi->max_value) {
try_shutdown("Thermocouple ADC out of range");
}
sendf("thermocouple_result oid=%c next_clock=%u value=%u fault=%c", sendf("thermocouple_result oid=%c next_clock=%u value=%u fault=%c",
oid, next_begin_time, value, fault); oid, next_begin_time, value, fault);
/* check the result and stop if below or above allowed range */
if (value < spi->min_value || value > spi->max_value)
try_shutdown("Thermocouple ADC out of range");
} }
static void static void