Repository navigation
Conversation
net_tcp_connect stored the handle in ult_tmp and then called ult_read_status, which ends with 'sty ult_tmp' (the status byte count, 5 for "00,OK"). HTTPGET and TELNET therefore wrote to handle 5 and HTTPGET read from whatever ult_read_data left in ult_tmp. Save the handle to telnet_sock before ult_read_status and have HTTPGET's SOCK_WRITE and SOCK_READ use it, as TELNET already does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An empty NET READ can answer at once with length $FFFF and no data, so HTTPGET printed nothing when the server's reply had not arrived yet. Retry the READ until data comes or about 5 seconds pass, timed on the CIA1 time-of-day clock (the jiffy clock does not run with interrupts off). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
hg_append copies pieces into dir_buffer but never terminates the result, so ult_cmd_str sent the request followed by whatever stale bytes were already in dir_buffer. Write the terminator after the last piece. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1
net_tcp_connectsaved the socket handle inult_tmpand then calledult_read_status, which ends withsty ult_tmp. That left the status length (5 for00,OK) inult_tmp, so HTTPGET wrote to handle 5 and read from another handle, and TELNET stored 5 astelnet_sock. The firmware answers an unknown handle with EBADF, so neither command worked.Changes
Three commits. The first is the bug fix and stands alone; the second builds on it (HTTPGET only gets as far as the READ once the handle is right); the third is independent:
telnet_sockinnet_tcp_connectbeforeult_read_status. HTTPGET's SOCK_WRITE and SOCK_READ usetelnet_sock; TELNET no longer copies fromult_tmp.$FFFF, no data), for up to about 5 seconds, timed on the CIA1 time-of-day clock because the jiffy clock doesn't run with interrupts off. Addsult_tod_start/ult_tod_expiredto the SDK and no-op versions to the VICE stub.hg_appenddoesn't terminate the request indir_buffer, soult_cmd_strsent stale bytes after it. Write a zero after the last piece.Testing
Built with ACME (all 22 banks,
cartconvto EasyFlash .crt). Ran on an Ultimate 64 Elite, with an HTTP server and a telnet server on a computer on the LAN. With the EasyFlash .crt running on an Ultimate 64 Elite, $DF1C-$DF1F read $F0, so the Command Interface isn't reachable (and I don't know how you run it against a real Ultimate). So I loaded bank 11 itself, unchanged, into RAM at $8000 and calledHttpGetCmdandTelnetCmdfrom a small driver that sets BASIC's text pointer to the arguments. The cartridge bank switching is not exercised.Results, same build for each row, on firmware where READ waits 40 ms and on firmware where READ does not wait:
Typed characters reaching the telnet server came through in 2 of 4 attempts with commits 1+2 (both on the no-wait firmware) and in 0 of 4 with commit 1 alone. TELNET's code is the same in both builds, so I don't know why; I haven't shown TELNET's write side reliably.
For commit 3, I filled
dir_bufferwithSTALE-BYTES-before running HTTPGET and captured what the server received. Before:GET / HTTP/1.0\r\nHost: 192.168.1.10\r\n\r\nALE-BYTES-STALE-BYTES-.... After:GET / HTTP/1.0\r\nHost: 192.168.1.10\r\n\r\nand nothing else.The retry is there because a UCI READ may answer empty before the server's reply has arrived; see the discussion in GideonZ/1541ultimate#1087.
Written with Claude Sonnet 5.5 in Claude Code.