소스 검색

Fixed a program crash at 1-Wire init

Philipp Hinz 7 년 전
부모
커밋
46fcbb2b31
4개의 변경된 파일26개의 추가작업 그리고 22개의 파일을 삭제
  1. 10 9
      CoffeeCode/DS18B20.cpp
  2. 1 1
      CoffeeCode/buildno
  3. 15 0
      CoffeeCode/display.cpp
  4. 0 12
      CoffeeCode/display.h

+ 10 - 9
CoffeeCode/DS18B20.cpp

@@ -19,7 +19,7 @@
 /*
  * | -- 8 BIT CRC -- | -- 48 BIT SERIAL NUMBER -- | -- 8 BIT FAMILY CODE (28h) -- |
  */
-uint8_t ROM[8] = {0,0,0,0,0,0,0,0};
+uint8_t rom[8] = {0,0,0,0,0,0,0,0};
 double deviceID;
 
 /**
@@ -30,22 +30,23 @@ double deviceID;
 void DS18B20_init(void){
 	OneWire_init();
 	if(OW_reset()){
-		logger_error("Unable to reset 1-Wire Bus, no Device present %s\n", strerror(errno));
+		logger_error("Unable to reset 1-Wire Bus, no device present %s\n", strerror(errno));
 		return;
 	}
+	logger(V_HAL, "Checking 1-Wire Bus for sensors..\n");
 	DS18B20_readRom();
-	deviceID = double (ROM[1]);// | ROM[5] << 8 | ROM[5] << 16 | ROM[5] << 24 | ROM[5] << 32 | ROM[5] << 40);
-	if(ROM[7] == 0x28){
-		logger(V_HAL, "Found Temperatur Sensor on 1-Wire Bus\n");
-		logger(V_HAL, "Device ID: %12X", deviceID);
+	deviceID = double (rom[1]);// | ROM[5] << 8 | ROM[5] << 16 | ROM[5] << 24 | ROM[5] << 32 | ROM[5] << 40);
+	if(rom[7] == 0x28){
+		logger(V_HAL, "Found temperatur sensor on 1-Wire Bus\n");
+		logger(V_HAL, "Device ID: %12X\n", deviceID);
 	}
 }
 
 void DS18B20_readRom(void){
 	OW_writeByte(READ_ROM);
-	uint8_t i;
-	for(i = 8; i >= 0; i--){
-		ROM[i] = OW_readByte();
+	int i;
+	for(i = 7; i >= 0; i--){
+		rom[i] = OW_readByte();
 	}
 }
 

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-185
+197

+ 15 - 0
CoffeeCode/display.cpp

@@ -4,7 +4,22 @@
  *  Created on: Sep 26, 2017
  *      Author: Philipp Hinz
  */
+#include <stdlib.h>
+#include <pthread.h>
+#include <time.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "global.h"
 #include "display.h"
+#include "logger.h"
+#include "database.h"
+#include "timer.h"
+#include "lcd.h"
+#include "coffee.h"
+#include "hal.h"
+#include "events.h"
+
 
 display_lang_t displayLang;
 timer displayTimer(displayTimerHandler);

+ 0 - 12
CoffeeCode/display.h

@@ -8,19 +8,7 @@
 #ifndef DISPLAY_H_
 #define DISPLAY_H_
 #include <string>
-#include <stdlib.h>
-#include <pthread.h>
-#include <time.h>
-#include <unistd.h>
-#include <string.h>
-#include "global.h"
-#include "logger.h"
-#include "database.h"
-#include "timer.h"
-#include "lcd.h"
 #include "coffee.h"
-#include "hal.h"
-#include "events.h"
 
 typedef enum {
 	lang_de,