I'm new to Ruby and need to take 10 character rfid token serial data (from arduino & parallax rfid reader) and convert it to a string. It doesn't look like anything is being added to string. I am getting the rfid token data in the terminal window when I scan the token if that helps.
require 'rubygems'
require 'serialport'
#params for serial port
port_str = "/dev/tty.usbserial-A4000ORO"
baud_rate = 2400
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
rfid_token = String.new
while true do
sp_char = sp.getc
rfid_token[0] = sp_char
if sp_char
printf("%c", sp_char)
end
if rfid_token.size == 10
puts "full token"
end
end
puts rfid_token