Fixes for new environment
This commit is contained in:
@@ -1 +1 @@
|
|||||||
ruby-1.9.3-p125
|
ruby-1.9.3-p484
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ GEM
|
|||||||
builder (3.0.4)
|
builder (3.0.4)
|
||||||
daemons (1.1.9)
|
daemons (1.1.9)
|
||||||
i18n (0.6.1)
|
i18n (0.6.1)
|
||||||
|
mail (2.6.1)
|
||||||
|
mime-types (>= 1.16, < 3)
|
||||||
|
mime-types (2.3)
|
||||||
multi_json (1.7.7)
|
multi_json (1.7.7)
|
||||||
mysql2 (0.3.11)
|
mysql2 (0.3.11)
|
||||||
rufus-scheduler (2.0.19)
|
rufus-scheduler (2.0.19)
|
||||||
@@ -30,6 +33,7 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
activerecord (= 3.2.13)
|
activerecord (= 3.2.13)
|
||||||
daemons
|
daemons
|
||||||
|
mail
|
||||||
mysql2
|
mysql2
|
||||||
rufus-scheduler
|
rufus-scheduler
|
||||||
serialport
|
serialport
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ class SearchingForSyncState < StatePattern::State
|
|||||||
# return
|
# return
|
||||||
return bytes[idx..-1] || ""
|
return bytes[idx..-1] || ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
class Synchronizer
|
class Synchronizer
|
||||||
include StatePattern
|
include StatePattern
|
||||||
|
|
||||||
SYNC_PATTERN = "\n/ISk5\\2ME382-1003\n\n"
|
SYNC_PATTERN = "\n/ISk5\\2ME382-1003\n\n"
|
||||||
|
|
||||||
set_initial_state SearchingForSyncState
|
set_initial_state ::SearchingForSyncState
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'rubygems'
|
#require 'rubygems'
|
||||||
require 'daemons'
|
require 'daemons'
|
||||||
|
|
||||||
pwd = Dir.pwd
|
pwd = Dir.pwd
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# load rvm ruby
|
# load rvm ruby
|
||||||
source /usr/local/rvm/environments/ruby-1.9.3-p125@smartmeter
|
source /usr/local/rvm/environments/ruby-1.9.3-p484@smartmeter
|
||||||
|
|
||||||
cd /mnt/usb/ruby/smartmeter
|
cd /home/pcog/smartmeter
|
||||||
ruby report_mailer.rb
|
ruby report_mailer.rb
|
||||||
|
|
||||||
|
|||||||
4
etc/smartmeter
Normal file → Executable file
4
etc/smartmeter
Normal file → Executable file
@@ -5,7 +5,9 @@
|
|||||||
# description: Starts Smartmeter as an unprivileged user.
|
# description: Starts Smartmeter as an unprivileged user.
|
||||||
#
|
#
|
||||||
|
|
||||||
sudo -u www-data ruby /mnt/usb/ruby/smartmeter/daemonize.rb $1
|
# Create a wrapper using 'rvm alias smartmeter ruby-1.9.3-p484@smartmeter'
|
||||||
|
|
||||||
|
sudo -u www-data /usr/local/rvm/wrappers/smartmeter/ruby /home/pcog/smartmeter/daemonize.rb $1
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require "rubygems"
|
#require "rubygems"
|
||||||
require "bundler/setup"
|
require "bundler/setup"
|
||||||
require "active_record"
|
require "active_record"
|
||||||
require "serialport"
|
require "serialport"
|
||||||
@@ -8,6 +8,7 @@ MAX_BYTES = 100
|
|||||||
|
|
||||||
project_root = File.dirname(File.absolute_path(__FILE__))
|
project_root = File.dirname(File.absolute_path(__FILE__))
|
||||||
Dir.glob(project_root + "/app/models/*.rb").each{|f| require f}
|
Dir.glob(project_root + "/app/models/*.rb").each{|f| require f}
|
||||||
|
Dir.glob(project_root + "/app/helpers/SearchingForSyncState.rb").each{|f| require f}
|
||||||
Dir.glob(project_root + "/app/helpers/*.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'))
|
connection_details = YAML::load(File.open('config/database.yml'))
|
||||||
@@ -16,7 +17,7 @@ ActiveRecord::Base.establish_connection(connection_details)
|
|||||||
def open_device
|
def open_device
|
||||||
begin
|
begin
|
||||||
# Open connection to serial port
|
# Open connection to serial port
|
||||||
io_device = SerialPort.new("/dev/ttyUSB1", 9600, 7, 1, SerialPort::EVEN)
|
io_device = SerialPort.new("/dev/ttyUSB0", 9600, 7, 1, SerialPort::EVEN)
|
||||||
# Make reading blocking
|
# Make reading blocking
|
||||||
io_device.read_timeout = 0
|
io_device.read_timeout = 0
|
||||||
rescue
|
rescue
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ require "state_pattern"
|
|||||||
|
|
||||||
project_root = File.dirname(File.absolute_path(__FILE__))
|
project_root = File.dirname(File.absolute_path(__FILE__))
|
||||||
Dir.glob(project_root + "/app/models/*.rb").each{|f| require f}
|
Dir.glob(project_root + "/app/models/*.rb").each{|f| require f}
|
||||||
|
Dir.glob(project_root + "/app/helpers/SearchingForSyncState.rb").each{|f| require f}
|
||||||
Dir.glob(project_root + "/app/helpers/*.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'))
|
connection_details = YAML::load(File.open('config/database.yml'))
|
||||||
@@ -16,7 +17,7 @@ ActiveRecord::Base.establish_connection(connection_details)
|
|||||||
if __FILE__ == $0
|
if __FILE__ == $0
|
||||||
|
|
||||||
#params for serial port
|
#params for serial port
|
||||||
port_str = "/dev/ttyUSB1" #may be different for you
|
port_str = "/dev/ttyUSB0" #may be different for you
|
||||||
baud_rate = 9600
|
baud_rate = 9600
|
||||||
data_bits = 7
|
data_bits = 7
|
||||||
stop_bits = 1
|
stop_bits = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user