RfmUsb.Net 2.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package RfmUsb.Net --version 2.0.5
NuGet\Install-Package RfmUsb.Net -Version 2.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RfmUsb.Net" Version="2.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RfmUsb.Net --version 2.0.5
#r "nuget: RfmUsb.Net, 2.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RfmUsb.Net as a Cake Addin
#addin nuget:?package=RfmUsb.Net&version=2.0.5

// Install RfmUsb.Net as a Cake Tool
#tool nuget:?package=RfmUsb.Net&version=2.0.5

RfmUsb

Build Status

NuGet Badge

Api for the USB Rfm69 and Rfm9x serial device. The api allows for all configuration parameters of the Rfm69 and Rfm9x radio module to be configured via a command line interface.

Installing RfmUsb

Install the RfmUsb package via nuget package manager console:

Install-Package RfmUsb.Net

Supported .Net Runtimes

The RfmUsb.Net package is compatible with the following runtimes:

  • .Net Core 7.0

Creating Instance

An instance of an RfmUsb class can be created by providing an instance of an ILogger and a ISerialPortFactory

var logger = GetLogger();

var serialPortFactory = GetSerialPortFactory();

var rfmUsbDevice = Rfm69(logger, serialPortFactory);

Alternatively an instance can be configured using the standard microsoft DI framework.

var serviceCollection = new ServiceCollection()
                .AddLogging(builder => builder.AddSerilog())
                .AddLogging()
                .AddRfmUsb(); // Add the RfmUsb

Open

The RfmUsb instance must be opened prior to usage.

 rfmUsbDevice.Open(comPort, 115200);

Configuration

All of the configuration settings are assigned via properties of the IRfmUsb interface.

_rfmUsb.Open(serialPort, baudrate);

_rfmUsb.Reset();

_rfmUsb.Timeout = 5000;

_rfmUsb.Modulation = Modulation.Fsk;
_rfmUsb.FrequencyDeviation = 0x01EC;
_rfmUsb.Frequency = 434300000;
_rfmUsb.RxBw = 14;
_rfmUsb.BitRate = 4800;
_rfmUsb.Sync = new List<byte>() { 0x2D, 0xD4 };
_rfmUsb.SyncSize = 1;
_rfmUsb.SyncEnable = true;
_rfmUsb.SyncBitErrors = 0;
_rfmUsb.PacketFormat = true;
_rfmUsb.DcFree = DcFree.Manchester;
_rfmUsb.CrcOn = false;
_rfmUsb.CrcAutoClear = false;
_rfmUsb.AddressFiltering = AddressFilter.None;
_rfmUsb.PayloadLength = 66;

Transmit

Transmit a packet of data with the default transmit timeout. The transmit control registers need to be configured to allow transmission of the packet data.

// Transmit data with default transmission timeouts
rfmUsbDevice.Transmit(new List<byte>() { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA });

Transmit a packet of data with a specific transmit timeout. The transmit control registers need to be configured to allow transmission of the packet data.

// Transmit data with a timeout
rfmUsbDevice.Transmit(new List<byte>() { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA }, 1000);

Transmit And Receive

Transmit a packet and wait for a response with the default transmit and receive timeouts.

// Transmit data and wait for a response with the default 
var response = rfmUsbDevice.TransmitReceive(new List<byte>() { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA });

Transmit a packet and wait for a response with the default receive timeouts and a specified transmit timeout.

// Transmit data and wait for
var response = rfmUsbDevice.TransmitReceive(new List<byte>() { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA }, 1000);

Transmit a packet and wait for a response with a specified transmit and receive timeouts.

// Transmit data and wait for
var response = rfmUsbDevice.TransmitReceive(new List<byte>() { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA }, 1000, 1000 );

Irqs

Set the Dio pin Irq mask.

AutoResetEvent IrqSignal;

void RfmDeviceDioInterrupt(object? sender, DioIrq e)
{
    Console.WriteLine("Dio Irq [{e}]", e);

    if ((e & DioIrq.Dio0) == DioIrq.Dio0)
    {
        IrqSignal.Set();
    }
}

// Setup the radio irq pin enables
rfmUsbDevice.DioInterruptMask = DioIrq.Dio0;

rfmUsbDevice.DioInterrupt += RfmDeviceDioInterrupt;

Wait for an IRQ to occur

IrqSignal.WaitOne(timeout);

// Check the irq
if ((rfmUsbDevice.Irq & Irq.PayloadReady) == Irq.PayloadReady)
{
    // Process packet
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RfmUsb.Net:

Package Downloads
RfmOta

A service for Ota updates for Rfm69 devices

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 102 3/9/2024
2.0.5 219 11/13/2023
2.0.4 94 11/6/2023
2.0.3 123 11/5/2023
2.0.1 119 10/20/2023
2.0.0 195 8/2/2023

1.0.0 Initial Version
1.0.6 Bug fixes
1.0.13 Added strong name key
1.0.14 Prevent operation being called when device not open
1.0.15 Added package xml document
1.0.18 Updated open check
1.0.19 Updated reset operation
2.0.0 Added support for Rfm95
2.0.1 Updated Irq handling
2.0.2 Refactored open
2.0.3 Set default timeout
2.0.4 Updated logging
2.0.5 Updated enter and exit conditions