Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout is too small and can bail before data is returned #7

Closed
em00k opened this issue Mar 11, 2023 · 0 comments
Closed

Timeout is too small and can bail before data is returned #7

em00k opened this issue Mar 11, 2023 · 0 comments

Comments

@em00k
Copy link

em00k commented Mar 11, 2023

InitESPTimeout:

The timeout gives up too quickly if a request takes some seconds to process eg:

https://zxnext.uk/scr?s=!hollywood&p=1

I have done a bodge fix to wait for raster


InitESPTimeout:
	MODULE InitESPTimeout
		push hl
		ld hl, ESPTimeout mod 65536 	; Timeout is a 32-bit value, so save the two LSBs first,
		ld (CheckESPTimeout.Value), hl
		ld hl, ESPTimeout / 65536	; then the two MSBs.
		ld (CheckESPTimeout.Value2), hl
		pop hl
		ret
	ENDMODULE

; Modifies: nothing
CheckESPTimeout:
	MODULE CheckESPTimeout
		push hl
		push af
Value 	EQU $+1
		ld hl, SMC
		dec hl
		ld (Value), hl
		call 	WaitRaster
		ld a, h
		or l
		jr z, Rollover
Success:	pop af
		pop hl
		ret
Failure:	ld hl, (Wifi.timeout)
HandleError:
		call Error 			; Ignore current stack depth, and just jump

Rollover:
Value2 	EQU $+1
		ld hl, SMC			; Check the two upper values
		ld a, h
		or l
		jr z, Failure			; If we hit here, 32 bit value is $00000000
		dec hl
		call 	WaitRaster 
		ld (Value2), hl
		ld hl, ESPTimeout mod 65536
		ld (Value), hl
		jr Success
WaitRaster:

		push 	bc 
		push 	af 
	waitloop:
		ld 		bc, $243b 
		ld 		a, $1f     ; only really care about lsb 
		out 	(c) , a 
		inc 	b 
		in 		a, (c)
		cp 		192 
		jr		nz, waitloop 
		pop 	af 
		pop 	bc 
		ret 

	ENDMODULE
@remy remy closed this as completed in 2e82c14 May 12, 2023
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

No branches or pull requests

1 participant