29 lines
791 B
Ruby
29 lines
791 B
Ruby
require "rubygems"
|
|
require "bundler/setup"
|
|
require "active_record"
|
|
require "serialport"
|
|
require "state_pattern"
|
|
|
|
project_root = File.dirname(File.absolute_path(__FILE__))
|
|
Dir.glob(project_root + "/app/models/*.rb").each{|f| require f}
|
|
Dir.glob(project_root + "/app/helpers/*.rb").each{|f| require f}
|
|
|
|
connection_details = YAML::load(File.open('config/database.yml'))
|
|
ActiveRecord::Base.establish_connection(connection_details)
|
|
|
|
# # Open connection to serial port
|
|
# ser = SerialPort.new("/dev/ttyUSB1", 9600, 7, 1, SerialPort::EVEN)
|
|
#
|
|
# # read until newline
|
|
# response = ser.readline("\r")
|
|
# response.chomp!
|
|
# print "#{response}\n"
|
|
|
|
sync = Synchronizer.new
|
|
lines = File.read("example_blurp.txt")[rand(500)..-1]
|
|
while (lines.length > 0)
|
|
lines = sync.handle_byte_stream(lines)
|
|
end
|
|
|
|
p sync
|