millworker

DESCRIPTION:

A Ruby gem which takes the pain of continuously reading data from a serial port away and lets you focus on dealing with the data received.

This was written specifically for reading in data from an ID-20 RFID card reader and running custom scripts to automatically perform various tasks when patrons scanned their badge at the MN Mill (logging attendance, etc).

Custom scripts are loaded from ENV["HOME"]/millworker/tasks and are executed in alphabetical order. Each script is executed with the ID of the badge passed in as an argument. For example, a script called tweet_id.rb existed in the afformentioned directory, it would be executed as if you had opened up a command terminal and typed tweet_id.rb RFID_TAG_ID_HERE.

SYNOPSIS:

Install the millworker gem (see below for instructions).

In order to read from the correct port on your computer, we need to do a bit of setup.

millworker setup
#...you will be prompted for the name of the serial port

Provided you keep the device connected to the same port, you should only have to run this one time. In the event that things stop working for some odd reason, you can re-run this as many times as necessary to overwrite and/or verify your settings.

Next, start the worker by issuing the following command

millworker start

Each time the reader receives a card, an entry in the logfile is written, which includes a timestamp and the data which was read over the serial port. After logging this information, each script located in the millworker/scripts directory is executed with the received data passed in as an argument.

You can stop the worker any time by issuing the following command:

millworker stop

REQUIREMENTS:

  • Ruby 1.9.3+
  • Please refer to the Gemfile for gem dependencies.

INSTALL:

From the command line:

gem install millworker

UNINSTALL:

From the command line:

gem uninstall millworker

Note: You may also want to removes the entire ENV['HOME']/millworker directory. This is not done automatically to prevent accidental data loss.

LICENSE:

See the LICENSE file (hint: MIT)