Quellcode durchsuchen

update: 读取dht12时,如果写入命令失败,就提前返回错误

Wendal Chen vor 5 Jahren
Ursprung
Commit
2e618a317c
1 geänderte Dateien mit 5 neuen und 0 gelöschten Zeilen
  1. 5 0
      luat/modules/luat_lib_i2c.c

+ 5 - 0
luat/modules/luat_lib_i2c.c

@@ -199,6 +199,11 @@ static int l_i2c_readDHT12(lua_State *L) {
     char buff[5] = {0};
     char temp = 0x00;
     int result = luat_i2c_send(id, addr, &temp, 1);
+    if (result) {
+        LLOGD("DHT12 i2c bus write fail");
+        lua_pushboolean(L, 0);
+        return 1;
+    }
     result = luat_i2c_recv(id, addr, buff, 5);
     if (result) {
         lua_pushboolean(L, 0);