#!/usr/bin/env ruby require 'rubygems' require 'applix' $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'rfid-usb-gom-sensor' #Thread.abort_on_exception = true $stderr.sync = true $stdout.sync = true class Usage < ArgumentError; end def main argv options = Hash.from_argv argv args = (options.delete :args) #options[:callback_port] ||= 32119 sensor_url = args.shift sensor_url or (raise Usage, "no ") puts " -- starting RFID sensor: #{Time.now}" daemon = Gom::Remote::Daemon.new(sensor_url, options) do |daemon, _| daemon.check_in end sensor = RfidUsbGomSensor::Node.new daemon.service_path, options sensor.preroll daemon.forever { sensor.detect } rescue Usage => e puts <<-TXT usage: #{__FILE__} ## #{e} TXT rescue => e puts " ## #{e}\n -> #{e.backtrace.join "\n "}" end main ARGV # vim: syntax=ruby