From 59418668e2169f53cd0002a1d53072b22010cb9f Mon Sep 17 00:00:00 2001 From: Asbelos Date: Fri, 17 Jan 2025 13:16:29 +0000 Subject: [PATCH] WIfiESP websock fix --- WifiESP32.cpp | 28 +++++++++++++--------------- objdump.bat | 27 ++++++++++++++------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/WifiESP32.cpp b/WifiESP32.cpp index 3b9d6bd..9483501 100644 --- a/WifiESP32.cpp +++ b/WifiESP32.cpp @@ -392,21 +392,19 @@ void WifiESP::loop() { int count=outboundRing->count(); auto wsHeaderLen=useWebsocket? Websockets::getOutboundHeaderSize(count) : 0; { - - byte buffer[wsHeaderLen+count+1]; // one extra for '\0' - if (useWebsocket) Websockets::fillOutboundHeader(count, buffer); - for(int i=0;iread(); - if (c >= 0) // Panic check, should never be false - // websocket implementations at browser end can barf at \b - if (websocket && (cout=='\n')) cout='\r'; - buffer[i+wsHeaderLen] = (char)c; - else { - DIAG(F("Ringread fail at %d"),i); - break; - } - } - // buffer filled, end with '\0' so we can use it as C string + byte buffer[wsHeaderLen + count + 1]; // one extra for '\0' + if (useWebsocket) Websockets::fillOutboundHeader(count, buffer); + for (int i = 0; i < count; i++) { + int c = outboundRing->read(); + if (!c) { + DIAG(F("Ringread fail at %d"), i); + break; + } + // websocket implementations at browser end can barf at \n + if (useWebsocket && (c == '\n')) c = '\r'; + buffer[i + wsHeaderLen] = (char)c; + } + // buffer filled, end with '\0' so we can use it as C string buffer[wsHeaderLen+count]='\0'; if((unsigned int)clientId <= clients.size() && clients[clientId].active(clientId)) { if (Diag::CMD || Diag::WITHROTTLE) diff --git a/objdump.bat b/objdump.bat index 26e3233..8f8ab7f 100644 --- a/objdump.bat +++ b/objdump.bat @@ -1,16 +1,17 @@ ECHO ON -FOR /F "delims=" %%i IN ('dir %TMP%\arduino_build_* /b /ad-h /t:c /od') DO SET a=%%i -echo Most recent subfolder: %a% >%TMP%\OBJDUMP_%a%.txt -SET ELF=%TMP%\%a%\CommandStation-EX.ino.elf +FOR /F "delims=" %%i IN ('dir %TMP%\arduino\sketches\CommandStation-EX.ino.elf /s /b /o-D') DO SET ELF=%%i +SET DUMP=%TEMP%\OBJDUMP.txt +echo Most recent subfolder: %ELF% >%DUMP% + set PATH="C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\";%PATH% -avr-objdump --private=mem-usage %ELF% >>%TMP%\OBJDUMP_%a%.txt -ECHO ++++++++++++++++++++++++++++++++++ >>%TMP%\OBJDUMP_%a%.txt -avr-objdump -x -C %ELF% | find ".text" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt -ECHO ++++++++++++++++++++++++++++++++++ >>%TMP%\OBJDUMP_%a%.txt -avr-objdump -x -C %ELF% | find ".data" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt -ECHO ++++++++++++++++++++++++++++++++++ >>%TMP%\OBJDUMP_%a%.txt -avr-objdump -x -C %ELF% | find ".bss" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt -ECHO ++++++++++++++++++++++++++++++++++ >>%TMP%\OBJDUMP_%a%.txt -avr-objdump -D -S %ELF% >>%TMP%\OBJDUMP_%a%.txt -%TMP%\OBJDUMP_%a%.txt +avr-objdump --private=mem-usage %ELF% >>%DUMP% +ECHO ++++++++++++++++++++++++++++++++++ >>%DUMP% +avr-objdump -x -C %ELF% | find ".text" | sort /+25 /R >>%DUMP% +ECHO ++++++++++++++++++++++++++++++++++ >>%DUMP% +avr-objdump -x -C %ELF% | find ".data" | sort /+25 /R >>%DUMP% +ECHO ++++++++++++++++++++++++++++++++++ >>%DUMP% +avr-objdump -x -C %ELF% | find ".bss" | sort /+25 /R >>%DUMP% +ECHO ++++++++++++++++++++++++++++++++++ >>%DUMP% +avr-objdump -D -S %ELF% >>%DUMP% +%DUMP% EXIT