Repository navigation
Talk to the device directly by default, alongside Central; deprecate Central-compat mode (#213) - #215
Merged
Merged
Conversation
A STANDALONE session can share a device with a running Central on the same PC (#213). Central binds each Gemini port on the instrument-network address without SO_REUSEADDR; a socket bound to the wildcard address with SO_REUSEADDR coexists with it in either start order, and since the devices broadcast everything, both receive the full stream. Measured on Central 7.7 and 7.8 with two hubs at 256 ch x 30 kHz: no lost samples on either side in any start order, config changes from either side seen by the other within ~50 ms, and recording commands from a session still reach Central via the device's broadcast REPFILECFG echo. So: - The Windows device socket shares the port again (reverting #212's SO_EXCLUSIVEADDRUSE, under which Central crashed on launch), and the protocol probe binds the wildcard like the device socket instead of the detected address Central holds (the WSAEACCES of #210). - New SdkConfig::connection_mode / cbsdk_config_t::connection_mode / Session(connection_mode=...). NATIVE, the default, never touches Central's shared memory. CENTRAL keeps the Central-compatible attach, is opt-in only, never falls back to NATIVE, and is deprecated for removal in the next major release. - The soak harness requests CENTRAL explicitly for --central runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 6, 2026
The deprecated Central shared-memory path is now chosen by setting CERELINK_CENTRAL_COMPAT=1 rather than SdkConfig::connection_mode / cbsdk_config_t::connection_mode / Session(connection_mode=...), so the public API and the C struct layout are unchanged. The variable only matters while Central is running and has a slot for the device; otherwise the session talks to the device directly as usual. Attaching to a running Central that has a slot still fails rather than falling back. Also sorts pycbsdk imports and __all__ for ruff. Co-Authored-By: Claude <[email protected]>
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.
Addresses #213. Follow-up to #212 / #214.
Summary
A CereLink STANDALONE session can share a device with a running Central on the same Windows PC, so CereLink no longer needs to go through Central's shared memory to coexist with it. This PR makes talking to the device directly the default, and turns the Central-compatible attach into an opt-in, deprecated mode slated for removal in the next major release.
Changes
Shared device port on Windows (cbdev)
SO_REUSEADDRagain, reverting Windows: peer clock consensus is stubbed out, and Central coexistence is inverted (#210) #212'sSO_EXCLUSIVEADDRUSE, under which Central 7.6–7.8 crashed on launch.192.168.137.199:51002) withoutSO_REUSEADDR.SO_REUSEADDR.WSAEACCES(10013) in Using Cerelink together with Central on the same Windows computer does not always work #210. Loopback, used by NPLAY, stays specific.bind()explain why the wildcard bind is load-bearing.Connection mode (cbsdk)
CERELINK_CENTRAL_COMPAT=1, not an API parameter, so the C++, C and Python APIs and thecbsdk_config_tlayout are unchanged.ShmemLayout::CENTRALand thecentral_clientexample are marked deprecated.CERELINK_CENTRAL_COMPAT=1for--centralruns.shared_memory_architecture.md(new "Running alongside Central" section), and the sequence diagrams.Is removing the Central path possible?
Yes, as far as we can tell. The one obvious Central-only feature, recording control, works from a NATIVE session. The device echoes
SETFILECFGas a broadcastREPFILECFG, and Central's File Storage acts on it. This was verified: a STANDALONE session opened File Storage, recorded and closed it, and the files were written.Bench results (#213 matrix)
Setup: Central 7.8.0, firmware 7.8, HUB1 + HUB2 at 256 ch × 30 kHz.
sync()< 1 ms, clock ±130–150 µssync()~20 ms, clock ±10 mssync()< 1 msSession(HUB1)→ STANDALONE, ~30k samples/s, no warning.connection_mode="central"(since replaced byCERELINK_CENTRAL_COMPAT=1) → attaches through Central.Known caveats (documented)
custom_client_addresscannot share the port with Central; leave it unset.Compatibility
CERELINK_CENTRAL_COMPAT=1.Tests
DeviceSessionTests (they replace Windows: peer clock consensus is stubbed out, and Central coexistence is inverted (#210) #212's exclusive-port tests):Windows_CentralCanBindAfterSessionWindows_SessionCanBindAfterCentralWindows_ProtocolProbeCanBindAfterCentral: holds the detected 192.168.137.x address the way Central does; skips without such an adapter.Failed to bind probe socket (winsock err 10013)without the factory change.SessionLifecycleTest.CentralCompatEnvWithoutCentralSlotIsStandalone(nPlayServer): withCERELINK_CENTRAL_COMPAT=1and no Central slot for the device, the session is still STANDALONE.A session-side recording gate is proposed separately in #218.
Not verified:
🤖 Generated with Claude Code