Skip to content

Commit

Permalink
WIfiESP websock fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Asbelos committed Jan 17, 2025
1 parent c4e2146 commit 5941866
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
28 changes: 13 additions & 15 deletions WifiESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;i<count;i++) {
int c = outboundRing->read();
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)
Expand Down
27 changes: 14 additions & 13 deletions objdump.bat
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5941866

Please sign in to comment.