Table of Contents

Core Concepts

The Ahsoka Service Pattern

CanService and IOService are both AhsokaServiceBase implementations, hosted by the OpenPV runtime and reached over a local TCP transport by a matching AhsokaClientBase client (CanServiceClient, IOServiceClient) that your application constructs. You never talk to the service directly — every call goes Client.Method(...) → serialized request → service → response, and every async event arrives as a notification your client raises on the Ahsoka.Core.Dispatch dispatcher you registered a callback with.

Both services are configured in the extension's .extensioninfo.json with AutoStart behavior, so the runtime starts them before your application code runs. Your application's only job is to construct clients and register for the notifications it cares about — see Notifications for the subscription pattern and what each service can send.

Service Readiness

IO raises a one-time ignition catch-up notification when a client connects after the ignition state is already known, so a client that registers late doesn't miss it. Because Dispatcher.RegisterCallback has no buffering, always register before calling OpenCommunicationChannel() — see Getting Started.

CAN is stricter. CanService opens every configured port asynchronously in the background; until every port has finished opening, the service rejects every request except OpenCommunicationChannel with an exception. OpenCommunicationChannel() itself always succeeds — it returns the port calibration immediately — but that is not the readiness signal. Wait for the CanServiceIsReadyNotification notification (sent once to every connected client, and again to any client that connects after readiness) before sending CAN messages, applying filters, or calling any other CanServiceClient method.

Platform Selection

Both services pick their real implementation at runtime, based on SystemInfo.CurrentPlatform:

Platform CanService IOService
Desktop ECOMServiceImplementation (Windows, when a port is configured for the ECOM USB-CAN adapter) or DesktopServiceImplementation (mock) DesktopServiceImplementation (mock)
OpenView (CM4) STCoprocessorServiceImplementation (coprocessor-backed ports) or a SocketCAN implementation, per port STServiceImplementation (runs directly on Linux — no coprocessor bridge for IO on this platform)
OpenView Pro (CA91) STCoprocessorServiceImplementation for every port CA90ServiceImplementation

CanService makes this choice per port — but all ports must be configured to use the same CanInterface. IOService makes the choice once, for the whole service.

CAN Message Handling: Raw vs. J1939

Every CAN port dispatches received frames through a chain of protocol handlers under Services/Can/Messages/:

Handler Role
RawProtocolHandler Frames that don't match any configured J1939 handling — delivered to the client as-is via CanMessagesReceived
ACMessageHandler J1939 Address Claim — tracks which source address each configured node currently holds
RQSTMessageHandler J1939 Request (PGN 0xEA00)
TPMessageHandler J1939 Transport Protocol (BAM/CMDT/multi-frame reassembly)
DMMessageHandler J1939 DM1/DM2 diagnostic trouble code broadcasts, decoded into Dm1State/Dm2State notifications
NmeaFastPacketMessageHandler NMEA 2000 fast-packet reassembly, used by CanLocationPlugin

Sending a message never requires you to construct raw bytes by hand: CanServiceClient.SendCanMessages accepts either raw CanMessageData or any type implementing IHasCanData — the models the GenerateCANClasses code generator produces from a DBC or CAN calibration file.

Plugins

CanService hosts optional service plugins (CanLocationPlugin, CruisePlugin, PdmPlugin) that are not started automatically. An application requests one by registering it through the Ahsoka plugin mechanism; CanService.OnPluginRequested matches the request's endpoint hash against each known plugin and adds it on demand. If your application never requests a plugin, its code never runs.