🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

HidDeviceReaderLibrary

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

HidDeviceReaderLibrary

A library for reading data from HID devices(only HID raw,not for virtual keyboard mode) and parsing JSON payloads.

4.5.0
NuGet
Version published
Maintainers
1
Created
Source

HidDeviceReaderLibrary

Introduction

HidDeviceReaderLibrary is a .NET library for reading data from USB HID devices (not supporting virtual keyboard mode) and parsing JSON data. It is suitable for scenarios where you need to communicate with HID devices and process their data.

Features

  • Supports finding and connecting HID devices by VendorID and ProductID
  • Real-time reading of HID device data streams
  • Automatically filters ASCII data and extracts JSON strings
  • Supports parsing JSON and retrieving specific field values
  • Asynchronous data retrieval via event callbacks
  • Supports custom cancellation of reading (CancellationToken)

Supported Platforms

  • .NET Core 2.0 and above
  • .NET 6/8/9
  • Windows, Linux, macOS (platforms supported by HidSharp)

Installation

dotnet add package HidDeviceReaderLibrary

Quick Start Example

using System; 
using System.Threading; 
using HidDeviceReaderLibrary;
class Program { 
    static async void Main() 
        {
            // your HID device VendorID 和 ProductID
            var reader = new HidDeviceReader(0x2F50, 0x0300);
            reader.OnDataReceived += data =>
            {
                Console.WriteLine($"Received data: {data}");
            };

            using (var cts = new CancellationTokenSource())
            {
                // press Ctrl+C cancels
                Console.CancelKeyPress += (s, e) => {
                    e.Cancel = true;
                    cts.Cancel();
                };

                await reader.StartReadingAsync(cts.Token);
                Console.ReadKey();
            }
        }
}

Dependencies

License

MIT

Keywords

HID

FAQs

Package last updated on 16 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts