APPENDIX 1: Simulating an RFID Tag Reader
A1.1: Overview
The RFID tag reader can be replaced with anything that capable of the same
protocol. This technique is useful for development, debugging, and evaluation
purposes. For instance, not being required to have physical access to the
target hardware allowed me (the developer) to continue working on the
Smartshelf program after leaving the lab room.
The Smartshelf program supports communicating with the RFID tag reader (or an
emulation thereof) via a serial cable connected to the device or another
computer; a child process speaking the RFID protocol; or a previously-prepared
file descriptor, which, in Unix, can be connected to any sort of device at
all. This document will briefly cover using a serial connection to a separate
computer to emulate the RFID tag reader.
A1.2: Preparing the toolkit
Two computers are needed (each with an RS-232 serial port), one to run the
Smartshelf program and one to pretend to be the RFID tag reader. Failing that,
it's possible to use a single computer with two serial ports or even a Unix
socket or pipe pair, but that's not covered here.
A serial cable is necessary to connect the two computers. It must be a
crossed-over RS-232 serial cable, that is, each side's RX pin must connect to
the other side's TX pin, and the flow control pins should be appropriately
connected (or you can disable flow control in ss-hw/main.c). It's best to use
a ready-made male-to-male cable and a so-called null-modem adapter, but a
homemade cable can be produced using wiring diagrams readily available in other
texts and Internet resources. At a minimum this will require three wires.
Compiling the software requires GNU make, GNU bash, GNU gcc, and the other
assorted Unix tools bundled with GNU, all available with any decent GNU/Linux
distribution. Sqlite is also required; get it at .
One computer (`shelf') must have the Smartshelf software, in particular the
ss-hw program. For a more elaborate display, ss-core or even ss-gui can be
used. First, unpack the Smartshelf tar file using `tar' or your favorite
archiver program. Next, edit ss-hw/main.c to select the appropriate device
node for the serial port, which is typically /dev/ttyS0 (look for the
serial_init() line in the section "RFID tag reader"). Then type `make' to
build the requisite programs.
shelf$ bzip2 -c -d smartshelf-latest.tar.bz2 | tar xv
shelf$ cd smartshelf
shelf$ vim ss-hw/main.c # If necessary
shelf$ make
The other computer (`rfid') needs a serial port terminal emulation program. On
MS-Windows, HyperTerminal is popular (because it's bundled, not because it's
high-quality), and on other platforms Minicom is widely available. Unix
systems also allow direct usage of stty and redirections on /dev/ttyS0. If
desired, see the appropriate reference material for instructions on using the
above methods--- here I discuss using term.c, since it comes with the
Smartshelf archive. To build the term program from term.c, unpack and `make'
the Smartshelf tar file, as above. If necessary, edit CFG_LINE_DEV in
misc/term.c to select the correct device node (do this before `make').
rfid$ bzip2 -c -d smartshelf-latest.tar.bz2 | tar xv
rfid$ cd smartshelf
rfid$ vim misc/term.c # If necessary
rfid$ make
On `rfid', prepare some pregenerated packets to send over the serial cable.
They must be handy ahead of time to avoid problems with timeout expiry.
Generate packet.* from misc/packets as follows:
rfid$ i=1; while read line; do
> [ ${line:0:1} != \# ] || continue
> echo $line | misc/hex -r > packet.$i
> ((++i))
> done < misc/packets
See misc/README for information on the hex program, and see misc/packets for
the source data from which the packet.* files are generated.
A1.3: Performing the simulation
Make sure the computers are connected using the serial cable, and check that
the cable is plugged into the correct ports (the port labeled `COM1:' generally
corresponds to /dev/ttyS0). Log in to both `shelf' and `rfid'.
First, start the term program on `rfid', and enable hex mode with `~x'. Do
this from the same directory as the packet.* files generated above. Also note
that the user account must have read-write access to the serial device node.
If not, contact your system administrator.
rfid$ misc/term
~x
Term should say `Hex mode enabled' if all is well. Remember, to get online
help while using term, type `~?'. `~.' (not ctrl-C) quits the program.
Next, start ss-hw on `shelf'. It should immediately start sending data over
the serial cable to `rfid', which with luck will appear as hexadecimal digits.
shelf$ ss-hw/ss-hw
Quickly (or the 10-second watchdog timer will expire), use term on `rfid' to
send data packets to `shelf' in response to its first packet, which should be
an inventory query. Respond with one of packet.1, packet.2, packet.3, or
packet.4. See misc/packets to see which is which. Use the ~s term command to
send a file. Let's say you send packet.2. ss-hw should respond by querying
the data for the tag with uid 1111111111111111. So reply with either packet.5
(tag not found) or packet.6 (data is 00000001). Then, after a brief delay,
ss-hw (running on `shelf') will again perform an inventory, to which you can
respond with, say, packet.1 (no tags). As packets are sent, `rfid' should
output inventory updates to its terminal.
Below, < indicates a line that you type and * means the line was printed in
response. Beware, ~ commands don't appear as they are typed. The left column
indicates the host on which the line is typed or the output appears. For the
sake of brevity, status lines are omitted.
rfid$ misc/term <
~x <
shelf$ ss-hw/ss-hw <
rfid 07feb00100a74a *
~s packet.2 <
11feb0230111111111111111110001f4fa *
~s packet.6 <
shelf TAG-ADD 1111111111111111 00000001 *
rfid 07feb00100a74a *
~s packet.3 <
11feb0230122222222222222220001e935 *
~s packet.7 <
shelf TAG-ADD 2222222222222222 00000002 *
rfid 07feb00100a74a *
~s packet.1 <
shelf TAG-DEL 1111111111111111 *
rfid 07feb00100a74a *
~s packet.1 <
shelf TAG-DEL 2222222222222222 *
rfid ~. <
shelf [control-C] <
The above conversation tests the grace period feature of ss-hw. This explains
why the TAG-DEL lines only appear after `rfid' reports that a given tag is
missing over the course of two consecutive inventories.
Feel free to experiment using the other available packet.* files and the
remainder of the available protocol. See the references section for links to
more information about the protocol.
A1.4: References
- HF Reader System Series 6000: S6500/S6550 Configuration and Host
Protocol Reference Guide, TI-RFID document number 11-06-21-064
See this document for details about the protocol used by the RFID tag
reader. It will help illuminate the misc/packets file and the requests
generated by ss-hw.
- File : ss-hw/README
Man page: termios(3)
These documents explain how to adjust the serial port settings used by ss-hw
and term.
- Man page: bash(1)
This man page explains the while loop used above to generate packet.*.
- File: */README
There are many README's and TODO's and so on scattered throughout the
Smartshelf archive. They serve as a roadmap and commentary on the code.
A1.5: About this document
Version 1 of this document was written by Andy Goth
on May 10, 2004, to help give a sampling of the flexibility and functionality
of the ss-hw design. It should appear as an appendix on Zorica Majdov's paper,
"RFID Based Smart Kitchen Shelf". It is also available in the smartshelf
archive, found at . The latest version
should be in ,
which can be browsed online at .