Quick Start
This guide walks through connecting to an rf IDEAS reader, reading metadata, and using reader features in all supported languages.
1. Define the Reader
Every RIK application starts by defining which reader to connect to:
- C++
- C#
- Python
#include "Reader/AbstractReader.h"
#include "Reader/Reader.h"
using namespace Rik;
using namespace RikCommon;
ReaderDefinition readerDef{};
readerDef.DeviceId.VendorId = 0x0C27;
readerDef.DeviceId.ProductId = 0x3BFA;
readerDef.ProtocolType = PROTOCOL_TYPE_FEATURE_REPORT;
using rfIDEAS.ReaderIntegrationKit;
using rfIDEAS.ReaderIntegrationKit.Objects;
using rfIDEAS.ReaderIntegrationKit.Enum;
var readerDef = new ReaderDefinition {
DeviceId = new DeviceId { VendorId = 0x0C27, ProductId = 0x3BFA },
ProtocolType = ProtocolType.FeatureReport,
SerialPortSettings = new SerialPortSettings()
};
from reader_integration_kit.facade import Reader
from reader_integration_kit.structures import ReaderDefinition, DeviceId, SerialPortSettings
from reader_integration_kit.enum import ProtocolType
reader_def = ReaderDefinition(
DeviceId=DeviceId(VendorId=0x0C27, ProductId=0x3BFA),
ProtocolType=ProtocolType.FEATURE_REPORT,
SerialPortSettings=SerialPortSettings()
)
2. Connect and Initialize
- C++
- C#
- Python
// Create instance (retries up to 3 times on connection failure)
auto handle = AbstractReader::CreateReaderInstance(readerDef, 3);
auto* app = AbstractReader::GetInstance(handle);
// Initialize -- connects to the reader and populates metadata
app->Init();
// Constructor opens the connection; 'using' ensures cleanup
using var app = new Reader(readerDef, retryCount: 3);
app.Init();
# Context manager ensures cleanup
with Reader(reader_def, retry_count=3) as app:
app.init()
3. Read Metadata
- C++
- C#
- Python
auto metadata = app->GetMetadataStruct();
std::cout << "Part Number: " << metadata.PartNumber << std::endl;
std::cout << "Serial Number: " << metadata.SerialNumber << std::endl;
std::cout << "Firmware: " << metadata.FirmwareVersion << std::endl;
std::cout << "Product: " << metadata.Product << std::endl;
// Force refresh from device (bypasses cache)
auto fresh = app->GetMetadataStruct(true);
var metadata = app.GetMetadata();
Console.WriteLine($"Part Number: {metadata.PartNumber}");
Console.WriteLine($"Serial Number: {metadata.SerialNumber}");
Console.WriteLine($"Firmware: {metadata.FirmwareVersion}");
Console.WriteLine($"Product: {metadata.Product}");
// Force refresh
app.RefreshMetadata();
var fresh = app.GetMetadata(forceRefresh: true);
metadata = app.get_metadata()
print(f"Part Number: {metadata.get('PartNumber')}")
print(f"Serial Number: {metadata.get('SerialNumber')}")
print(f"Firmware: {metadata.get('FirmwareVersion')}")
print(f"Product: {metadata.get('Product')}")
# Force refresh
fresh = app.get_metadata(force_refresh=True)
4. Use Reader Features
- C++
- C#
- Python
auto* reader = dynamic_cast<Reader*>(app);
// Beep the reader
reader->Beep(2, RikProtocol::BEEP_DURATION_SHORT);
// Beeper volume
RikProtocol::BeepVolume volume;
reader->GetBeeperVolume(volume);
reader->SetBeeperVolume(RikProtocol::BEEP_VOLUME_HIGH);
// Card data
CardData cardData;
reader->GetCardData(cardData);
if (!cardData.IsEmpty()) {
std::cout << "Bits: " << cardData.GetBitCount() << std::endl;
}
// Beep the reader
app.Beep(2, BeepDuration.Short);
// Beeper volume
var volume = app.GetBeeperVolume();
app.SetBeeperVolume(BeepVolume.High);
// Card data
app.GetCardData(out var cardData);
if (!cardData.IsEmpty()) {
Console.WriteLine($"Card bits: {cardData.BitCount}");
Console.WriteLine($"Hex: {cardData.AsHexString()}");
}
from reader_integration_kit.enum import BeepDuration, BeepVolume
# Beep the reader
app.beep(2, BeepDuration.BEEP_DURATION_SHORT)
# Beeper volume
volume = app.get_beeper_volume()
app.set_beeper_volume(BeepVolume.BEEP_VOLUME_HIGH)
# Card data
card = app.get_card_data()
print(f"Bits: {card.bit_count}")
5. Clean Up
- C++
- C#
- Python
app->Close();
AbstractReader::DestroyInstance(handle);
// Automatic with 'using' statement, or manually:
app.Dispose();
# Automatic with 'with' statement, or manually:
app.dispose()
tip
In C# and Python, prefer using using / with statements for automatic cleanup instead of calling Dispose() / dispose() manually.
Complete Example
- C++
- C#
- Python
main.cpp
#include <iostream>
#include "Reader/AbstractReader.h"
#include "Reader/Reader.h"
int main() {
using namespace Rik;
using namespace RikCommon;
ReaderHandle handle = nullptr;
try {
ReaderDefinition readerDef{};
readerDef.DeviceId.VendorId = 0x0C27;
readerDef.DeviceId.ProductId = 0x3BFA;
readerDef.ProtocolType = PROTOCOL_TYPE_FEATURE_REPORT;
handle = AbstractReader::CreateReaderInstance(readerDef, 3);
auto* app = AbstractReader::GetInstance(handle);
app->Init();
auto metadata = app->GetMetadataStruct();
std::cout << "Part Number: " << metadata.PartNumber << std::endl;
auto* reader = dynamic_cast<Reader*>(app);
reader->Beep(2, RikProtocol::BEEP_DURATION_SHORT);
app->Close();
AbstractReader::DestroyInstance(handle);
return 0;
} catch (const ReaderException& e) {
std::cerr << "Error: " << e.Message << std::endl;
if (handle) AbstractReader::DestroyInstance(handle);
return 1;
}
}
Program.cs
using rfIDEAS.ReaderIntegrationKit;
using rfIDEAS.ReaderIntegrationKit.Objects;
using rfIDEAS.ReaderIntegrationKit.Enum;
try {
var readerDef = new ReaderDefinition {
DeviceId = new DeviceId { VendorId = 0x0C27, ProductId = 0x3BFA },
ProtocolType = ProtocolType.FeatureReport,
SerialPortSettings = new SerialPortSettings()
};
using var app = new Reader(readerDef, retryCount: 3);
app.Init();
var metadata = app.GetMetadata();
Console.WriteLine($"Part Number: {metadata.PartNumber}");
app.Beep(2, BeepDuration.Short);
} catch (ReaderException ex) {
Console.WriteLine($"Error: {ex.Message}");
}
main.py
from reader_integration_kit.facade import Reader
from reader_integration_kit.structures import ReaderDefinition, DeviceId, SerialPortSettings
from reader_integration_kit.enum import ProtocolType, BeepDuration
from reader_integration_kit.errors import ReaderException
try:
reader_def = ReaderDefinition(
DeviceId=DeviceId(VendorId=0x0C27, ProductId=0x3BFA),
ProtocolType=ProtocolType.FEATURE_REPORT,
SerialPortSettings=SerialPortSettings()
)
with Reader(reader_def, retry_count=3) as app:
app.init()
metadata = app.get_metadata()
print(f"Part Number: {metadata.get('PartNumber')}")
app.beep(2, BeepDuration.BEEP_DURATION_SHORT)
except ReaderException as e:
print(f"Error: {e}")
Next Steps
- Examples -- More code samples (configuration, LED, BLE, multi-reader)
- API Reference -- Full method documentation
- Supported Readers -- All compatible reader models