Getting Started
Add the Extension to Your Project
Add the package reference to your application project:
<PackageReference Include="Ahsoka.Extensions.Control" />
And register the extension in your application's package/target definition (*.PackageInfo.json)
so the OpenPV Developer Toolkit deploys CanService/IOService alongside your application:
"extensionInfo": [
{ "packageName": "Ahsoka.Extensions.Control" }
]
Both services are AutoStart — you do not launch them yourself. Your application only needs to
construct the clients it wants to talk to.
Demos/Ahsoka.CS.CAN in this repository is a complete, runnable reference for everything below —
it exercises both CanServiceClient and IOServiceClient against the same package reference and
extension registration shown here.
Reading IO
using Ahsoka.Core.Dispatch;
using Ahsoka.Services.IO;
var ioClient = new IOServiceClient();
// Register notification callbacks BEFORE opening the channel. OpenCommunicationChannel() can
// trigger notifications (e.g. the ignition catch-up broadcast) immediately, and
// Dispatcher.RegisterCallback is a plain event subscription with no buffering — anything that
// fires before you're subscribed is lost.
Dispatcher.Default.RegisterCallback<IOServiceClient.AhsokaNotificationArgs>(OnIoNotification, ioClient);
ioClient.OpenCommunicationChannel();
var digitalOutputs = ioClient.RequestDigitalOutputs();
var battery = ioClient.GetVBat();
Sending and Receiving CAN
using Ahsoka.Core.Dispatch;
using Ahsoka.Services.Can;
var canClient = new CanServiceClient();
// Same rule as IO: register before opening the channel.
Dispatcher.Default.RegisterCallback<CanServiceClient.AhsokaNotificationArgs>(OnCanNotification, canClient);
canClient.OpenCommunicationChannel();
// canClient.Calibrations is populated once OpenCommunicationChannel() returns, describing every
// configured CAN port.
var ports = canClient.Calibrations.CanPortConfiguration.MessageConfiguration.Ports;
uint canPort = ports[0].Port;
canClient.SendCanMessages(canPort, new CanMessageData { Id = 0x18FEF100, Dlc = 8 });
OpenCommunicationChannel() returning does not mean the CAN ports have finished opening —
see Core Concepts before sending anything beyond the initial
call.
Where to Go Next
Read Core Concepts for the Ahsoka service pattern, port/interface configuration, and the CAN readiness gate; read Notifications for the full notification subscription pattern and what each service can send — then browse the API Reference for the full client surface.