From 54ea3f398b91e76e85477ebf02eaa3740892dda5 Mon Sep 17 00:00:00 2001 From: nopnop2002 Date: Wed, 16 Nov 2022 19:40:29 +0900 Subject: [PATCH] Changed log format for int32_t/uint32_t --- main/Kconfig.projbuild | 10 +++++----- main/http_post.c | 6 ++++-- main/http_server.c | 5 +++-- main/main.c | 3 ++- main/twai.c | 15 ++++++++------- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index e1670b2..f524135 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -4,8 +4,8 @@ menu "Application Configuration" int default 33 if IDF_TARGET_ESP32 default 46 if IDF_TARGET_ESP32S2 - default 19 if IDF_TARGET_ESP32C3 default 48 if IDF_TARGET_ESP32S3 + default 19 if IDF_TARGET_ESP32C3 menu "CAN Setting" @@ -51,9 +51,9 @@ menu "Application Configuration" config CTX_GPIO int "CTX GPIO number" range 0 GPIO_RANGE_MAX - default 9 if IDF_TARGET_ESP32C3 - default 17 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 default 21 if IDF_TARGET_ESP32 + default 17 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 + default 0 if IDF_TARGET_ESP32C3 help GPIO number (IOxx) to CTX. Some GPIOs are used for other purposes (flash connections, etc.). @@ -62,9 +62,9 @@ menu "Application Configuration" config CRX_GPIO int "CRX GPIO number" range 0 GPIO_RANGE_MAX - default 10 if IDF_TARGET_ESP32C3 - default 18 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 default 22 if IDF_TARGET_ESP32 + default 18 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 + default 1 if IDF_TARGET_ESP32C3 help GPIO number (IOxx) to CRX. Some GPIOs are used for other purposes (flash connections, etc.). diff --git a/main/http_post.c b/main/http_post.c index 1b358a1..fb20376 100644 --- a/main/http_post.c +++ b/main/http_post.c @@ -7,6 +7,8 @@ CONDITIONS OF ANY KIND, either express or implied. */ +#include +#include #include #include #include "freertos/FreeRTOS.h" @@ -139,7 +141,7 @@ static void http_rest_with_url(char * path, char * post_data) esp_http_client_set_post_field(client, post_data, strlen(post_data)); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { - ESP_LOGI(TAG, "HTTP POST Status = %d, content_length = %d", + ESP_LOGI(TAG, "HTTP POST Status = %d, content_length = %lld", esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); ESP_LOGI(TAG, "local_response_buffer=[%s]", local_response_buffer); @@ -157,7 +159,7 @@ void http_client_task(void *pvParameters) FRAME_t frameBuf; while (1) { xQueueReceive(xQueue_http_client, &frameBuf, portMAX_DELAY); - ESP_LOGI(TAG, "canid=%x ext=%d topic=[%s]", frameBuf.canid, frameBuf.ext, frameBuf.topic); + ESP_LOGI(TAG, "canid=%"PRIx32" ext=%d topic=[%s]", frameBuf.canid, frameBuf.ext, frameBuf.topic); for(int i=0;i +#include #include #include "freertos/FreeRTOS.h" @@ -138,7 +139,7 @@ static esp_err_t twai_send_handler(httpd_req_t *req) cJSON* state = cJSON_GetObjectItem(root, "canid"); if (state) { canid = cJSON_GetObjectItem(root, "canid")->valueint; - ESP_LOGI(TAG, "canid=%x", canid); + ESP_LOGI(TAG, "canid=%"PRIx32, canid); } else { ESP_LOGE(TAG, "canid item not found"); parse = false; @@ -209,7 +210,7 @@ static esp_err_t twai_send_handler(httpd_req_t *req) // JSON parse success. Send twai data. if (parse) { - ESP_LOGI(TAG, "twai_send_handler frame=%d canid=%x data_len=%d", frame, canid, data_len); + ESP_LOGI(TAG, "twai_send_handler frame=%d canid=%"PRIx32" data_len=%d", frame, canid, data_len); ESP_LOG_BUFFER_HEX(TAG, data_value, data_len); twai_message_t tx_msg; tx_msg.extd = frame; diff --git a/main/main.c b/main/main.c index 6d49843..f508a18 100644 --- a/main/main.c +++ b/main/main.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include "freertos/FreeRTOS.h" @@ -348,7 +349,7 @@ esp_err_t build_table(TOPIC_t **topics, char *file, int16_t *ntopic) void dump_table(TOPIC_t *topics, int16_t ntopic) { for(int i=0;iframe, (topics+i)->canid, (topics+i)->topic, (topics+i)->topic_len); } diff --git a/main/twai.c b/main/twai.c index 7fe4272..894ee3b 100644 --- a/main/twai.c +++ b/main/twai.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include "freertos/FreeRTOS.h" @@ -41,7 +42,7 @@ void twai_task(void *pvParameters) while (1) { esp_err_t ret = twai_receive(&rx_msg, pdMS_TO_TICKS(10)); if (ret == ESP_OK) { - ESP_LOGD(TAG,"twai_receive identifier=0x%x flags=0x%x data_length_code=%d", + ESP_LOGD(TAG,"twai_receive identifier=0x%"PRIx32" flags=0x%"PRIx32" data_length_code=%d", rx_msg.identifier, rx_msg.flags, rx_msg.data_length_code); int ext = rx_msg.flags & 0x01; @@ -50,9 +51,9 @@ void twai_task(void *pvParameters) #if CONFIG_ENABLE_PRINT if (ext == STANDARD_FRAME) { - printf("Standard ID: 0x%03x ", rx_msg.identifier); + printf("Standard ID: 0x%03"PRIx32" ", rx_msg.identifier); } else { - printf("Extended ID: 0x%08x", rx_msg.identifier); + printf("Extended ID: 0x%08"PRIx32, rx_msg.identifier); } printf(" DLC: %d Data: ", rx_msg.data_length_code); @@ -70,7 +71,7 @@ void twai_task(void *pvParameters) for(int index=0;index