require 'rubygems' require 'serialport' #require 'rest_fs/client' sp=SerialPort.new "/dev/ttyUSB0", 9600 #r=RestFs::Client.new info=[0x02, 0x01, 0x47, 0x46, 0x03] info.each {|c| sp.putc c.to_i} 2.times {sp.getc} print "Detected reader: " 37.times {putc(sp.getc)} print "\n" 6.times {sp.getc} continuous=[0x02, 0x01, 0x43, 0x04, 0x46, 0x03] continuous.each {|c| sp.putc c.to_i} 6.times {sp.getc} while true 2.times {sp.getc} v=0 0.upto(7) do |i| v+=sp.getc*2**((7-i)*8) end print "Detected tag: ", v, "\n" #r.create!("/sensors/rfid-readers/usb/tags/#{v}") 3.times {sp.getc} end