From 7ee8919d3912ea2e5376f3d4c2888e9f6134c70f Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Tue, 7 Oct 2025 20:08:11 +0900 Subject: [PATCH 01/12] tested UDP and TCP -> It is better TCP on my environment tested UDP and TCP -> It is better TCP on my environment - case of UDP Ok, Host -> Client communication Broken, Client -> Host communication - case of TCP Ok, bi-direction, Host -> Client and Client <- Host --- .../ESP32-Serial-WiFi-Client.ino | 3 ++- ESP32-Serial-WiFi-Client/client_config.h | 12 +++++++----- config.h | 8 ++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino b/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino index c8c58bd..ceee4f6 100644 --- a/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino +++ b/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino @@ -152,7 +152,8 @@ void loop() { #ifdef PROTOCOL_TCP if (num > 0) client.write(buf, num); #elif defined(PROTOCOL_UDP) - udp.broadcastTo(buf, num, HOST_PORT + 1); + //udp.broadcastTo(buf, num, HOST_PORT + 1); + udp.broadcastTo(buf, num, HOST_PORT); #endif num = 0; } diff --git a/ESP32-Serial-WiFi-Client/client_config.h b/ESP32-Serial-WiFi-Client/client_config.h index 7c6220c..c61bc27 100644 --- a/ESP32-Serial-WiFi-Client/client_config.h +++ b/ESP32-Serial-WiFi-Client/client_config.h @@ -13,20 +13,22 @@ #define OTA_HANDLER // uncomment to enable OTA programming -#define SSID "ssid" // SSID to join -#define PASSWD "password" // wiFi password +#define SSID "ssid_esp_uart_bridge" // SSID to join +#define PASSWD "password_esp_uart_bridgeAAAA" // wiFi password #define BUFFERSIZE 1024 #define VERSION "2.0-ESP32" -#define PROTOCOL_UDP // PROTOCOL_TCP or PROTOCOL_UDP +#define PROTOCOL_TCP // PROTOCOL_TCP or PROTOCOL_UDP +//#define PROTOCOL_UDP // PROTOCOL_TCP or PROTOCOL_UDP #define HOST_IP IPAddress(192, 168, 4, 1) // only used for PROTOCOL_TCP -#define HOST_PORT 14550 // TCP or UDP port +//#define HOST_PORT 14550 // UDP port +#define HOST_PORT 8880 // TCP port #define CLIENT_BAUD 115200 #define CLIENT_PARAM SERIAL_8N1 #define CLIENT_TXPIN 1 -#define CLIENT_RXPIN 3 +#define CLIENT_RXPIN 21 /************************** DO NOT EDIT BELOW HERE **************************/ // perhaps a clever way to include/exclude serial debug messages... diff --git a/config.h b/config.h index 968644e..f981b41 100644 --- a/config.h +++ b/config.h @@ -19,8 +19,8 @@ #define OTA_HANDLER // uncomment to enable OTA programming -#define SSID "ssid" // SSID to join (or broadcast) -#define PASSWD "password" // wiFi password +#define SSID "ssid_esp_uart_bridge" // SSID to join (or broadcast) +#define PASSWD "password_esp_uart_bridgeAAAA" // wiFi password #define HOSTNAME "esp32" // hostname for STA mode mDNS #define BUFFERSIZE 1024 @@ -31,10 +31,10 @@ #define VERSION "2.0-ESP8266" #endif -#define MODE_STA // MODE_STA or MODE_AP +#define MODE_AP // MODE_STA or MODE_AP #define PROTOCOL_TCP // uncomment to enable TCP server #define MAX_NMEA_CLIENTS 4 // max TCP clients -#define PROTOCOL_UDP // uncomment to enable UDP broadcast (ESP32 only) +//#define PROTOCOL_UDP // uncomment to enable UDP broadcast (ESP32 only) //#define BLUETOOTH 0 // uncomment to create a bluetooth serial bridge on the indicated serial port (ESP32 only) //#define BATTERY_SAVER // uncomment to reduce wifi power From fc1a8559848eadcc8b532518057acddaa88958a8 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Tue, 7 Oct 2025 20:08:26 +0900 Subject: [PATCH 02/12] add speed test python code add speed test python code --- speed_test_script/test1_receive_random.py | 18 ++++++++++++++++++ speed_test_script/test1_send_random.py | 9 +++++++++ 2 files changed, 27 insertions(+) create mode 100644 speed_test_script/test1_receive_random.py create mode 100644 speed_test_script/test1_send_random.py diff --git a/speed_test_script/test1_receive_random.py b/speed_test_script/test1_receive_random.py new file mode 100644 index 0000000..20a5b04 --- /dev/null +++ b/speed_test_script/test1_receive_random.py @@ -0,0 +1,18 @@ +import serial, time + +ser = serial.Serial("COM18", 115200) +# ser = serial.Serial("COM17", 115200) + +count = 0 +start = time.time() + +while True: + data = ser.read(1024) + count += len(data) + elapsed = time.time() - start + if elapsed >= 1.0: + #print(f"{count/elapsed/1024:.2f} KB/s") + print(f"{count*8/elapsed:.2f} bps") + count = 0 + start = time.time() + diff --git a/speed_test_script/test1_send_random.py b/speed_test_script/test1_send_random.py new file mode 100644 index 0000000..34db538 --- /dev/null +++ b/speed_test_script/test1_send_random.py @@ -0,0 +1,9 @@ +import serial, os + +# COMポートを指定(例: COM3) +ser = serial.Serial("COM17", 115200) +# ser = serial.Serial("COM18", 115200) + +while True: + ser.write(os.urandom(1024)) + From e51453a530b94978db1db3b551a253b3b182bd16 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Tue, 7 Oct 2025 20:16:13 +0900 Subject: [PATCH 03/12] add result of speed test, Client -> Host, communication speed has limit? add result of speed test, Client -> Host, communication speed has limit? Client -> Host, communication speed has limitation? 80000 bps? 0. same condition 1. TCP only without UDP waiting -> same speed 2. buffer size 1024 -> 2048, 80000 -> 77000 bps downed --- .../251007_speed_test_result-0.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 speed_test_script/251007_speed_test_result-0.md diff --git a/speed_test_script/251007_speed_test_result-0.md b/speed_test_script/251007_speed_test_result-0.md new file mode 100644 index 0000000..5b3a748 --- /dev/null +++ b/speed_test_script/251007_speed_test_result-0.md @@ -0,0 +1,39 @@ +# 251007_speed_test_result-0.md +- Host -> Client: around 115200 bps, OK +``` +PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py +9437.34 bps +10642.07 bps +6163.63 bps +14873.13 bps +11102.08 bps +11005.70 bps +5552.57 bps +10833.07 bps +11031.34 bps +5211.61 bps +5783.82 bps +16435.98 bps +10812.21 bps +9828.91 bps +12238.48 bps +5398.71 bps +11187.61 bps +``` +- Client -> Host: around 80000 bps, it is strange +``` +PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py +76537.87 bps +80721.85 bps +80845.42 bps +80787.46 bps +81025.16 bps +80693.60 bps +80843.86 bps +80668.67 bps +80694.41 bps +80951.30 bps +80942.55 bps +80923.27 bps +80717.47 bps +``` From 19dbf8349a421d774aa1f5cca4a2bfe5f5ac1df7 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Tue, 7 Oct 2025 21:18:52 +0900 Subject: [PATCH 04/12] checking fastest speed...... checking fastest speed...... --- ESP-Serial-Bridge.ino | 17 ++++--- config.h | 5 ++- .../251007_speed_test_result-0.md | 45 ++++++++++++++++++- speed_test_script/test1_receive_random.py | 14 ++++-- speed_test_script/test1_send_random.py | 4 +- 5 files changed, 68 insertions(+), 17 deletions(-) diff --git a/ESP-Serial-Bridge.ino b/ESP-Serial-Bridge.ino index 20f8814..0291310 100644 --- a/ESP-Serial-Bridge.ino +++ b/ESP-Serial-Bridge.ino @@ -56,7 +56,8 @@ BluetoothSerial SerialBT; HardwareSerial Serial_one(1); HardwareSerial Serial_two(2); -HardwareSerial* COM[NUM_COM] = {&Serial, &Serial_one, &Serial_two}; +//HardwareSerial* COM[NUM_COM] = {&Serial, &Serial_one, &Serial_two}; +HardwareSerial* COM[NUM_COM] = {&Serial}; #elif defined(ESP8266) SoftwareSerial Serial_zero(SERIAL0_RXPIN, SERIAL0_TXPIN); SoftwareSerial Serial_one(SERIAL1_RXPIN, SERIAL1_TXPIN); @@ -66,11 +67,12 @@ SoftwareSerial* COM[NUM_COM] = {&Serial_zero, &Serial_one}; #ifdef PROTOCOL_TCP #include WiFiServer server_0(SERIAL0_TCP_PORT); -WiFiServer server_1(SERIAL1_TCP_PORT); +//WiFiServer server_1(SERIAL1_TCP_PORT); #ifdef ESP32 -WiFiServer server_2(SERIAL2_TCP_PORT); -WiFiServer* server[NUM_COM] = {&server_0, &server_1, &server_2}; +//WiFiServer server_2(SERIAL2_TCP_PORT); +//WiFiServer* server[NUM_COM] = {&server_0, &server_1, &server_2}; +WiFiServer* server[NUM_COM] = {&server_0}; #elif defined(ESP8266) WiFiServer* server[NUM_COM] = {&server_0, &server_1}; #endif @@ -81,7 +83,8 @@ uint8_t buf1[NUM_COM][BUFFERSIZE]; uint8_t buf2[NUM_COM][BUFFERSIZE]; #ifdef ESP32 -uint16_t i1[NUM_COM] = {0, 0, 0}; +//uint16_t i1[NUM_COM] = {0, 0, 0}; +uint16_t i1[NUM_COM] = {0}; #elif defined(ESP8266) uint16_t i1[NUM_COM] = {0, 0}; #endif @@ -119,8 +122,8 @@ void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) { #ifdef ESP32 COM[0]->begin(UART_BAUD0, SERIAL_PARAM0, SERIAL0_RXPIN, SERIAL0_TXPIN); - COM[1]->begin(UART_BAUD1, SERIAL_PARAM1, SERIAL1_RXPIN, SERIAL1_TXPIN); - COM[2]->begin(UART_BAUD2, SERIAL_PARAM2, SERIAL2_RXPIN, SERIAL2_TXPIN); + //COM[1]->begin(UART_BAUD1, SERIAL_PARAM1, SERIAL1_RXPIN, SERIAL1_TXPIN); + //COM[2]->begin(UART_BAUD2, SERIAL_PARAM2, SERIAL2_RXPIN, SERIAL2_TXPIN); #elif defined(ESP8266) COM[0]->begin(UART_BAUD0); COM[1]->begin(UART_BAUD1); diff --git a/config.h b/config.h index f981b41..8af09da 100644 --- a/config.h +++ b/config.h @@ -33,7 +33,7 @@ #define MODE_AP // MODE_STA or MODE_AP #define PROTOCOL_TCP // uncomment to enable TCP server -#define MAX_NMEA_CLIENTS 4 // max TCP clients +#define MAX_NMEA_CLIENTS 1 // max TCP clients //#define PROTOCOL_UDP // uncomment to enable UDP broadcast (ESP32 only) //#define BLUETOOTH 0 // uncomment to create a bluetooth serial bridge on the indicated serial port (ESP32 only) //#define BATTERY_SAVER // uncomment to reduce wifi power @@ -42,7 +42,8 @@ #define NETMASK IPAddress(255, 255, 255, 0) // netmask for MODE_AP #ifdef ESP32 -#define NUM_COM 3 // 3 available on ESP32 +//#define NUM_COM 3 // 3 available on ESP32 +#define NUM_COM 1 // 3 available on ESP32 #elif defined(ESP8266) #define NUM_COM 2 // we only use 2 on ESP8266 #endif diff --git a/speed_test_script/251007_speed_test_result-0.md b/speed_test_script/251007_speed_test_result-0.md index 5b3a748..eb8f658 100644 --- a/speed_test_script/251007_speed_test_result-0.md +++ b/speed_test_script/251007_speed_test_result-0.md @@ -1,5 +1,11 @@ # 251007_speed_test_result-0.md -- Host -> Client: around 115200 bps, OK + +## test1 +- Host -> Client: around 11000 bps, 1/10 +- Client -> Host: around 80000 bps + +### test1 detail +- Host -> Client: around 11000 bps, 1/10 ``` PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py 9437.34 bps @@ -20,7 +26,7 @@ PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\t 5398.71 bps 11187.61 bps ``` -- Client -> Host: around 80000 bps, it is strange +- Client -> Host: around 80000 bps ``` PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py 76537.87 bps @@ -37,3 +43,38 @@ PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\t 80923.27 bps 80717.47 bps ``` + +## test2 +- Host -> Client, around 11000 bps, 1/10 +- Client -> Host, around 115200 bps, Ok + +### test2, detail +- Host -> Client, around 11000 bps, 1/10 +``` +PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py +8613.45 bps +7017.59 bps +13569.80 bps +6700.04 bps +13826.51 bps +14297.73 bps +13348.43 bps +13311.04 bps +13815.43 bps +6572.14 bps +``` +- Client -> Host, around 115200 bps, Ok +``` +PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py +2490.32 bps +103051.81 bps +101330.02 bps +101190.01 bps +101395.86 bps +101285.53 bps +101177.61 bps +101078.65 bps +101285.08 bps +100570.91 bps +100694.02 bps +``` diff --git a/speed_test_script/test1_receive_random.py b/speed_test_script/test1_receive_random.py index 20a5b04..d721f11 100644 --- a/speed_test_script/test1_receive_random.py +++ b/speed_test_script/test1_receive_random.py @@ -1,7 +1,7 @@ import serial, time -ser = serial.Serial("COM18", 115200) -# ser = serial.Serial("COM17", 115200) +# ser = serial.Serial("COM18", 115200) +ser = serial.Serial("COM17", 115200) count = 0 start = time.time() @@ -11,8 +11,14 @@ count += len(data) elapsed = time.time() - start if elapsed >= 1.0: - #print(f"{count/elapsed/1024:.2f} KB/s") - print(f"{count*8/elapsed:.2f} bps") + # kbps = (count / elapsed) / 1024.0 # KB/s + byte_per_sec = (count / elapsed) + kbps = byte_per_sec/ 1024.0 # KB/s + data_bps = byte_per_sec * 8 # データ部のみ(8bit換算) + total_bps = byte_per_sec * 10 # UART全体(8N1の場合) + # print(f"{kbps:.2f} KB/s") + # print(f"{data_bps:.2f} bps") + print(f"{total_bps:.2f} bps") count = 0 start = time.time() diff --git a/speed_test_script/test1_send_random.py b/speed_test_script/test1_send_random.py index 34db538..4434774 100644 --- a/speed_test_script/test1_send_random.py +++ b/speed_test_script/test1_send_random.py @@ -1,8 +1,8 @@ import serial, os # COMポートを指定(例: COM3) -ser = serial.Serial("COM17", 115200) -# ser = serial.Serial("COM18", 115200) +# ser = serial.Serial("COM17", 115200) +ser = serial.Serial("COM18", 115200) while True: ser.write(os.urandom(1024)) From 2ce3d521f093ba461dc632a6b5882299b41e8dcd Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Tue, 7 Oct 2025 21:30:57 +0900 Subject: [PATCH 05/12] =?UTF-8?q?config.h=E3=82=92=E5=A4=89=E3=81=88?= =?UTF-8?q?=E3=81=A6=E3=81=BF=E3=81=9F=E3=82=8A=E3=81=97=E3=81=9F=E3=81=8C?= =?UTF-8?q?=E5=A4=89=E3=82=8F=E3=82=89=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.hを変えてみたりしたが変わらない - Host -> Client, around 13000 bps, 1/10 - Client -> Host, around 115200 bps --- ESP-Serial-Bridge.ino | 20 +++++------ config.h | 4 +-- .../251007_speed_test_result-0.md | 34 +++++++++++++++++++ speed_test_script/test1_receive_random.py | 4 +-- speed_test_script/test1_send_random.py | 4 +-- 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/ESP-Serial-Bridge.ino b/ESP-Serial-Bridge.ino index 0291310..b80672c 100644 --- a/ESP-Serial-Bridge.ino +++ b/ESP-Serial-Bridge.ino @@ -56,8 +56,8 @@ BluetoothSerial SerialBT; HardwareSerial Serial_one(1); HardwareSerial Serial_two(2); -//HardwareSerial* COM[NUM_COM] = {&Serial, &Serial_one, &Serial_two}; -HardwareSerial* COM[NUM_COM] = {&Serial}; +HardwareSerial* COM[NUM_COM] = {&Serial, &Serial_one, &Serial_two}; +//HardwareSerial* COM[NUM_COM] = {&Serial}; #elif defined(ESP8266) SoftwareSerial Serial_zero(SERIAL0_RXPIN, SERIAL0_TXPIN); SoftwareSerial Serial_one(SERIAL1_RXPIN, SERIAL1_TXPIN); @@ -67,12 +67,12 @@ SoftwareSerial* COM[NUM_COM] = {&Serial_zero, &Serial_one}; #ifdef PROTOCOL_TCP #include WiFiServer server_0(SERIAL0_TCP_PORT); -//WiFiServer server_1(SERIAL1_TCP_PORT); +WiFiServer server_1(SERIAL1_TCP_PORT); #ifdef ESP32 -//WiFiServer server_2(SERIAL2_TCP_PORT); -//WiFiServer* server[NUM_COM] = {&server_0, &server_1, &server_2}; -WiFiServer* server[NUM_COM] = {&server_0}; +WiFiServer server_2(SERIAL2_TCP_PORT); +WiFiServer* server[NUM_COM] = {&server_0, &server_1, &server_2}; +//WiFiServer* server[NUM_COM] = {&server_0}; #elif defined(ESP8266) WiFiServer* server[NUM_COM] = {&server_0, &server_1}; #endif @@ -83,8 +83,8 @@ uint8_t buf1[NUM_COM][BUFFERSIZE]; uint8_t buf2[NUM_COM][BUFFERSIZE]; #ifdef ESP32 -//uint16_t i1[NUM_COM] = {0, 0, 0}; -uint16_t i1[NUM_COM] = {0}; +uint16_t i1[NUM_COM] = {0, 0, 0}; +//uint16_t i1[NUM_COM] = {0}; #elif defined(ESP8266) uint16_t i1[NUM_COM] = {0, 0}; #endif @@ -122,8 +122,8 @@ void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) { #ifdef ESP32 COM[0]->begin(UART_BAUD0, SERIAL_PARAM0, SERIAL0_RXPIN, SERIAL0_TXPIN); - //COM[1]->begin(UART_BAUD1, SERIAL_PARAM1, SERIAL1_RXPIN, SERIAL1_TXPIN); - //COM[2]->begin(UART_BAUD2, SERIAL_PARAM2, SERIAL2_RXPIN, SERIAL2_TXPIN); + COM[1]->begin(UART_BAUD1, SERIAL_PARAM1, SERIAL1_RXPIN, SERIAL1_TXPIN); + COM[2]->begin(UART_BAUD2, SERIAL_PARAM2, SERIAL2_RXPIN, SERIAL2_TXPIN); #elif defined(ESP8266) COM[0]->begin(UART_BAUD0); COM[1]->begin(UART_BAUD1); diff --git a/config.h b/config.h index 8af09da..0be1919 100644 --- a/config.h +++ b/config.h @@ -42,8 +42,8 @@ #define NETMASK IPAddress(255, 255, 255, 0) // netmask for MODE_AP #ifdef ESP32 -//#define NUM_COM 3 // 3 available on ESP32 -#define NUM_COM 1 // 3 available on ESP32 +#define NUM_COM 3 // 3 available on ESP32 +//#define NUM_COM 1 // 3 available on ESP32 #elif defined(ESP8266) #define NUM_COM 2 // we only use 2 on ESP8266 #endif diff --git a/speed_test_script/251007_speed_test_result-0.md b/speed_test_script/251007_speed_test_result-0.md index eb8f658..e673607 100644 --- a/speed_test_script/251007_speed_test_result-0.md +++ b/speed_test_script/251007_speed_test_result-0.md @@ -78,3 +78,37 @@ PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\t 100570.91 bps 100694.02 bps ``` + +## test3 +- Host -> Client, around 115200 bps +- Client -> Host, around 13000 bps, 1/10 + +### test3, detail +- Host -> Client, around 115200 bps +``` +PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py +825.76 bps +101699.98 bps +101086.60 bps +100784.28 bps +101176.80 bps +101184.19 bps +101181.45 bps +100977.22 bps +101200.93 bps +101220.15 bps +``` +- Client -> Host, around 13000 bps, 1/10 +``` +PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py +8643.42 bps +13705.61 bps +7663.88 bps +13088.96 bps +12960.40 bps +13315.06 bps +14086.15 bps +13497.89 bps +14034.07 bps +13409.55 bps +``` diff --git a/speed_test_script/test1_receive_random.py b/speed_test_script/test1_receive_random.py index d721f11..d7552bd 100644 --- a/speed_test_script/test1_receive_random.py +++ b/speed_test_script/test1_receive_random.py @@ -1,7 +1,7 @@ import serial, time -# ser = serial.Serial("COM18", 115200) -ser = serial.Serial("COM17", 115200) +ser = serial.Serial("COM18", 115200) +# ser = serial.Serial("COM17", 115200) count = 0 start = time.time() diff --git a/speed_test_script/test1_send_random.py b/speed_test_script/test1_send_random.py index 4434774..34db538 100644 --- a/speed_test_script/test1_send_random.py +++ b/speed_test_script/test1_send_random.py @@ -1,8 +1,8 @@ import serial, os # COMポートを指定(例: COM3) -# ser = serial.Serial("COM17", 115200) -ser = serial.Serial("COM18", 115200) +ser = serial.Serial("COM17", 115200) +# ser = serial.Serial("COM18", 115200) while True: ser.write(os.urandom(1024)) From 12bf00b00c7ec16923dd7f90667783aa1d19194f Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Tue, 7 Oct 2025 21:33:11 +0900 Subject: [PATCH 06/12] =?UTF-8?q?config.h=E3=82=92=E5=A4=89=E3=81=88?= =?UTF-8?q?=E3=81=A6=E3=81=BF=E3=81=9F=E3=82=8A=E3=81=97=E3=81=9F=E3=81=8C?= =?UTF-8?q?=E5=A4=89=E3=82=8F=E3=82=89=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.hを変えてみたりしたが変わらない - Host -> Client, around 13000 bps, 1/10 - Client -> Host, around 115200 bps --- .../251007_speed_test_result-0.md | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/speed_test_script/251007_speed_test_result-0.md b/speed_test_script/251007_speed_test_result-0.md index e673607..08cf9c9 100644 --- a/speed_test_script/251007_speed_test_result-0.md +++ b/speed_test_script/251007_speed_test_result-0.md @@ -80,25 +80,11 @@ PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\t ``` ## test3 -- Host -> Client, around 115200 bps -- Client -> Host, around 13000 bps, 1/10 +- Host -> Client, around 13000 bps, 1/10 +- Client -> Host, around 115200 bps ### test3, detail -- Host -> Client, around 115200 bps -``` -PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py -825.76 bps -101699.98 bps -101086.60 bps -100784.28 bps -101176.80 bps -101184.19 bps -101181.45 bps -100977.22 bps -101200.93 bps -101220.15 bps -``` -- Client -> Host, around 13000 bps, 1/10 +- Host -> Client, around 13000 bps, 1/10 ``` PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py 8643.42 bps @@ -112,3 +98,19 @@ PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\t 14034.07 bps 13409.55 bps ``` + +- Client -> Host, around 115200 bps +``` +PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py +825.76 bps +101699.98 bps +101086.60 bps +100784.28 bps +101176.80 bps +101184.19 bps +101181.45 bps +100977.22 bps +101200.93 bps +101220.15 bps +``` + From 18c63b2bb91739cab935dc2135923eac188114b0 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Wed, 8 Oct 2025 15:49:49 +0900 Subject: [PATCH 07/12] test adding watch dog timer, wdt test adding watch dog timer, wdt --- .../251008_error_message_for_adding_wdt.md | 52 +++++++++++++++++++ .../ESP32-Serial-WiFi-Client.ino | 17 ++++++ 2 files changed, 69 insertions(+) create mode 100644 ESP32-Serial-WiFi-Client/251008_error_message_for_adding_wdt.md diff --git a/ESP32-Serial-WiFi-Client/251008_error_message_for_adding_wdt.md b/ESP32-Serial-WiFi-Client/251008_error_message_for_adding_wdt.md new file mode 100644 index 0000000..82c70bc --- /dev/null +++ b/ESP32-Serial-WiFi-Client/251008_error_message_for_adding_wdt.md @@ -0,0 +1,52 @@ +# 251008_error_message_for_adding_wdt.md + +## cycle 1 +``` +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino: In function 'void setup()': +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:80:23: error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)' + 80 | timer = timerBegin(0, 80, true); //timer 0, div 80 + | ~~~~~~~~~~^~~~~~~~~~~~~ +In file included from C:\Users\YoshihiroNakagawa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/esp32-hal.h:98, + from C:\Users\YoshihiroNakagawa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/Arduino.h:44, + from C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:12: +C:\Users\YoshihiroNakagawa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/esp32-hal-timer.h:35:13: note: declared here + 35 | hw_timer_t *timerBegin(uint32_t frequency); + | ^~~~~~~~~~ +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:81:25: error: too many arguments to function 'void timerAttachInterrupt(hw_timer_t*, void (*)())' + 81 | timerAttachInterrupt(timer, &resetModule, true); //attach callback + | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ +C:\Users\YoshihiroNakagawa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/esp32-hal-timer.h:50:6: note: declared here + 50 | void timerAttachInterrupt(hw_timer_t *timer, void (*userFunc)(void)); + | ^~~~~~~~~~~~~~~~~~~~ +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:82:5: error: 'timerAlarmWrite' was not declared in this scope; did you mean 'timerWrite'? + 82 | timerAlarmWrite(timer, TIMEOUT * 1000, false); //set time in us + | ^~~~~~~~~~~~~~~ + | timerWrite +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:83:5: error: 'timerAlarmEnable' was not declared in this scope; did you mean 'timerAlarm'? + 83 | timerAlarmEnable(timer); //enable interrupt + | ^~~~~~~~~~~~~~~~ + | timerAlarm +exit status 1 + +Compilation error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)' +``` + +## cycle 2 +``` +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:34:1: error: expected ',' or ';' before 'hw_timer_t' + 34 | hw_timer_t *timer = NULL; + | ^~~~~~~~~~ +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino: In function 'void setup()': +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:80:5: error: 'timer' was not declared in this scope; did you mean 'time'? + 80 | timer = timerBegin(1000000); //timer 1MHz + | ^~~~~ + | time +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino: In function 'void loop()': +C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:150:16: error: 'timer' was not declared in this scope; did you mean 'time'? + 150 | timerWrite(timer, 0); //reset timer (feed watchdog) + | ^~~~~ + | time +exit status 1 + +Compilation error: expected ',' or ';' before 'hw_timer_t' +``` \ No newline at end of file diff --git a/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino b/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino index ceee4f6..ce3d5e4 100644 --- a/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino +++ b/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino @@ -13,6 +13,7 @@ #include #include #include +#include "esp_system.h" #include "client_config.h" @@ -29,6 +30,14 @@ uint8_t buf[BUFFERSIZE]; uint16_t num = 0; +const int wdtTimeout = 30000; // reboot after 30 seconds of no clients +hw_timer_t *timer = NULL; + +void ARDUINO_ISR_ATTR resetModule() { + debug.println("Rebooting..."); + esp_restart(); +} + #ifdef PROTOCOL_TCP WiFiClient client; void connect_to_host() { @@ -68,6 +77,11 @@ void setup() { debug.print("\n\nWiFi serial bridge client "); debug.println(VERSION); + timer = timerBegin(1000000); //timer 1MHz + timerAttachInterrupt(timer, &resetModule); //attach callback + timerAlarm(timer, wdtTimeout * 1000, false, 0); //set time in us + debug.println("Watch dog timer Setup done"); + debug.println("Open ESP Station Mode"); WiFi.mode(WIFI_STA); WiFi.onEvent(WiFiStationDisconnected, ARDUINO_EVENT_WIFI_STA_DISCONNECTED); @@ -79,6 +93,7 @@ void setup() { delay(500); debug.print("."); } + timerWrite(timer, 0); //reset timer (feed watchdog) debug.println("connected"); debug.print("IP address: "); debug.println(WiFi.localIP()); @@ -131,6 +146,8 @@ void loop() { #ifdef OTA_HANDLER ArduinoOTA.handle(); #endif + + timerWrite(timer, 0); //reset timer (feed watchdog) #ifdef PROTOCOL_TCP if (!client.connected()) connect_to_host(); From 6f866e229968b1be3c4e6cea1c3f325df7647af0 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Wed, 17 Dec 2025 19:07:40 +0900 Subject: [PATCH 08/12] =?UTF-8?q?Host=E5=81=B4=E3=81=8C=E8=90=BD=E3=81=A1?= =?UTF-8?q?=E3=81=9F=E6=99=82=E3=81=AB=E7=84=A1=E9=99=90=E3=83=AB=E3=83=BC?= =?UTF-8?q?=E3=83=97=E3=81=8B=E3=81=A4Watch=20dog=20timer=E3=81=8C?= =?UTF-8?q?=E5=8A=B9=E3=81=8B=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Host側が落ちた時に無限ループかつWatch dog timerが効かなかったエラーを修正 1. Client側が落ちた場合(ClientのReset)→Host側からの入力で回復 2. Host側が落ちてすぐ回復した場合(HostのReset)→OK 3. Host側が落ちて回復しない場合(HostのOFF)→30sごとにWatch dog TimerでClientをReset の3ケースに対応した --- .../ESP32-Serial-WiFi-Client.ino | 229 ++++++++++-------- 1 file changed, 127 insertions(+), 102 deletions(-) diff --git a/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino b/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino index ce3d5e4..5e2ffa4 100644 --- a/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino +++ b/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino @@ -30,7 +30,7 @@ uint8_t buf[BUFFERSIZE]; uint16_t num = 0; -const int wdtTimeout = 30000; // reboot after 30 seconds of no clients +const int wdtTimeout = 30000; // reboot after 30 seconds of no host hw_timer_t *timer = NULL; void ARDUINO_ISR_ATTR resetModule() { @@ -41,13 +41,21 @@ void ARDUINO_ISR_ATTR resetModule() { #ifdef PROTOCOL_TCP WiFiClient client; void connect_to_host() { - debug.printf("Connecting to %s:%d...", HOST_IP.toString(), HOST_PORT); - while (!client.connect(HOST_IP, HOST_PORT)) { - delay(500); - debug.print('.'); - } - debug.println("connected\n"); - delay(1000); + debug.printf("Connecting to %s:%d...", HOST_IP.toString(), HOST_PORT); + + //timer = timerBegin(1000000); //timer 1MHz + //timerAttachInterrupt(timer, &resetModule); //attach callback + //timerAlarm(timer, wdtTimeout * 1000, false, 0); //set time in us + //debug.println("Watch dog timer Setup done"); + + debug.println("while, connect_to_host"); + while (!client.connect(HOST_IP, HOST_PORT)) { + delay(500); + debug.print('.'); + } + //timerWrite(timer, 0); //reset timer (feed watchdog) + debug.println("connected, connect_to_host\n"); + delay(1000); } #endif @@ -56,121 +64,138 @@ AsyncUDP udp; #endif void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) { - debug.print("WiFi disconnected: "); - debug.println(info.wifi_sta_disconnected.reason); - debug.println("Trying to reconnect.."); - WiFi.begin(SSID, PASSWD); - while (WiFi.status() != WL_CONNECTED) { - delay(500); - debug.print("."); + debug.print("WiFi disconnected: "); + debug.println(info.wifi_sta_disconnected.reason); + debug.println("Trying to reconnect.."); + WiFi.begin(SSID, PASSWD); + + //timer = timerBegin(1000000); //timer 1MHz + //timerAttachInterrupt(timer, &resetModule); //attach callback + //timerAlarm(timer, wdtTimeout * 1000, false, 0); //set time in us + //debug.println("Watch dog timer Setup done"); + + debug.println("while, WiFiStationDisconnected"); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + debug.print("."); + if(client.connect(HOST_IP, HOST_PORT)) { + break; } - debug.println("connected"); - debug.print("IP address: "); - debug.println(WiFi.localIP()); + } + //timerWrite(timer, 0); //reset timer (feed watchdog) + debug.println("connected, WiFiStationDisconnected"); + debug.print("IP address: "); + debug.println(WiFi.localIP()); } void setup() { - delay(500); + delay(500); - Serial.begin(CLIENT_BAUD, CLIENT_PARAM, CLIENT_RXPIN, CLIENT_TXPIN); - - debug.print("\n\nWiFi serial bridge client "); - debug.println(VERSION); - - timer = timerBegin(1000000); //timer 1MHz - timerAttachInterrupt(timer, &resetModule); //attach callback - timerAlarm(timer, wdtTimeout * 1000, false, 0); //set time in us - debug.println("Watch dog timer Setup done"); - - debug.println("Open ESP Station Mode"); - WiFi.mode(WIFI_STA); - WiFi.onEvent(WiFiStationDisconnected, ARDUINO_EVENT_WIFI_STA_DISCONNECTED); - WiFi.begin(SSID, PASSWD); - debug.print("Connecting to: "); - debug.print(SSID); - debug.print(".."); - while (WiFi.status() != WL_CONNECTED) { - delay(500); - debug.print("."); - } - timerWrite(timer, 0); //reset timer (feed watchdog) - debug.println("connected"); - debug.print("IP address: "); - debug.println(WiFi.localIP()); + Serial.begin(CLIENT_BAUD, CLIENT_PARAM, CLIENT_RXPIN, CLIENT_TXPIN); -#ifdef OTA_HANDLER - ArduinoOTA.onStart([]() { - String type; - if (ArduinoOTA.getCommand() == U_FLASH) - type = "sketch"; - else // U_SPIFFS - type = "filesystem"; - - // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS - // using SPIFFS.end() - Serial.println("Start updating " + type); - }); - ArduinoOTA.onEnd([]() { Serial.println("\nEnd"); }); - ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { - Serial.printf("Progress: %u%%\r", (progress / (total / 100))); - }); - ArduinoOTA.onError([](ota_error_t error) { - Serial.printf("Error[%u]: ", error); - if (error == OTA_AUTH_ERROR) - Serial.println("Auth Failed"); - else if (error == OTA_BEGIN_ERROR) - Serial.println("Begin Failed"); - else if (error == OTA_CONNECT_ERROR) - Serial.println("Connect Failed"); - else if (error == OTA_RECEIVE_ERROR) - Serial.println("Receive Failed"); - else if (error == OTA_END_ERROR) - Serial.println("End Failed"); - }); + debug.print("\n\nWiFi serial bridge client "); + debug.println(VERSION); - ArduinoOTA.begin(); + debug.println("Open ESP Station Mode"); + WiFi.mode(WIFI_STA); + WiFi.onEvent(WiFiStationDisconnected, ARDUINO_EVENT_WIFI_STA_DISCONNECTED); + WiFi.begin(SSID, PASSWD); + debug.print("Connecting to: "); + debug.print(SSID); + debug.print(".."); + + timer = timerBegin(1000000); //timer 1MHz + timerAttachInterrupt(timer, &resetModule); //attach callback + timerAlarm(timer, wdtTimeout * 1000, false, 0); //set time in us + debug.println("Watch dog timer Setup done"); + + debug.println("while, setup"); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + debug.print("."); + } + timerWrite(timer, 0); //reset timer (feed watchdog) + debug.println("connected, setup"); + debug.print("IP address: "); + debug.println(WiFi.localIP()); + +#ifdef OTA_HANDLER + ArduinoOTA.onStart([]() { + String type; + if (ArduinoOTA.getCommand() == U_FLASH) + type = "sketch"; + else // U_SPIFFS + type = "filesystem"; + + // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS + // using SPIFFS.end() + Serial.println("Start updating " + type); + }); + ArduinoOTA.onEnd([]() { + Serial.println("\nEnd"); + }); + ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { + Serial.printf("Progress: %u%%\r", (progress / (total / 100))); + }); + ArduinoOTA.onError([](ota_error_t error) { + Serial.printf("Error[%u]: ", error); + if (error == OTA_AUTH_ERROR) + Serial.println("Auth Failed"); + else if (error == OTA_BEGIN_ERROR) + Serial.println("Begin Failed"); + else if (error == OTA_CONNECT_ERROR) + Serial.println("Connect Failed"); + else if (error == OTA_RECEIVE_ERROR) + Serial.println("Receive Failed"); + else if (error == OTA_END_ERROR) + Serial.println("End Failed"); + }); + + ArduinoOTA.begin(); #endif #ifdef PROTOCOL_UDP - if (udp.listen(HOST_PORT)) { - debug.printf("Listening on UDP port %d\n", HOST_PORT); - udp.onPacket([](AsyncUDPPacket packet) { - if (packet.localPort() == HOST_PORT) - Serial.write(packet.data(), packet.length()); - }); - } + if (udp.listen(HOST_PORT)) { + debug.printf("Listening on UDP port %d\n", HOST_PORT); + udp.onPacket([](AsyncUDPPacket packet) { + if (packet.localPort() == HOST_PORT) + Serial.write(packet.data(), packet.length()); + }); + } #endif } void loop() { #ifdef OTA_HANDLER - ArduinoOTA.handle(); + ArduinoOTA.handle(); #endif - - timerWrite(timer, 0); //reset timer (feed watchdog) -#ifdef PROTOCOL_TCP - if (!client.connected()) connect_to_host(); + timerWrite(timer, 0); //reset timer (feed watchdog) - while (client.available()) { - buf[num] = client.read(); - num++; - if (num == BUFFERSIZE - 1) break; - } - if (num > 0) Serial.write(buf, num); - num = 0; +#ifdef PROTOCOL_TCP + if (!client.connected()) { + connect_to_host(); + } + + while (client.available()) { + buf[num] = client.read(); + num++; + if (num == BUFFERSIZE - 1) break; + } + if (num > 0) Serial.write(buf, num); + num = 0; #endif - while (Serial.available()) { - buf[num] = Serial.read(); - num++; - if (num == BUFFERSIZE - 1) break; - } + while (Serial.available()) { + buf[num] = Serial.read(); + num++; + if (num == BUFFERSIZE - 1) break; + } #ifdef PROTOCOL_TCP - if (num > 0) client.write(buf, num); + if (num > 0) client.write(buf, num); #elif defined(PROTOCOL_UDP) - //udp.broadcastTo(buf, num, HOST_PORT + 1); - udp.broadcastTo(buf, num, HOST_PORT); + //udp.broadcastTo(buf, num, HOST_PORT + 1); + udp.broadcastTo(buf, num, HOST_PORT); #endif - num = 0; + num = 0; } From 6ecf0973cb5ca50ff8208fe1b04f0f26723bad24 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Wed, 17 Dec 2025 19:09:01 +0900 Subject: [PATCH 09/12] delete commented line delete commented line --- .../ESP32-Serial-WiFi-Client.ino | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino b/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino index 5e2ffa4..f3abe14 100644 --- a/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino +++ b/ESP32-Serial-WiFi-Client/ESP32-Serial-WiFi-Client.ino @@ -42,18 +42,11 @@ void ARDUINO_ISR_ATTR resetModule() { WiFiClient client; void connect_to_host() { debug.printf("Connecting to %s:%d...", HOST_IP.toString(), HOST_PORT); - - //timer = timerBegin(1000000); //timer 1MHz - //timerAttachInterrupt(timer, &resetModule); //attach callback - //timerAlarm(timer, wdtTimeout * 1000, false, 0); //set time in us - //debug.println("Watch dog timer Setup done"); - debug.println("while, connect_to_host"); while (!client.connect(HOST_IP, HOST_PORT)) { delay(500); debug.print('.'); } - //timerWrite(timer, 0); //reset timer (feed watchdog) debug.println("connected, connect_to_host\n"); delay(1000); } @@ -68,12 +61,6 @@ void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) { debug.println(info.wifi_sta_disconnected.reason); debug.println("Trying to reconnect.."); WiFi.begin(SSID, PASSWD); - - //timer = timerBegin(1000000); //timer 1MHz - //timerAttachInterrupt(timer, &resetModule); //attach callback - //timerAlarm(timer, wdtTimeout * 1000, false, 0); //set time in us - //debug.println("Watch dog timer Setup done"); - debug.println("while, WiFiStationDisconnected"); while (WiFi.status() != WL_CONNECTED) { delay(500); @@ -82,7 +69,6 @@ void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) { break; } } - //timerWrite(timer, 0); //reset timer (feed watchdog) debug.println("connected, WiFiStationDisconnected"); debug.print("IP address: "); debug.println(WiFi.localIP()); From ed6678f79bf8a6a4311bd5253a4d66870902517d Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Wed, 17 Dec 2025 19:15:13 +0900 Subject: [PATCH 10/12] delete development memo delete development memo --- .../251008_error_message_for_adding_wdt.md | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 ESP32-Serial-WiFi-Client/251008_error_message_for_adding_wdt.md diff --git a/ESP32-Serial-WiFi-Client/251008_error_message_for_adding_wdt.md b/ESP32-Serial-WiFi-Client/251008_error_message_for_adding_wdt.md deleted file mode 100644 index 82c70bc..0000000 --- a/ESP32-Serial-WiFi-Client/251008_error_message_for_adding_wdt.md +++ /dev/null @@ -1,52 +0,0 @@ -# 251008_error_message_for_adding_wdt.md - -## cycle 1 -``` -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino: In function 'void setup()': -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:80:23: error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)' - 80 | timer = timerBegin(0, 80, true); //timer 0, div 80 - | ~~~~~~~~~~^~~~~~~~~~~~~ -In file included from C:\Users\YoshihiroNakagawa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/esp32-hal.h:98, - from C:\Users\YoshihiroNakagawa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/Arduino.h:44, - from C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:12: -C:\Users\YoshihiroNakagawa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/esp32-hal-timer.h:35:13: note: declared here - 35 | hw_timer_t *timerBegin(uint32_t frequency); - | ^~~~~~~~~~ -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:81:25: error: too many arguments to function 'void timerAttachInterrupt(hw_timer_t*, void (*)())' - 81 | timerAttachInterrupt(timer, &resetModule, true); //attach callback - | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ -C:\Users\YoshihiroNakagawa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/esp32-hal-timer.h:50:6: note: declared here - 50 | void timerAttachInterrupt(hw_timer_t *timer, void (*userFunc)(void)); - | ^~~~~~~~~~~~~~~~~~~~ -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:82:5: error: 'timerAlarmWrite' was not declared in this scope; did you mean 'timerWrite'? - 82 | timerAlarmWrite(timer, TIMEOUT * 1000, false); //set time in us - | ^~~~~~~~~~~~~~~ - | timerWrite -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:83:5: error: 'timerAlarmEnable' was not declared in this scope; did you mean 'timerAlarm'? - 83 | timerAlarmEnable(timer); //enable interrupt - | ^~~~~~~~~~~~~~~~ - | timerAlarm -exit status 1 - -Compilation error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)' -``` - -## cycle 2 -``` -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:34:1: error: expected ',' or ';' before 'hw_timer_t' - 34 | hw_timer_t *timer = NULL; - | ^~~~~~~~~~ -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino: In function 'void setup()': -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:80:5: error: 'timer' was not declared in this scope; did you mean 'time'? - 80 | timer = timerBegin(1000000); //timer 1MHz - | ^~~~~ - | time -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino: In function 'void loop()': -C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\ESP32-Serial-WiFi-Client\ESP32-Serial-WiFi-Client.ino:150:16: error: 'timer' was not declared in this scope; did you mean 'time'? - 150 | timerWrite(timer, 0); //reset timer (feed watchdog) - | ^~~~~ - | time -exit status 1 - -Compilation error: expected ',' or ';' before 'hw_timer_t' -``` \ No newline at end of file From 2fb6ec9fcaf21b37044f058755603b3a1951bbb8 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Wed, 17 Dec 2025 19:32:00 +0900 Subject: [PATCH 11/12] undo for pull request undo for pull request --- ESP32-Serial-WiFi-Client/client_config.h | 4 +- config.h | 4 +- .../251007_speed_test_result-0.md | 116 ------------------ speed_test_script/test1_receive_random.py | 24 ---- speed_test_script/test1_send_random.py | 9 -- 5 files changed, 4 insertions(+), 153 deletions(-) delete mode 100644 speed_test_script/251007_speed_test_result-0.md delete mode 100644 speed_test_script/test1_receive_random.py delete mode 100644 speed_test_script/test1_send_random.py diff --git a/ESP32-Serial-WiFi-Client/client_config.h b/ESP32-Serial-WiFi-Client/client_config.h index c61bc27..a277dc8 100644 --- a/ESP32-Serial-WiFi-Client/client_config.h +++ b/ESP32-Serial-WiFi-Client/client_config.h @@ -13,8 +13,8 @@ #define OTA_HANDLER // uncomment to enable OTA programming -#define SSID "ssid_esp_uart_bridge" // SSID to join -#define PASSWD "password_esp_uart_bridgeAAAA" // wiFi password +#define SSID "ssid" // SSID to join +#define PASSWD "password" // wiFi password #define BUFFERSIZE 1024 diff --git a/config.h b/config.h index 0be1919..6a440e3 100644 --- a/config.h +++ b/config.h @@ -19,8 +19,8 @@ #define OTA_HANDLER // uncomment to enable OTA programming -#define SSID "ssid_esp_uart_bridge" // SSID to join (or broadcast) -#define PASSWD "password_esp_uart_bridgeAAAA" // wiFi password +#define SSID "ssid" // SSID to join (or broadcast) +#define PASSWD "password" // wiFi password #define HOSTNAME "esp32" // hostname for STA mode mDNS #define BUFFERSIZE 1024 diff --git a/speed_test_script/251007_speed_test_result-0.md b/speed_test_script/251007_speed_test_result-0.md deleted file mode 100644 index 08cf9c9..0000000 --- a/speed_test_script/251007_speed_test_result-0.md +++ /dev/null @@ -1,116 +0,0 @@ -# 251007_speed_test_result-0.md - -## test1 -- Host -> Client: around 11000 bps, 1/10 -- Client -> Host: around 80000 bps - -### test1 detail -- Host -> Client: around 11000 bps, 1/10 -``` -PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py -9437.34 bps -10642.07 bps -6163.63 bps -14873.13 bps -11102.08 bps -11005.70 bps -5552.57 bps -10833.07 bps -11031.34 bps -5211.61 bps -5783.82 bps -16435.98 bps -10812.21 bps -9828.91 bps -12238.48 bps -5398.71 bps -11187.61 bps -``` -- Client -> Host: around 80000 bps -``` -PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py -76537.87 bps -80721.85 bps -80845.42 bps -80787.46 bps -81025.16 bps -80693.60 bps -80843.86 bps -80668.67 bps -80694.41 bps -80951.30 bps -80942.55 bps -80923.27 bps -80717.47 bps -``` - -## test2 -- Host -> Client, around 11000 bps, 1/10 -- Client -> Host, around 115200 bps, Ok - -### test2, detail -- Host -> Client, around 11000 bps, 1/10 -``` -PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py -8613.45 bps -7017.59 bps -13569.80 bps -6700.04 bps -13826.51 bps -14297.73 bps -13348.43 bps -13311.04 bps -13815.43 bps -6572.14 bps -``` -- Client -> Host, around 115200 bps, Ok -``` -PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py -2490.32 bps -103051.81 bps -101330.02 bps -101190.01 bps -101395.86 bps -101285.53 bps -101177.61 bps -101078.65 bps -101285.08 bps -100570.91 bps -100694.02 bps -``` - -## test3 -- Host -> Client, around 13000 bps, 1/10 -- Client -> Host, around 115200 bps - -### test3, detail -- Host -> Client, around 13000 bps, 1/10 -``` -PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py -8643.42 bps -13705.61 bps -7663.88 bps -13088.96 bps -12960.40 bps -13315.06 bps -14086.15 bps -13497.89 bps -14034.07 bps -13409.55 bps -``` - -- Client -> Host, around 115200 bps -``` -PS C:\250602_Works\250602_GitLab\ESP-Serial-Bridge\speed_test_script> python .\test1_receive_random.py -825.76 bps -101699.98 bps -101086.60 bps -100784.28 bps -101176.80 bps -101184.19 bps -101181.45 bps -100977.22 bps -101200.93 bps -101220.15 bps -``` - diff --git a/speed_test_script/test1_receive_random.py b/speed_test_script/test1_receive_random.py deleted file mode 100644 index d7552bd..0000000 --- a/speed_test_script/test1_receive_random.py +++ /dev/null @@ -1,24 +0,0 @@ -import serial, time - -ser = serial.Serial("COM18", 115200) -# ser = serial.Serial("COM17", 115200) - -count = 0 -start = time.time() - -while True: - data = ser.read(1024) - count += len(data) - elapsed = time.time() - start - if elapsed >= 1.0: - # kbps = (count / elapsed) / 1024.0 # KB/s - byte_per_sec = (count / elapsed) - kbps = byte_per_sec/ 1024.0 # KB/s - data_bps = byte_per_sec * 8 # データ部のみ(8bit換算) - total_bps = byte_per_sec * 10 # UART全体(8N1の場合) - # print(f"{kbps:.2f} KB/s") - # print(f"{data_bps:.2f} bps") - print(f"{total_bps:.2f} bps") - count = 0 - start = time.time() - diff --git a/speed_test_script/test1_send_random.py b/speed_test_script/test1_send_random.py deleted file mode 100644 index 34db538..0000000 --- a/speed_test_script/test1_send_random.py +++ /dev/null @@ -1,9 +0,0 @@ -import serial, os - -# COMポートを指定(例: COM3) -ser = serial.Serial("COM17", 115200) -# ser = serial.Serial("COM18", 115200) - -while True: - ser.write(os.urandom(1024)) - From d966a6e0253c0e94f85106c91f163326beb40481 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nakagawa Date: Wed, 17 Dec 2025 19:36:36 +0900 Subject: [PATCH 12/12] undo for pull request 2 undo for pull request 2 --- ESP-Serial-Bridge.ino | 3 --- ESP32-Serial-WiFi-Client/client_config.h | 2 +- config.h | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ESP-Serial-Bridge.ino b/ESP-Serial-Bridge.ino index b80672c..20f8814 100644 --- a/ESP-Serial-Bridge.ino +++ b/ESP-Serial-Bridge.ino @@ -57,7 +57,6 @@ BluetoothSerial SerialBT; HardwareSerial Serial_one(1); HardwareSerial Serial_two(2); HardwareSerial* COM[NUM_COM] = {&Serial, &Serial_one, &Serial_two}; -//HardwareSerial* COM[NUM_COM] = {&Serial}; #elif defined(ESP8266) SoftwareSerial Serial_zero(SERIAL0_RXPIN, SERIAL0_TXPIN); SoftwareSerial Serial_one(SERIAL1_RXPIN, SERIAL1_TXPIN); @@ -72,7 +71,6 @@ WiFiServer server_1(SERIAL1_TCP_PORT); #ifdef ESP32 WiFiServer server_2(SERIAL2_TCP_PORT); WiFiServer* server[NUM_COM] = {&server_0, &server_1, &server_2}; -//WiFiServer* server[NUM_COM] = {&server_0}; #elif defined(ESP8266) WiFiServer* server[NUM_COM] = {&server_0, &server_1}; #endif @@ -84,7 +82,6 @@ uint8_t buf2[NUM_COM][BUFFERSIZE]; #ifdef ESP32 uint16_t i1[NUM_COM] = {0, 0, 0}; -//uint16_t i1[NUM_COM] = {0}; #elif defined(ESP8266) uint16_t i1[NUM_COM] = {0, 0}; #endif diff --git a/ESP32-Serial-WiFi-Client/client_config.h b/ESP32-Serial-WiFi-Client/client_config.h index a277dc8..7083b77 100644 --- a/ESP32-Serial-WiFi-Client/client_config.h +++ b/ESP32-Serial-WiFi-Client/client_config.h @@ -28,7 +28,7 @@ #define CLIENT_BAUD 115200 #define CLIENT_PARAM SERIAL_8N1 #define CLIENT_TXPIN 1 -#define CLIENT_RXPIN 21 +#define CLIENT_RXPIN 3 /************************** DO NOT EDIT BELOW HERE **************************/ // perhaps a clever way to include/exclude serial debug messages... diff --git a/config.h b/config.h index 6a440e3..b8aed6a 100644 --- a/config.h +++ b/config.h @@ -33,7 +33,7 @@ #define MODE_AP // MODE_STA or MODE_AP #define PROTOCOL_TCP // uncomment to enable TCP server -#define MAX_NMEA_CLIENTS 1 // max TCP clients +#define MAX_NMEA_CLIENTS 4 // max TCP clients //#define PROTOCOL_UDP // uncomment to enable UDP broadcast (ESP32 only) //#define BLUETOOTH 0 // uncomment to create a bluetooth serial bridge on the indicated serial port (ESP32 only) //#define BATTERY_SAVER // uncomment to reduce wifi power @@ -43,7 +43,6 @@ #ifdef ESP32 #define NUM_COM 3 // 3 available on ESP32 -//#define NUM_COM 1 // 3 available on ESP32 #elif defined(ESP8266) #define NUM_COM 2 // we only use 2 on ESP8266 #endif