From ffc958e5b541741ed5a687f822676bd8f0e36384 Mon Sep 17 00:00:00 2001 From: nopnop2002 Date: Fri, 9 Jul 2021 15:35:48 +0900 Subject: [PATCH] Abolished http2can.csv --- README.md | 14 ++------- csv/http2can.csv | 11 ------- main/http_server.c | 74 +++++++++------------------------------------- main/main.c | 10 ------- 4 files changed, 16 insertions(+), 93 deletions(-) delete mode 100644 csv/http2can.csv diff --git a/README.md b/README.md index d0bec30..b67b680 100644 --- a/README.md +++ b/README.md @@ -142,19 +142,9 @@ CAN-ID is a decimal number, not a hexadecimal number. ``` # Definition from HTTP to CANbus -When the Built-in HTTP server receives an HTTP POST, it is sent by CANBus according to csv/http2can.csv. -Other than this, it is the same as csv/can2http.csv. -In the last column you have to specify the HTTP-POST-Path of built-in HTTP server. +Not exist. +You can send any CAN-ID. -``` -S,201,/receive -E,201,/receive -S,203,/receive -E,203,/receive -``` - -If you POST {"canid": 513, "frame": "standard", "data": [16, 17, 18]}, send a standard CAN frame with ID 0x201. -If you POST {"canid": 513, "frame": "extended", "data": [16, 17, 18]}, send a extended CAN frame with ID 0x201. # Send CANBus frame using curl ``` diff --git a/csv/http2can.csv b/csv/http2can.csv deleted file mode 100644 index 3d2970b..0000000 --- a/csv/http2can.csv +++ /dev/null @@ -1,11 +0,0 @@ -#The file mqtt2can.csv has three columns. -#In the first column you need to specify the CAN Frame type. -#The CAN frame type is either S(Standard frame) or E(Extended frame). -#In the second column you have to specify the CAN-ID as a __hexdecimal number__. -#In the last column you have to specify the PATH of built-in web server. -#Each CAN-ID is allowed to appear only once in the whole file. - -S,201,/receive -E,201,/receive -S,203,/receive -E,203,/receive diff --git a/main/http_server.c b/main/http_server.c index 48c812c..5a156ba 100644 --- a/main/http_server.c +++ b/main/http_server.c @@ -28,8 +28,6 @@ static const char *TAG = "SERVER"; //static SemaphoreHandle_t ctrl_task_sem; extern QueueHandle_t xQueue_twai_tx; -extern TOPIC_t *subscribe; -extern int16_t nsubscribe; #define SCRATCH_BUFSIZE (1024) @@ -43,41 +41,11 @@ typedef struct rest_server_context { static esp_err_t root_get_handler(httpd_req_t *req) { ESP_LOGI(TAG, "root_get_handler req->uri=[%s]", req->uri); - for(int index=0;index"); - - httpd_resp_sendstr_chunk(req, ""); - httpd_resp_sendstr_chunk(req, ""); - - char chunk[64]; - for(int index=0;index"); - sprintf(chunk, "", frameType); - httpd_resp_sendstr_chunk(req, chunk); - sprintf(chunk, "", subscribe[index].canid); - httpd_resp_sendstr_chunk(req, chunk); - sprintf(chunk, "", subscribe[index].topic); - httpd_resp_sendstr_chunk(req, chunk); - httpd_resp_sendstr_chunk(req, ""); - } - - /* Finish the table */ - httpd_resp_sendstr_chunk(req, "
Frame TypeFrame IDHTTP Path
%16s%x%s
"); - - /* Send remaining chunk of HTML file to complete it */ - httpd_resp_sendstr_chunk(req, ""); /* Send empty chunk to signal HTTP response completion */ httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; } @@ -238,34 +206,20 @@ static esp_err_t twai_send_handler(httpd_req_t *req) if (parse) { ESP_LOGI(TAG, "twai_send_handler frame=%d canid=%x data_len=%d", frame, canid, data_len); ESP_LOG_BUFFER_HEX(TAG, data_value, data_len); - bool isMatch = false; - for(int index=0;index