aboutsummaryrefslogtreecommitdiffstats
path: root/src/thermocouple.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-07-25 09:06:50 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-07-25 09:06:50 -0400
commit7a9553b38a39398226d95b7569a0b889b8cdb10a (patch)
tree2b46f9b170dec052c0e8bc424af23fb5f829c02b /src/thermocouple.c
parent7d0f3649f354a95cd833879cb7c26d80885ed36e (diff)
downloadkutter-7a9553b38a39398226d95b7569a0b889b8cdb10a.tar.gz
kutter-7a9553b38a39398226d95b7569a0b889b8cdb10a.tar.xz
kutter-7a9553b38a39398226d95b7569a0b889b8cdb10a.zip
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>
Diffstat (limited to 'src/thermocouple.c')
-rw-r--r--src/thermocouple.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/thermocouple.c b/src/thermocouple.c
index 94dc42d2..2389e7b6 100644
--- a/src/thermocouple.c
+++ b/src/thermocouple.c
@@ -68,9 +68,9 @@ command_query_thermocouple(uint32_t *args)
sched_del_timer(&spi->timer);
spi->timer.waketime = args[1];
- if (! spi->timer.waketime)
- return;
spi->rest_time = args[2];
+ if (! spi->rest_time)
+ return;
spi->min_value = args[3];
spi->max_value = args[4];
sched_add_timer(&spi->timer);
@@ -83,12 +83,11 @@ static void
thermocouple_respond(struct thermocouple_spi *spi, uint32_t next_begin_time
, 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",
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