Skip to content

daqifi/daqifi-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

101 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DAQiFi Core Library

The DAQiFi Core Library is a .NET library designed to simplify interaction with DAQiFi devices. It provides a robust and intuitive API for discovering, connecting to, and communicating with DAQiFi hardware, making it an ideal choice for developers building applications that require data acquisition and device control.

Features

βœ… Available Now

  • Device Discovery: Find DAQiFi devices connected via WiFi, USB/Serial, or HID bootloader mode
  • Easy Connection: Single-call device connection with DaqifiDeviceFactory
  • Data Streaming: Stream data from devices in real-time with event-driven API
  • SD Card Operations: List, download, delete, and format SD card files; start/stop SD logging over USB/Serial connections (not available over WiFi)
  • Firmware Update Orchestration: Programmatic PIC32 bootloader updates with state/progress reporting, timeout/retry handling, and cancellation support
  • Transport Layer: TCP, UDP, and Serial communication with async/await patterns
  • Protocol Buffers: Efficient binary message serialization for device communication
  • Cross-Platform: Compatible with .NET 8.0 and .NET 9.0

🚧 In Development

  • Channel Configuration: Advanced channel setup and calibration

Getting Started

Installation

dotnet add package Daqifi.Core

Quick Start: Connect and Stream

using Daqifi.Core.Device;
using Daqifi.Core.Communication.Producers;

// Connect to a device (handles transport, connection, and initialization)
using var device = await DaqifiDeviceFactory.ConnectTcpAsync("192.168.1.100", 9760);

// Subscribe to incoming data
device.MessageReceived += (sender, e) =>
{
    if (e.Message.Data is DaqifiOutMessage message)
    {
        Console.WriteLine($"Timestamp: {message.MsgTimeStamp}");
        Console.WriteLine($"Analog values: {string.Join(", ", message.AnalogInData)}");
    }
};

// Configure channels and start streaming
device.Send(ScpiMessageProducer.EnableAdcChannels("3")); // Enable first 2 channels (bitmask 0b11 = 3)
device.Send(ScpiMessageProducer.StartStreaming(100)); // 100 Hz sample rate

await Task.Delay(TimeSpan.FromSeconds(10)); // Stream for 10 seconds

device.Send(ScpiMessageProducer.StopStreaming);

Connection Options

// With retry options for unreliable networks
using var device = await DaqifiDeviceFactory.ConnectTcpAsync(
    "192.168.1.100",
    9760,
    DeviceConnectionOptions.Resilient); // 5 retries, longer timeouts

// Connect from discovery result
var devices = await wifiFinder.DiscoverAsync(TimeSpan.FromSeconds(5));
using var device = await DaqifiDeviceFactory.ConnectFromDeviceInfoAsync(devices.First());

// Custom options
using Daqifi.Core.Communication.Transport; // For ConnectionRetryOptions

var options = new DeviceConnectionOptions
{
    DeviceName = "My DAQiFi",
    ConnectionRetry = new ConnectionRetryOptions
    {
        MaxAttempts = 3,
        ConnectionTimeout = TimeSpan.FromSeconds(10)
    },
    InitializeDevice = true // Sends standard init commands
};
using var device = await DaqifiDeviceFactory.ConnectTcpAsync(ip, port, options);

Quick Start: Device Discovery

using Daqifi.Core.Device.Discovery;

// Discover WiFi devices on your network
using var wifiFinder = new WiFiDeviceFinder();
wifiFinder.DeviceDiscovered += (sender, e) =>
{
    var device = e.DeviceInfo;
    Console.WriteLine($"Found: {device.Name} at {device.IPAddress}");
    Console.WriteLine($"  Serial: {device.SerialNumber}");
    Console.WriteLine($"  Firmware: {device.FirmwareVersion}");
};

var devices = await wifiFinder.DiscoverAsync(TimeSpan.FromSeconds(5));
Console.WriteLine($"Discovery complete. Found {devices.Count()} device(s)");

// Discover USB/Serial devices
using var serialFinder = new SerialDeviceFinder();
var serialDevices = await serialFinder.DiscoverAsync();

foreach (var device in serialDevices)
{
    Console.WriteLine($"Serial Port: {device.PortName}");
}

Advanced Discovery Options

// Use cancellation tokens for fine-grained control
using var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(10));

try
{
    var devices = await wifiFinder.DiscoverAsync(cts.Token);
}
catch (OperationCanceledException)
{
    Console.WriteLine("Discovery was cancelled");
}

// Discover on custom UDP port (default is 30303)
using var customFinder = new WiFiDeviceFinder(port: 12345);
var customDevices = await customFinder.DiscoverAsync();

Supported Devices

The library automatically detects DAQiFi hardware:

  • Nyquist 1: DAQiFi's data acquisition device
  • Nyquist 3: DAQiFi's advanced data acquisition device

Both devices are identified by their part number in the discovery response.

Connection Types

  • WiFi: Network-connected devices discovered via UDP broadcast
  • Serial: USB-connected devices enumerated via serial ports
  • HID: Devices in bootloader mode (HidSharp backend)

Firmware Update Orchestration

The core library exposes IFirmwareUpdateService for update orchestration:

  • UpdateFirmwareAsync(...) for PIC32 firmware flashing from a local Intel HEX file
  • UpdateWifiModuleAsync(...) for WiFi module flashing through an external tool runner

UpdateWifiModuleAsync automatically queries the device's current WiFi chip firmware version via ILanChipInfoProvider and compares it against the latest GitHub release. If the device is already up to date, the flash is skipped and the service reports Complete immediately β€” no unnecessary reflashing.

The service emits explicit state transitions and IProgress<FirmwareUpdateProgress> updates for UI/CLI telemetry.

Note: the default WiFi flash tool configuration uses winc_flash_tool.cmd conventions. If you run on macOS/Linux, provide a compatible executable/script and argument template via FirmwareUpdateServiceOptions.

Real-World Usage

This library powers the DAQiFi Desktop application and is designed for:

  • Custom data acquisition applications
  • Automated testing systems
  • Industrial monitoring solutions
  • Research and development tools
  • Any application requiring DAQiFi device integration

Requirements

  • .NET 8.0 or .NET 9.0
  • For WiFi discovery: UDP port 30303 must be accessible (firewall configuration may be required)
  • For Serial discovery: Appropriate USB drivers for your platform
  • Admin privileges may be required for firewall configuration on Windows

Publishing

This library follows semantic versioning (MAJOR.MINOR.PATCH):

  • MAJOR: Breaking changes
  • MINOR: New features (backwards compatible)
  • PATCH: Bug fixes

Releases are automated via GitHub Actions:

  1. Create a new GitHub Release
  2. Tag it with vX.Y.Z (e.g. v1.0.0)
  3. For pre-releases, use -alpha.1, -beta.1, -rc.1 suffixes
  4. Publishing to NuGet happens automatically on release

About

.NET library for interacting with DAQiFi devices

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages