Skip to content

Fix the CheckESPTimeout and its constant, remove WaitRaster, add init empty Rx FIFO#9

Open
janko-jj wants to merge 2 commits into
remy:mainfrom
janko-jj:main
Open

Fix the CheckESPTimeout and its constant, remove WaitRaster, add init empty Rx FIFO#9
janko-jj wants to merge 2 commits into
remy:mainfrom
janko-jj:main

Conversation

@janko-jj

Copy link
Copy Markdown

As each WaitRaster causes up to a whole frame busy wait, the constant used for timeout produced a practically infinite wait in 1.1.0. Here WaitRaster is removed from CheckESPTimeout , and instead the constant calculation adjusted to specify the timeout in seconds. As many seconds are needed for slow requests over the internet, a timeout constant of 60 seconds (in 28MHz mode) is specified to also comply with the reason which lead to the introduction of WaitRaster.
Also an UART init is adjusted to perform fast emptying of Rx FIFO at the start.

janko-jj added 2 commits June 16, 2026 02:51
  With the WaitRaster and the big constant the timeout became infinity
  in practice. Therefore after the constant calculation is corrected
  the WaitRaster is removed. The timeout is set to 60 seconds at 28MHz
@remy

remy commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Where you able to test against the original issue? #7

@janko-jj

janko-jj commented Jun 16, 2026

Copy link
Copy Markdown
Author

We can chat on discord about the details, I've also reported you the previous ("it remained stuck") issue which resulted in you fixing it in some later http, and I can explain there the details of test setups.

WaitRaster does busy wait until the line is 192, which means it doesn't break when there is new data, but can loop for a whole frame time, 1/50th of the second, which for a given constant means 65535*4/50 = 5242 seconds until the timeout.

Additionally, it's not that then selecting a small constant would also give good results as the WaitRaster waits 1/50th sometimes, but not always: it was made convenient for games, where once it stops waiting, it's not called in the same line. Here if it is called fast during the nextreg 0x1f is still in the same line, the counter will decrease faster. Which means that using it unchanged in the context needed in .http is generally "not right" (the actual timeouts aren't expiring regularly but execute with actually less predictable delays, sometimes expiring fast (while the line is 192), sometimes not). Making a code bigger to fix WaitRaster, and then selecting the smaller constant is still IMO worse solution than finding a way to conveniently adjust the counter for the code without WaitRaster, as without the WaitRaster the wait until the data will be processed will be much shorter, and the FIFO will be kept less full, enabling more reliable transfers.

This is GetIt receiving a response from 7 without timeout happening too early, with the http with this PR:

image

And this is to demonstrate that it does timeout when it's promised, a snapshot of the result when, for the debugging purposes, it's made sure that ESP gives no response at all:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants