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)
|
||||
daemons (1.1.9)
|
||||
i18n (0.6.1)
|
||||
mail (2.6.1)
|
||||
mime-types (>= 1.16, < 3)
|
||||
mime-types (2.3)
|
||||
multi_json (1.7.7)
|
||||
mysql2 (0.3.11)
|
||||
rufus-scheduler (2.0.19)
|
||||
@@ -30,6 +33,7 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
activerecord (= 3.2.13)
|
||||
daemons
|
||||
mail
|
||||
mysql2
|
||||
rufus-scheduler
|
||||
serialport
|
||||
|
||||
@@ -10,4 +10,4 @@ class SearchingForSyncState < StatePattern::State
|
||||
# return
|
||||
return bytes[idx..-1] || ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Synchronizer
|
||||
include StatePattern
|
||||
include StatePattern
|
||||
|
||||
SYNC_PATTERN = "\n/ISk5\\2ME382-1003\n\n"
|
||||
|
||||
set_initial_state SearchingForSyncState
|
||||
set_initial_state ::SearchingForSyncState
|
||||
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rubygems'
|
||||
#require 'rubygems'
|
||||
require 'daemons'
|
||||
|
||||
pwd = Dir.pwd
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
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.
|
||||
#
|
||||
|
||||
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=$?
|
||||
|
||||
exit $RETVAL
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require "rubygems"
|
||||
#require "rubygems"
|
||||
require "bundler/setup"
|
||||
require "active_record"
|
||||
require "serialport"
|
||||
@@ -8,6 +8,7 @@ MAX_BYTES = 100
|
||||
|
||||
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/SearchingForSyncState.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'))
|
||||
@@ -16,7 +17,7 @@ ActiveRecord::Base.establish_connection(connection_details)
|
||||
def open_device
|
||||
begin
|
||||
# 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
|
||||
io_device.read_timeout = 0
|
||||
rescue
|
||||
|
||||
@@ -7,6 +7,7 @@ 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/SearchingForSyncState.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'))
|
||||
@@ -16,7 +17,7 @@ ActiveRecord::Base.establish_connection(connection_details)
|
||||
if __FILE__ == $0
|
||||
|
||||
#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
|
||||
data_bits = 7
|
||||
stop_bits = 1
|
||||
|
||||
Reference in New Issue
Block a user