millworker 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,10 @@
1
+ === 0.1.1 / 2012-09-18
2
+
3
+ * 1 bug fix:
4
+
5
+ * Serial port initialization updates for Windows 7
6
+
7
+
1
8
  === 1.0.0 / 2012-08-22
2
9
 
3
10
  * 1 major enhancement
data/README.md CHANGED
@@ -23,7 +23,7 @@ command terminal and typed `tweet_id.rb RFID_TAG_ID_HERE`.
23
23
 
24
24
  Install the millworker gem (see below for instructions).
25
25
 
26
- In order read from the correct port on your computer, we need to do a bit of
26
+ In order to read from the correct port on your computer, we need to do a bit of
27
27
  setup.
28
28
 
29
29
  ```bash
@@ -35,7 +35,10 @@ def config
35
35
  end
36
36
 
37
37
  def serial_port
38
- SerialPort.new(SERIAL_PORT || config[:serial_port])
38
+ return @serial_port unless @serial_port.nil?
39
+ @serial_port ||= SerialPort.new(SERIAL_PORT || config[:serial_port],{"baud" => 9600, "parity" => SerialPort::NONE, "data_bits" => 8})
40
+ @serial_port.read_timeout = 1000
41
+ @serial_port
39
42
  end
40
43
 
41
44
 
@@ -72,9 +75,11 @@ command :start do |c|
72
75
  c.switch :stdin, desc: 'Read input from STDIN (command line) instead of a serial port.'
73
76
 
74
77
  c.action do |g, options, args|
75
- Dante::Runner.new('millworker').execute(daemonize: !options[:stdin],
76
- pid_path: PID_PATH,
77
- log_path: DAEMON_LOG_PATH) {
78
+ runner = Dante::Runner.new('millworker')
79
+
80
+ runner.execute(daemonize: !options[:stdin],
81
+ pid_path: PID_PATH,
82
+ log_path: DAEMON_LOG_PATH) {
78
83
 
79
84
  FileUtils.mkdir_p(LOG_DIR) unless File.directory?(LOG_DIR)
80
85
  logger = Logger.new(LOG_PATH)
@@ -83,27 +88,30 @@ command :start do |c|
83
88
 
84
89
  loop do
85
90
  data = input.gets
86
-
87
- unless data.nil? || data.empty?
88
- data.strip! # Take off newline from serial read
89
-
90
- logger.info "received: '#{data.chomp}'"
91
-
92
- # Read task list in every time so the daemon does not need to be
93
- # restarted after changes
94
- tasks = Dir["#{TASKS_DIR}/*"]
95
-
96
- if tasks.empty?
97
- logger.warn "No tasks to execute in '#{TASKS_DIR}'. Skipping."
98
- next
99
- else
100
- tasks.each do |task|
101
- command = "#{task} #{data}"
102
-
103
- execute(command) { |result|
104
- logger.info("executed: '#{command}', result: #{result}")
105
- }
106
- end
91
+ next if data.nil? || data.empty?
92
+
93
+ # Take off newline from serial read
94
+ data.strip!
95
+ logger.info "received: '#{data.inspect}'"
96
+
97
+ # Take off start & end of text unicode characters
98
+ rfid_id = data.slice(/\u0002(.*)\u0003/, 1)
99
+ next if rfid_id.nil?
100
+
101
+ # Read task list in every time so the daemon does not need to be
102
+ # restarted after changes
103
+ tasks = Dir["#{TASKS_DIR}/*"]
104
+
105
+ if tasks.empty?
106
+ logger.warn "No tasks to execute in '#{TASKS_DIR}'. Skipping."
107
+ next
108
+ else
109
+ tasks.each do |task|
110
+ command = "#{task} #{data}"
111
+
112
+ execute(command) { |result|
113
+ logger.info("executed: '#{command}', result: #{result}")
114
+ }
107
115
  end
108
116
  end
109
117
  end
@@ -1,3 +1,3 @@
1
1
  module Millworker
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: millworker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  L1dHTHNEVk9tZ0orZzR4b09pQ2U5WkVrZGE4SytsL0YKeVhXcUluUmxGSWxU
37
37
  dXdGVHhqMjZqYXVCb3NrQlBvejViZmtaRmphVlJoeVVuUm5Ha2E2Nmx2Y0RP
38
38
  R2ZrUlpXUQpOVkFESkE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2012-09-10 00:00:00.000000000 Z
39
+ date: 2012-09-19 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gli
metadata.gz.sig CHANGED
Binary file