Remarks

IDxxLA
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Radio.Rfid.IDxxLA

Code Example

IRfidReader rfidReader;

public override Task Initialize()
{
    Console.WriteLine("Initialize...");

    rfidReader = new IDxxLA(Device, Device.SerialPortNames.Com1);

    // subscribe to event
    rfidReader.RfidRead += RfidReaderOnTagRead;

    // subscribe to IObservable
    rfidReader.Subscribe(new RfidObserver());

    return Task.CompletedTask;
}

public override Task Run()
{ 
    rfidReader.StartReading();

    return Task.CompletedTask;
}

private void RfidReaderOnTagRead(object sender, RfidReadResult e)
{
    if (e.Status == RfidValidationStatus.Ok) {
        Console.WriteLine($"From event - Tag value is {DebugInformation.Hexadecimal(e.RfidTag)}");
        return;
    }

    Console.WriteLine($"From event - Error {e.Status}");
}

private class RfidObserver : IObserver<byte[]>
{
    public void OnCompleted()
    {
        Console.WriteLine("From IObserver - RfidReader has terminated, no more events will be emitted.");
    }

    public void OnError(Exception error)
    {
        Console.WriteLine($"From IObserver - {error}");
    }

    public void OnNext(byte[] value)
    {
        Console.WriteLine($"From IObserver - Tag value is {DebugInformation.Hexadecimal(value)}");
    }
}

Sample project(s) available on GitHub

Characteristic Locus
Inheritance System.Object > IDxxLA
Implements IRfidReader IObservable<System.Byte[]> IDisposable
Namespace Meadow.Foundation.Sensors.Radio.Rfid
Assembly IDxxLA.dll

Syntax

public class IDxxLA : object, IRfidReader, IObservable<byte[]>, IDisposable

Constructors

IDxxLA(ISerialMessageController, SerialPortName)

Create an IDxxLA RFID reader

Declaration
public IDxxLA(ISerialMessageController device, SerialPortName serialPortName)

Parameters

Type Name Description
ISerialMessageController device

Device to use

SerialPortName serialPortName

Port name to use

IDxxLA(ISerialMessagePort)

Create an IDxxLA RFID reader using an existing port.

Declaration
public IDxxLA(ISerialMessagePort serialPort)

Parameters

Type Name Description
ISerialMessagePort serialPort

Remarks

Be sure to use suitable settings when creating the serial port. Default BaudRate and DataBits are exposed as constants.

Fields

BaudRate

Declaration
public const int BaudRate = null

Field Value

Type Description
System.Int32

DataBits

Declaration
public const int DataBits = null

Field Value

Type Description
System.Int32

Properties

LastRead

A cached copy of the last successfully read RFID tag.

Declaration
public byte[] LastRead { get; }

Property Value

Type Description
System.Byte[]

The last read RFID tag.

SerialPort

Declaration
public ISerialMessagePort SerialPort { get; }

Property Value

Type Description
ISerialMessagePort

Methods

Dispose()

Dispose of this instance.

Declaration
public void Dispose()

StartReading()

Start reading for RFID tags.

Declaration
public void StartReading()

StopReading()

Stop reading for RFID tags.

Declaration
public void StopReading()

Subscribe(IObserver<Byte[]>)

Subscribe to RFID tag reads. Observer will only receive valid reads, with invalid reads triggering an OnError call. OnComplete will be called if this instance is disposed. This call is thread-safe.

Declaration
public IDisposable Subscribe(IObserver<byte[]> observer)

Parameters

Type Name Description
IObserver<System.Byte[]> observer

The observer to subscribe

Returns

Type Description
IDisposable

Disposable unsubscriber

Events

RfidRead

Event fired when an RFID tag is read. Check the read status to see if the read was successful.

Declaration
public event RfidReadEventHandler RfidRead

Event Type

Type Description
RfidReadEventHandler