require 'rubygems'
require 'serialport'
require 'time'

SerialPorts = ['/dev/ttyACM0', '/dev/ttyACM1']

sp = nil

SerialPorts.each do |filename|
  break if sp
  begin
    sp = SerialPort.new filename, 57600, 8, 1, SerialPort::NONE
  rescue Exception => e
    puts e.to_s
  end
end

unless sp
  puts "Did you connect Arduino?"
  exit
end

while true
  sp.write("T#{Time.now.to_i+60*60}") if sp.getc == 7
end

