Testing better MAX31855 error handling

MAX31855-EH
chrono 2014-09-21 10:24:11 +02:00
rodzic 3168aa90c0
commit fa07c7fd8e
2 zmienionych plików z 5 dodań i 4 usunięć

Wyświetl plik

@ -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")

Wyświetl plik

@ -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)