From fa07c7fd8ed745b9608642073a81dbdc36a70c2f Mon Sep 17 00:00:00 2001 From: chrono Date: Sun, 21 Sep 2014 10:24:11 +0200 Subject: [PATCH] Testing better MAX31855 error handling --- lib/max31855.py | 2 +- lib/oven.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/max31855.py b/lib/max31855.py index 38ac170..c95d6ba 100644 --- a/lib/max31855.py +++ b/lib/max31855.py @@ -12,7 +12,7 @@ class MAX31855(object): '''Initialize Soft (Bitbang) SPI bus Parameters: - - cs_pin: Chip Select (CS) / Slave Select (SS) pin (Any GPIO) + - cs_pin: Chip Select (CS) / Slave Select (SS) pin (Any GPIO) - clock_pin: Clock (SCLK / SCK) pin (Any GPIO) - data_pin: Data input (SO / MOSI) pin (Any GPIO) - units: (optional) unit of measurement to return. ("c" (default) | "k" | "f") diff --git a/lib/oven.py b/lib/oven.py index 80f8710..91dafd2 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -4,7 +4,6 @@ import random import datetime import logging import json - import config log = logging.getLogger(__name__) @@ -24,7 +23,6 @@ try: GPIO.setup(config.gpio_cool, GPIO.OUT) GPIO.setup(config.gpio_air, GPIO.OUT) GPIO.setup(config.gpio_door, GPIO.IN, pull_up_down=GPIO.PUD_UP) - gpio_available = True except ImportError: msg = "Could not initialize GPIOs, oven operation will only be simulated!" @@ -182,7 +180,10 @@ class TempSensorReal(TempSensor): def run(self): while True: - self.temperature = self.thermocouple.get() + try: + self.temperature = self.thermocouple.get() + except MAX31855Error as error: + log.error("MAX31855 reported Error: "+ error.value) time.sleep(self.time_step)