Add ps2client: a CC0 Go client for ps2link #1

Merged
techwritescode merged 5 commits from ps2client-go into main 2026-09-29 22:20:00 +00:00

A Go client for ps2link, released under CC0, as cmd/ps2client.

  • Commands: reset, execiop, execee, poweroff, scrdump, netdump, dumpmem, writemem, startvu, stopvu, dumpreg, gsexec, listen. iopexcep is left out. -h, -t and $PS2HOSTNAME behave as in the C tool.
  • Serves the PS2's host: file requests (open, read, write, lseek, directories, stat, remove, mkdir) from a directory, with the root confined against .. and symlinks and an optional read-only mode.
  • ps2client fs exists but is not implemented yet.
  • Written from the wire protocol, not from the BSD-licensed C ps2client, so it can be CC0. Sources and the one caveat are in cmd/ps2client/CLEANROOM.md; the protocol is in cmd/ps2client/docs/protocol.md.

Tested against real ps2link v1.9.x in PCSX2:

  • Unit tests for packets, the file server (including path escapes) and the UDP/TCP session code run anywhere.
  • An end-to-end suite (-tags e2e) resets ps2link and checks the file device (byte-exact 300 KiB read and 100 KiB write, stat, directories, lseek), a memory write/dump round trip, and all register dump sizes. All pass. See cmd/ps2client/docs/testing.md for the emulator setup (it needs a TAP adapter and a modified ps2link).
  • execiop (arguments and module fetch), gsexec, scrdump, netdump, startvu and stopvu were confirmed by hand against ps2link's log.

Found while testing:

  • ps2link reads stat modes in the classic ioman encoding; the first version sent the fileXio one and every entry looked like both a file and a directory.
  • The PS2's fioRemove follows a successful remove with a mkdir of the same name (documented as broken in the SDK).
  • dumpreg fifo aborts PCSX2 (emulator assertion); it is skipped in the emulator run.
  • Console text works end to end in PCSX2 for text written to tty0: (the e2e suite asserts it). A plain printf never reaches udptty in the emulator because PCSX2 handles writes to stdout itself; that path needs a real PS2 (examples/consoletest and a hardware guide are included).
  • sdk-core's ps2ip-nm was built from the wrong source and could never send anything; fixed separately in ps2/sdk-core.

Not tested on hardware. Tracked as PS2-18 (phases PS2-19 to PS2-26).

A Go client for ps2link, released under CC0, as `cmd/ps2client`. - Commands: reset, execiop, execee, poweroff, scrdump, netdump, dumpmem, writemem, startvu, stopvu, dumpreg, gsexec, listen. `iopexcep` is left out. `-h`, `-t` and `$PS2HOSTNAME` behave as in the C tool. - Serves the PS2's `host:` file requests (open, read, write, lseek, directories, stat, remove, mkdir) from a directory, with the root confined against `..` and symlinks and an optional read-only mode. - `ps2client fs` exists but is not implemented yet. - Written from the wire protocol, not from the BSD-licensed C ps2client, so it can be CC0. Sources and the one caveat are in `cmd/ps2client/CLEANROOM.md`; the protocol is in `cmd/ps2client/docs/protocol.md`. Tested against real ps2link v1.9.x in PCSX2: - Unit tests for packets, the file server (including path escapes) and the UDP/TCP session code run anywhere. - An end-to-end suite (`-tags e2e`) resets ps2link and checks the file device (byte-exact 300 KiB read and 100 KiB write, stat, directories, lseek), a memory write/dump round trip, and all register dump sizes. All pass. See `cmd/ps2client/docs/testing.md` for the emulator setup (it needs a TAP adapter and a modified ps2link). - `execiop` (arguments and module fetch), `gsexec`, `scrdump`, `netdump`, `startvu` and `stopvu` were confirmed by hand against ps2link's log. Found while testing: - ps2link reads stat modes in the classic ioman encoding; the first version sent the fileXio one and every entry looked like both a file and a directory. - The PS2's `fioRemove` follows a successful remove with a mkdir of the same name (documented as broken in the SDK). - `dumpreg fifo` aborts PCSX2 (emulator assertion); it is skipped in the emulator run. - Console text works end to end in PCSX2 for text written to `tty0:` (the e2e suite asserts it). A plain `printf` never reaches udptty in the emulator because PCSX2 handles writes to stdout itself; that path needs a real PS2 (`examples/consoletest` and a hardware guide are included). - sdk-core's `ps2ip-nm` was built from the wrong source and could never send anything; fixed separately in ps2/sdk-core. Not tested on hardware. Tracked as PS2-18 (phases PS2-19 to PS2-26).
Written from the ps2link protocol, not the C ps2client; see cmd/ps2client/CLEANROOM.md
and docs/protocol.md. The fs subcommand is not implemented yet.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Found by running the client against ps2link in PCSX2: file and directory
modes came out wrong on the PS2 because the fileXio type bits overlap the
ioman ones.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ps2client: end-to-end tests against ps2link in PCSX2, loopback tests, docs
All checks were successful
Build / build (push) Successful in 57s
0c4d69a47d
The e2e suite (build tag e2e) resets ps2link, then checks the file device,
a memory write/dump round trip and every register dump size. Also adds unit
tests for the UDP/TCP session code and a guide to the emulator setup.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The emulated PS2's console text reaches ps2client through the stock udptty when
a program writes to tty0:. PCSX2 handles writes to stdout before any driver sees
them, so the plain printf path can only be checked on hardware.

Also warns when the console port cannot be bound, and asserts console text in
the e2e suite.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ps2client docs: console text finding
All checks were successful
Build / build (push) Successful in 1m1s
90e7c0d93b
techwritescode force-pushed ps2client-go from 90e7c0d93b
All checks were successful
Build / build (push) Successful in 1m1s
to c71c110544
All checks were successful
Build / build-macos (push) Successful in 31s
Build / build (push) Successful in 56s
2026-09-29 22:17:09 +00:00
Compare
techwritescode force-pushed ps2client-go from c71c110544
All checks were successful
Build / build-macos (push) Successful in 31s
Build / build (push) Successful in 56s
to fac2fe4488
All checks were successful
Build / build (push) Successful in 58s
Release / build-macos (push) Successful in 38s
Release / build (amd64, linux) (push) Successful in 47s
Release / build (amd64, windows) (push) Successful in 1m4s
Release / release (push) Successful in 9s
2026-09-29 22:18:56 +00:00
Compare
techwritescode deleted branch ps2client-go 2026-09-29 22:20:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ps2/tools!1
No description provided.