It can be useful to write code which uses RShell commands to configure the reader, essentially Telnet scripting. Below is an example in C# which opens a socket connection to the Speedway Revolution RFID reader and utilizes the CLI.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
namespace RshellScripting
{
class Program
{
static Socket socket;
static void Main(string[] args)
{
int count;
string str;
byte[] buffer = new byte[1024];
// Replace READER_HOSTNAME with your reader's host name or IP address
const string READER_HOSTNAME = "SpeedwayR-10-27-DA.local";
try
{
// Create a new socket
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
// Get the IP address of the reader by hostname
IPAddress[] ip = Dns.GetHostAddresses(READER_HOSTNAME);
// Create an IP endpoint using the IP address
IPEndPoint ep = new IPEndPoint(ip[0], 23);
// Connect to the telnet socket on the reader
socket.Connect(ep);
// Wait for the login prompt
str = "";
while (!str.Contains("login:"))
{
count = socket.Receive(buffer);
str = System.Text.Encoding.ASCII.GetString(buffer);
}
// Send the user name
socket.Send(Encoding.UTF8.GetBytes("root\n"));
// Wait for the password prompt
str = "";
while (!str.Contains("Password:"))
{
count = socket.Receive(buffer);
str = System.Text.Encoding.ASCII.GetString(buffer);
}
// Send the password
socket.Send(Encoding.UTF8.GetBytes("impinj\n"));
// Wait for the RShell prompt
str = "";
while (!str.Contains(">"))
{
count = socket.Receive(buffer);
str = System.Text.Encoding.ASCII.GetString(buffer);
}
// Send an RShell command
socket.Send(Encoding.UTF8.GetBytes("show image summary\n"));
// Read the reply
// The first reply is just an echo of our command "show image summary"
// Ignore it
count = socket.Receive(buffer);
// The second reply is the data we want (the result of the command)
count = socket.Receive(buffer);
Console.WriteLine(System.Text.Encoding.ASCII.GetString(buffer,0,count));
}
catch (SocketException ex)
{
Console.WriteLine("A socket exception occurred : " + ex.Message);
}
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}Impinj partners can download the RShell Reference Manual from this support portal link (login required).