changeset 76:4abce5954d25

Add a routine to return text versions of errors from the temperature conversion routine.
author darius@Inchoate
date Wed, 21 Jan 2009 22:51:37 +1030
parents 39d629c7d935
children ca5fc59ec4f0
files 1wire.c 1wire.h
diffstat 2 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/1wire.c	Wed Jan 21 22:50:43 2009 +1030
+++ b/1wire.c	Wed Jan 21 22:51:37 2009 +1030
@@ -596,3 +596,48 @@
 
     return(temp);
 }
+
+/*
+ * OWTempStatusStr
+ *
+ * Return a string for each OW_TEMP_xxx error code
+ *
+ * shrt = 1 returns short strings
+ *
+ */
+const char *
+OWTempStatusStr(int16_t val, uint8_t shrt) {
+    if (val > OW_TEMP_BADVAL) {
+        if (shrt)
+            return PSTR("OK");
+        else
+            return PSTR("OK");
+    }
+
+    switch (val) {
+        case OW_TEMP_WRONG_FAM:
+            if (shrt)
+                return PSTR("WrFam");
+            else
+                return PSTR("Wrong family");
+            break;
+        case OW_TEMP_CRC_ERR:
+            if (shrt)
+                return PSTR("CRCErr");
+            else
+                return PSTR("CRC Error");
+            break;
+        case OW_TEMP_NO_ROM:
+            if (shrt)
+                return PSTR("NoROM");
+            else
+                return PSTR("ROM did not reply");
+            break;
+        default:
+            if (shrt)
+                return PSTR("???");
+            else
+                return PSTR("Unknown error code");
+            break;
+    }
+}
--- a/1wire.h	Wed Jan 21 22:50:43 2009 +1030
+++ b/1wire.h	Wed Jan 21 22:51:37 2009 +1030
@@ -42,6 +42,7 @@
 void		OWSendCmd(uint8_t *ROM, uint8_t cmd);
 uint8_t		OWProgROM(uint8_t *ROM, uint8_t start, uint8_t len, uint8_t *data, uint8_t exact, uint8_t status);
 int16_t		OWGetTemp(uint8_t *ROM);
+const PROGMEM char *OWTempStatusStr(int16_t val, uint8_t shrt);
 extern const PROGMEM char *OWProgROM_Status[];