# HG changeset patch # User Michiel Broek # Date 1573135791 -3600 # Node ID 58a328e918818f4a330c105703a9f6d9a8266d4c # Parent cceb36fd3a2ac1361d48cfb6070e5788f8ce0f0e Added error logging for failed locks diff -r cceb36fd3a2a -r 58a328e91881 main/co2meter.c --- a/main/co2meter.c Thu Nov 07 11:47:15 2019 +0100 +++ b/main/co2meter.c Thu Nov 07 15:09:51 2019 +0100 @@ -206,7 +206,9 @@ strncpy(rom_code, ds18b20_state->sensor[0].rom_code, 17); rom_code[16] = '\0'; xSemaphoreGive(xSemaphoreDS18B20); - } + } else { + ESP_LOGE(TAG, "ML1_MQTT_CONNECT DS18B20 lock error"); + } /* Copy measured data and calculate results */ if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) { @@ -233,11 +235,15 @@ // Verbruik 10 mA // Setup tijd max 2 mS xSemaphoreGive(xSemaphoreADC); - } + } else { + ESP_LOGE(TAG, "ML1_MQTT_CONNECT ADC lock error"); + } } write_units(); xSemaphoreGive(xSemaphoreUnits); user_refresh(); + } else { + ESP_LOGE(TAG, "ML1_MQTT_CONNECT units lock error"); } } break; diff -r cceb36fd3a2a -r 58a328e91881 main/task_ds18b20.c --- a/main/task_ds18b20.c Thu Nov 07 11:47:15 2019 +0100 +++ b/main/task_ds18b20.c Thu Nov 07 15:09:51 2019 +0100 @@ -146,6 +146,10 @@ ds18b20_state->sensor[i].error = DS18B20_ERR_READ; // All other errors ds18b20_state->valid = false; ds18b20_state->sensor[i].temperature = 0.0; + } else if (readings[i] == 85.0) { // Error value + ds18b20_state->sensor[i].error = DS18B20_ERR_READ; + ds18b20_state->valid = false; + ds18b20_state->sensor[i].temperature = 0.0; } else { ds18b20_state->sensor[i].error = DS18B20_ERR_NONE; ds18b20_state->sensor[i].temperature = readings[i]; diff -r cceb36fd3a2a -r 58a328e91881 main/task_mqtt.c --- a/main/task_mqtt.c Thu Nov 07 11:47:15 2019 +0100 +++ b/main/task_mqtt.c Thu Nov 07 15:09:51 2019 +0100 @@ -91,10 +91,9 @@ */ if (xSemaphoreTake(xSemaphorePcounter, 10) == pdTRUE) { count_pub++; -//printf(" up %d\n", count_pub); xSemaphoreGive(xSemaphorePcounter); } else { - ESP_LOGE(TAG, "Missed lock 1"); + ESP_LOGE(TAG, "publisher() counter lock"); } if (payload) @@ -147,6 +146,8 @@ payload = xstrcat(payload, buf); payload = xstrcat(payload, (char *)"}}"); xSemaphoreGive(xSemaphoreUnits); + } else { + ESP_LOGE(TAG, "unit_data(%d) lock error", i); } return payload; } @@ -204,6 +205,8 @@ payload = xstrcat(payload, buf); payload = xstrcat(payload, (char *)"}"); xSemaphoreGive(xSemaphoreDS18B20); + } else { + ESP_LOGE(TAG, "publishNode() lock DS18B20 error"); } if (xSemaphoreTake(xSemaphoreWiFi, 10) == pdTRUE) { @@ -214,6 +217,8 @@ payload = xstrcat(payload, buf); payload = xstrcat(payload, (char *)"}"); xSemaphoreGive(xSemaphoreWiFi); + } else { + ESP_LOGE(TAG, "publishNode() lock WiFi error"); } payload = xstrcat(payload, (char *)"}}"); @@ -254,6 +259,8 @@ free(payload); payload = NULL; xSemaphoreGive(xSemaphoreUnits); + } else { + ESP_LOGE(TAG, "publishLogs() lock error unit %d", i); } } } @@ -288,11 +295,10 @@ if (xSemaphoreTake(xSemaphorePcounter, 10) == pdTRUE) { if (count_pub) { count_pub--; -//printf("down %d\n", count_pub); } xSemaphoreGive(xSemaphorePcounter); } else { - ESP_LOGE(TAG, "Missed lock 2"); + ESP_LOGE(TAG, "mqtt_event_handler_cb(() lock error event"); } break; @@ -379,7 +385,7 @@ ESP_LOGI(TAG, "Request MQTT connect"); err = esp_mqtt_client_start(client); if (err != ESP_OK) - ESP_LOGI(TAG, "Result %s", esp_err_to_name(err)); + ESP_LOGE(TAG, "Result %s", esp_err_to_name(err)); xEventGroupClearBits(xEventGroupMQTT, TASK_MQTT_CONNECT); } else if (uxBits & TASK_MQTT_DISCONNECT) { diff -r cceb36fd3a2a -r 58a328e91881 main/task_user.c --- a/main/task_user.c Thu Nov 07 11:47:15 2019 +0100 +++ b/main/task_user.c Thu Nov 07 15:09:51 2019 +0100 @@ -107,29 +107,39 @@ { int key = *curkey; int rc = 0; + int8_t ascent = u8g2_GetAscent(&u8g2); + int8_t charheight = u8g2_GetMaxCharHeight(&u8g2); + int8_t charwidth = u8g2_GetMaxCharWidth(&u8g2); u8g2_DrawHLine(&u8g2, x, y+3, 12); u8g2_SendBuffer(&u8g2); + ESP_LOGI(TAG, "getkey(%c, %d, %d, %d) a %d h %d w %d", key, type, x, y, ascent, charheight, charwidth); + for (;;) { if (xQueueReceive(event_queue, &event, 100 / portTICK_PERIOD_MS) == pdTRUE) { UserTimer = INACTIVITY; if (event.state.position != 0) { - u8g2_SetDrawColor(&u8g2, 0); - u8g2_DrawGlyph(&u8g2, x, y, key); - u8g2_SetDrawColor(&u8g2, 1); +// u8g2_SetDrawColor(&u8g2, 0); +// u8g2_DrawGlyph(&u8g2, x, y, key); +// u8g2_SetDrawColor(&u8g2, 1); + + u8g2_DrawBox(&u8g2, x, y - ascent, 16, 16); +// u8g2_UpdateDisplayArea(&u8g2, x, y, 16, 16); u8g2_SendBuffer(&u8g2); if (event.state.position > 0) { - if (key == 126) - key = 171; - else if (key < 126) +// if (key == 126) +// key = 171; +// else + if (key < 127) key++; } else if (event.state.position < 0) { - if (key == 171) - key = 126; - else if (key > 32) +// if (key == 171) +// key = 126; +// else + if (key > 32) key--; } @@ -183,10 +193,12 @@ u8g2_SetFont(&u8g2, u8g2_font_t0_12b_tf); u8g2_DrawStr(&u8g2, 0, 61, errmsg); } - u8g2_SetFont(&u8g2, u8g2_font_t0_12_tf); + u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols); +// u8g2_SetFont(&u8g2, u8g2_font_t0_12_tf); y = 36; u8g2_DrawStr(&u8g2, 0, y, txt); u8g2_SendBuffer(&u8g2); + ESP_LOGI(TAG, "rotary_editer(%s, %s, %s, %d, %d)", label, txt, errmsg, len, type); for (;;) { x = u8g2_GetUTF8Width(&u8g2, txt); @@ -299,6 +311,8 @@ u8g2_DrawUTF8(&u8g2, ((42 - w) / 2) + i * 43,63, buf); } xSemaphoreGive(xSemaphoreUnits); + } else { + ESP_LOGE(TAG, "screen_main() lock error"); } u8g2_SendBuffer(&u8g2); u8g2_SetPowerSave(&u8g2, 0); // wake up display @@ -326,10 +340,12 @@ sprintf(buf, "%.2f bar", units[no].pressure / 1000.0); w = u8g2_GetUTF8Width(&u8g2, buf); u8g2_DrawUTF8(&u8g2, (128 - w) / 2,63, buf); + u8g2_SendBuffer(&u8g2); xSemaphoreGive(xSemaphoreUnits); + } else { + ESP_LOGE(TAG, "screen_unit(%d) lock error", no); } - u8g2_SendBuffer(&u8g2); } diff -r cceb36fd3a2a -r 58a328e91881 main/task_user.h --- a/main/task_user.h Thu Nov 07 11:47:15 2019 +0100 +++ b/main/task_user.h Thu Nov 07 15:09:51 2019 +0100 @@ -14,9 +14,10 @@ #define ROT_ENC_SW_GPIO (CONFIG_ROT_ENC_SW_GPIO) #define INACTIVITY 120 ///< User inactivity time -#define EDIT_TYPE_TEXT 0 ///< Editor type is text -#define EDIT_TYPE_INT 1 ///< Editor type is integer -#define EDIT_TYPE_FLOAT 2 ///< Editor type is float +#define EDIT_TYPE_TEXT 0 ///< Editor type is text, special chars and digits. +#define EDIT_TYPE_CAPS 1 ///< Editor alpha capitals, some specials and digits. +#define EDIT_TYPE_INT 2 ///< Editor type is integer +#define EDIT_TYPE_FLOAT 3 ///< Editor type is float diff -r cceb36fd3a2a -r 58a328e91881 main/task_wifi.c --- a/main/task_wifi.c Thu Nov 07 11:47:15 2019 +0100 +++ b/main/task_wifi.c Thu Nov 07 15:09:51 2019 +0100 @@ -135,7 +135,9 @@ wifi_state->STA_rssi = ap_info.rssi; sprintf(wifi_state->STA_ssid, "%s", ap_info.ssid); xSemaphoreGive(xSemaphoreWiFi); - } + } else { + ESP_LOGE(TAG, "wifi_event_handler() lock error WIFI_EVENT_STA_CONNECTED"); + } xEventGroupSetBits(xEventGroupWifi, TASK_WIFI_STA_CONNECTED); xEventGroupClearBits(xEventGroupWifi, TASK_WIFI_STA_DISCONNECTED); break; @@ -152,7 +154,9 @@ wifi_state->STA_online = false; wifi_state->STA_rssi = 0; xSemaphoreGive(xSemaphoreWiFi); - } + } else { + ESP_LOGE(TAG, "wifi_event_handler() lock error WIFI_EVENT_STA_DISCONNECTED"); + } xEventGroupClearBits(xEventGroupWifi, TASK_WIFI_STA_CONNECTED); xEventGroupSetBits(xEventGroupWifi, TASK_WIFI_STA_DISCONNECTED); break; @@ -179,6 +183,8 @@ snprintf(wifi_state->STA_nm, 16, "%s", ip4addr_ntoa(&event->ip_info.netmask)); snprintf(wifi_state->STA_gw, 16, "%s", ip4addr_ntoa(&event->ip_info.gw)); xSemaphoreGive(xSemaphoreWiFi); + } else { + ESP_LOGE(TAG, "got_ip_event_handler() lock error IP_EVENT_STA_GOT_IP"); } break; @@ -191,6 +197,8 @@ wifi_state->STA_gw[0] = '\0'; wifi_state->STA_online = false; xSemaphoreGive(xSemaphoreWiFi); + } else { + ESP_LOGE(TAG, "got_ip_event_handler() lock error IP_EVENT_STA_LOST_IP"); } break;