Programming NUR With
Programming NUR With
NET languages
Contents
Contents ............................................................................................................................................................. 2
Overview ............................................................................................................................................................ 3
1.1 NurApi .NET ....................................................................................................................................... 3
1.1.1 Hello NUR Module ...................................................................................................................... 4
2 Setting up programming environment ....................................................................................................... 5
2.1.1 Needed equipment ....................................................................................................................... 5
2.1.2 Running sample program ............................................................................................................. 5
2.1.3 Creating Visual Studio project ..................................................................................................... 6
3 Programming guidelines ............................................................................................................................ 7
3.1 Exception handling.............................................................................................................................. 7
3.2 Events .................................................................................................................................................. 8
4 Connection setup ........................................................................................................................................ 9
4.1 Serial port ............................................................................................................................................ 9
5 Settings ..................................................................................................................................................... 10
6 Reading RFID tags ................................................................................................................................... 11
6.1.1 Simple Inventory........................................................................................................................ 11
6.1.2 Inventory Stream ........................................................................................................................ 12
7 Support ..................................................................................................................................................... 12
Nordic ID
International Headquarters 2
Page 2 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
Overview
NUR-05W is a compact UHF RFID reader/writer module. Its small footprint, SMD, low power consumption and
high RF output makes it an outstanding choice for everything from simple mobile readers to port readers with
multiple antennas.
NUR-05W is compatible with the EPC C1G2 (ISO18000-6C) standard. The module meets the requirements of
ETSI, FCC and IC radio regulations. NUR-05W is also compatible with the DRM (dense reader mode)
requirements.
This document describes how to create .NET applications for NUR module. Code samples are collected to SDK
packet and Visual Studio 2005 solution file is located in ../Samples/SimpleDotNetSamples folder.
If you are using newer version of Visual Studio than 2005, you can convert it to newer one.
Sample code offers examples of most used functionalities like “Inventory” in Visual Basic and C#.
NUR API .NET consist easy-to-use functionalities for creating sophisticate RFID applications for NUR module.
Nordic ID
International Headquarters 3
Page 3 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
Code: (VB)
Imports NurApiDotNet
'Hello NUR is simple sample which connects to Sampo S1 reader via USB and acquire reader
information and shows it in the ListBox.
'------------------------------------------
'Guidelines creating NurApiDotNet projects:
'-Add reference to NurApiDotNet.dll
'-Set target platform to x86
'-NURAPI.dll must be in same folder than executable. Add it in your project and set
property "Copy to Output directory" to "Copy always"
'-Use NurApi commands inside Try...Catch structure. See NurApi documentation which
methods throws exceptions.
'When NUR module connected via USB, this function finds it and connects
automagically...
hNur.SetUsbAutoConnect(True)
Nordic ID
International Headquarters 4
Page 4 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
Nordic ID
International Headquarters 5
Page 5 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
Follow steps below to create Visual Studio project for programming NUR module applications.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NurApiDotNet; //Need to use namespace of NurApiDotNet
namespace Inventory
{
public partial class Form1 : Form
{
NurApi hNur = null;
public Form1()
{
InitializeComponent();
Nordic ID
International Headquarters 6
Page 6 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
3 Programming guidelines
Most of NurApi .NET methods throw exception for error handling. It is important to use NurApi methods always
inside Try Catch structure and handle exceptions properly.
Example:
Try
tags = hNur.GetTagStorage()
For Each tag In tags
ListBox1.Items.Add(tag.GetEpcString())
Next
If e.data.stopped Then
'Start again if stopped
hNur.StartInventoryStream()
End If
hNur.ClearTags() 'Clear NUR memory as well
Catch ex As Exception
'Error. Handle exception
ListBox1.Items.Add(ex.Message)
End Try
Nordic ID
International Headquarters 7
Page 7 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
3.2 Events
NurAPI .NET provides notifications when Nur module has something to say for application. One of these kinds
of event is ConnectedEvent indicating that NUR module is connected successfully to application via selected
transport.
Example:
In Windows Form application, it is forbidden to call windows control methods inside event handler because
control is accessed from a thread other than the thread it was created on.
To make thread-safe calls to Windows Forms controls in NurApi event handlers, add following line in to
program initialization:
(VB)
hNur.SetNotificationReceiver(Me)
(C#)
hNur.SetNotificationReceiver(this);
Nordic ID
International Headquarters 8
Page 8 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
4 Connection setup
NUR Sampo or Evaluation kit can connected to PC via mini USB connector.
NurApi looking for correct USB device continuously and launches ConnectedEvent when found.
If USB cable removed out, DisconnectEvent launches.
NUR module is provided with TTL level serial port. Default serial communication parameters are 115200,8,n,1
No flow control.
Nordic ID
International Headquarters 9
Page 9 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
5 Settings
NUR module can be configured for various usage purposes. One of most important settings is Tx-level for
adjusting reading distance which may need to adjust many times during application running. Settings like
Region, Tx-modulation, Link frequency and Rx Decoding are usually needed to set once.
Refer to NUR Implementation guide for more information about module settings.
Refer sample VB_Sample_VS2010 for example code of module settings. (Visual Basic)
Nordic ID
International Headquarters 10
Page 10 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
Simple inventory performs one Inventory process and returns tags found.
Refer to “SimpleInventory_VB” and “SimpleInventory_CSharp” applications for details.
Catch ex As Exception
'Something went wrong.(usually transport not connected) Show reason in
the MessageBox.
MessageBox.Show(ex.ToString(), "Exception")
End Try
Nordic ID
International Headquarters 11
Page 11 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com
2011-01-03
NUR API
Ver 1.0
In inventory stream, NUR module continuously reading tags and provides reading result to TagStorage.
Refer to “InventoryStream_VB” and “InventoryStream_CSharp” sample applications for details.
Starting InventoryStream:
StartInventoryStream()
Nur module starts continuously reading tags. InventoryStream event notifies when data is available.
Try
For Each tag In hNur.GetTagStorage()
If tags.AddTag(tag) Then
'New unique tag added
ListBox1.Items.Add(tag.GetEpcString())
End If
Next
'Clear NurApi internal tag storage
hNur.ClearTags()
If e.data.stopped Then
'Start again if stopped
hNur.StartInventoryStream()
End If
Catch ex As Exception
'Error. Handle exception
ListBox1.Items.Add(ex.Message)
End Try
End Sub
StopInventoryStream()
7 Support
support@nordicid.com
Nordic ID
International Headquarters 12
Page 12 / 12
Myllyojankatu 2 A, 24100 Salo, Finland
www.nordicid.com