escper 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/escper/asciifier.rb +3 -0
- data/lib/escper/printer.rb +6 -5
- data/lib/escper/version.rb +1 -1
- metadata +1 -1
data/lib/escper/asciifier.rb
CHANGED
@@ -30,6 +30,8 @@ module Escper
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def codepage_lookup(char)
|
33
|
+
return '*'.force_encoding('ASCII-8BIT') unless @codepage_lookup_yaml[@codepage]
|
34
|
+
|
33
35
|
output = @codepage_lookup_yaml[@codepage][char]
|
34
36
|
if output
|
35
37
|
output = output.chr
|
@@ -38,5 +40,6 @@ module Escper
|
|
38
40
|
end
|
39
41
|
return output.force_encoding('ASCII-8BIT')
|
40
42
|
end
|
43
|
+
|
41
44
|
end
|
42
45
|
end
|
data/lib/escper/printer.rb
CHANGED
@@ -86,6 +86,7 @@ module Escper
|
|
86
86
|
p = @vendor_printers[i]
|
87
87
|
name = p.name
|
88
88
|
path = p.path
|
89
|
+
codepage = p.codepage
|
89
90
|
if @mode != 'local' and SalorHospitality::Application::SH_DEBIAN_SITEID != 'none'
|
90
91
|
path = File.join('/', 'var', 'lib', 'salor-hospitality', SalorHospitality::Application::SH_DEBIAN_SITEID, 'public', 'uploads', "#{path}.salor")
|
91
92
|
end
|
@@ -93,7 +94,7 @@ module Escper
|
|
93
94
|
pid = p.id ? p.id : i
|
94
95
|
begin
|
95
96
|
printer = SerialPort.new path, 9600
|
96
|
-
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer }
|
97
|
+
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer, :codepage => codepage }
|
97
98
|
ActiveRecord::Base.logger.info "[PRINTING] Success for SerialPort: #{ printer.inspect }"
|
98
99
|
next
|
99
100
|
rescue Exception => e
|
@@ -102,7 +103,7 @@ module Escper
|
|
102
103
|
|
103
104
|
begin
|
104
105
|
printer = File.open path, 'wb'
|
105
|
-
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer }
|
106
|
+
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer, :codepage => codepage }
|
106
107
|
ActiveRecord::Base.logger.info "[PRINTING] Success for File: #{ printer.inspect }"
|
107
108
|
next
|
108
109
|
rescue Errno::EBUSY
|
@@ -113,7 +114,7 @@ module Escper
|
|
113
114
|
ActiveRecord::Base.logger.info "[PRINTING] Trying to reuse already opened File #{ key }: #{ val.inspect }"
|
114
115
|
if val[:path] == p[:path] and val[:device].class == File
|
115
116
|
ActiveRecord::Base.logger.info "[PRINTING] Reused."
|
116
|
-
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => val[:device] }
|
117
|
+
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => val[:device], :codepage => codepage }
|
117
118
|
break
|
118
119
|
end
|
119
120
|
end
|
@@ -124,7 +125,7 @@ module Escper
|
|
124
125
|
path = File.join('/', 'var', 'lib', 'salor-hospitality', SalorHospitality::Application::SH_DEBIAN_SITEID)
|
125
126
|
end
|
126
127
|
printer = File.open(File.join(path, "#{ p.id }-#{ name }-fallback-busy.salor"), 'wb')
|
127
|
-
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer }
|
128
|
+
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer, :codepage => codepage }
|
128
129
|
ActiveRecord::Base.logger.info "[PRINTING] Failed to open as either SerialPort or USB File and resource IS busy. This should not have happened. Created #{ printer.inspect } instead."
|
129
130
|
end
|
130
131
|
next
|
@@ -135,7 +136,7 @@ module Escper
|
|
135
136
|
path = File.join('/', 'var', 'lib', 'salor-hospitality', SalorHospitality::Application::SH_DEBIAN_SITEID)
|
136
137
|
end
|
137
138
|
printer = File.open(File.join(path, "#{ p.id }-#{ name }-fallback-notbusy.salor"), 'wb')
|
138
|
-
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer }
|
139
|
+
@open_printers.merge! pid => { :name => name, :path => path, :copies => p.copies, :device => printer, :codepage => codepage }
|
139
140
|
ActiveRecord::Base.logger.info "[PRINTING] Failed to open as either SerialPort or USB File and resource is NOT busy. Created #{ printer.inspect } instead."
|
140
141
|
end
|
141
142
|
end
|
data/lib/escper/version.rb
CHANGED