Update gmail.rb, enable starting of start file
parent
1273e5fd6f
commit
e0d87f3c60
10
src/gmail.rb
10
src/gmail.rb
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/env ruby
|
#!/bin/env ruby
|
||||||
|
|
||||||
#Check if operating being used it Linux-based
|
#Check if operating system being used it Linux-based
|
||||||
unless /linux/ =~ RUBY_PLATFORM then
|
unless /linux/ =~ RUBY_PLATFORM then
|
||||||
puts "ERROR: Only Linux-based operating systems are currently supported"
|
puts "ERROR: Only Linux-based operating systems are currently supported"
|
||||||
exit
|
exit
|
||||||
|
@ -28,9 +28,9 @@ end
|
||||||
@serial_connection = String.new
|
@serial_connection = String.new
|
||||||
|
|
||||||
#Start the bash file, read the file it creates and find out what port the Arduino is connected to
|
#Start the bash file, read the file it creates and find out what port the Arduino is connected to
|
||||||
system("bash #{File.dirname(__FILE__)}/detect_serial.sh > serial")
|
system("bash #{File.dirname(__FILE__)}/detect_serial.sh > #{File.dirname(__FILE__)}/serial")
|
||||||
File.open("#{File.dirname(__FILE__)}/serial").each_line do |line|
|
File.open("#{File.dirname(__FILE__)}/serial").each_line do |line|
|
||||||
@serial_connection = line.slice(0..(line.index(' '))) if line.include?("Arduino")
|
@serial_connection = line.slice(0..(line.index(' '))).gsub(' ', '') if line.include?("Arduino")
|
||||||
end
|
end
|
||||||
|
|
||||||
#Gmail username and password
|
#Gmail username and password
|
||||||
|
@ -57,7 +57,7 @@ unless @serial_connection.size > 0
|
||||||
else
|
else
|
||||||
puts "SUCCESS: ".colorize(:green) + "Arduino has been found"
|
puts "SUCCESS: ".colorize(:green) + "Arduino has been found"
|
||||||
puts "Arduino is connected to: #{@serial_connection}"
|
puts "Arduino is connected to: #{@serial_connection}"
|
||||||
port_file = @serial_connection.gsub(' ', '')
|
port_file = @serial_connection
|
||||||
end
|
end
|
||||||
|
|
||||||
#this must be same as the baud rate set on the Arduino
|
#this must be same as the baud rate set on the Arduino
|
||||||
|
@ -87,6 +87,8 @@ loop do
|
||||||
|
|
||||||
#For debugging purposes
|
#For debugging purposes
|
||||||
puts "Received email: \n" + gmail.inbox.find(:unread).last.subject
|
puts "Received email: \n" + gmail.inbox.find(:unread).last.subject
|
||||||
|
|
||||||
|
puts "Checking emails ..."
|
||||||
end
|
end
|
||||||
|
|
||||||
#reset the number of unread emails
|
#reset the number of unread emails
|
||||||
|
|
Loading…
Reference in New Issue