smartware 0.1.25 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,7 +28,6 @@ module Smartware
28
28
 
29
29
  def model
30
30
  model_code = send "\x1DI1"
31
- rom_version = send "\x1DI3", false
32
31
  model_name = case model_code
33
32
  when "a7" then 'Custom TG2460H'
34
33
  when "a8" then 'Custom TG2480H'
@@ -36,11 +35,15 @@ module Smartware
36
35
  when "ad" then 'Custom TL60'
37
36
  else 'Unknown printer'
38
37
  end
39
- "#{model_name}, ROM v#{rom_version}"
38
+ model_name
40
39
  rescue
41
40
  -1
42
41
  end
43
42
 
43
+ def version
44
+ send "\x1DI3", false
45
+ end
46
+
44
47
  private
45
48
  def send(message, parse_answer = true)
46
49
  @sp.write message
@@ -19,6 +19,7 @@ module Smartware
19
19
  @configured = true
20
20
  rescue => e
21
21
  @configured = false
22
+ Smartware::Logging.logger.error "Printer initialization failed: #{e.to_s}"
22
23
  end
23
24
 
24
25
  def self.configured?
@@ -49,20 +50,20 @@ module Smartware
49
50
  def self.start_monitor!
50
51
  t = Thread.new do
51
52
  loop do
52
- if @queue.empty?
53
- @status[:error] = @device.error || ''
54
- @status[:model] = @device.model
55
- @status[:version] = @device.version
56
- else
57
- begin
58
- `lpr #{@queue[0]}`
59
- Smartware::Logging.logger.info "Printed #{@queue[0]}"
60
- @queue.shift
61
- sleep 5
62
- rescue => e
63
- Smartware::Logging.logger.error e.message
64
- Smartware::Logging.logger.error e.backtrace.join("\n")
53
+ begin
54
+ if @queue.empty?
55
+ @status[:error] = @device.error || ''
56
+ @status[:model] = @device.model
57
+ @status[:version] = @device.version
58
+ else
59
+ `lpr #{@queue[0]}`
60
+ Smartware::Logging.logger.info "Printed #{@queue[0]}"
61
+ @queue.shift
62
+ sleep 5
65
63
  end
64
+ rescue => e
65
+ Smartware::Logging.logger.error e.message
66
+ Smartware::Logging.logger.error e.backtrace.join("\n")
66
67
  end
67
68
  sleep 0.2
68
69
  end
@@ -68,8 +68,7 @@ module Smartware
68
68
  begin
69
69
  loop do
70
70
  pid = Process.wait(-1, Process::WNOHANG)
71
-
72
- break if pid == 0
71
+ break if pid.nil?
73
72
 
74
73
  pids << pid
75
74
  end
@@ -1,3 +1,3 @@
1
1
  module Smartware
2
- VERSION = "0.1.25"
2
+ VERSION = "0.1.26"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: