smartware 0.1.30 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,64 +0,0 @@
1
- # coding: utf-8
2
- #
3
- # Custom tg2480h printer functions
4
- #
5
-
6
- require 'serialport'
7
-
8
- module Smartware
9
- module Driver
10
- module Printer
11
-
12
- class TG24XX
13
-
14
- def initialize(port)
15
- @sp = SerialPort.new(port, 115200, 8, 1, SerialPort::NONE)
16
- @sp.read_timeout = 100
17
- end
18
-
19
- def error
20
- res = send "\x1Dr1"
21
- return "1" unless res # No answer
22
- return "" if res == "0" # No error
23
- return "2" if res == "f" # Paper not present
24
- return "3" if res == "3" # Paper near end
25
- rescue
26
- -1
27
- end
28
-
29
- def model
30
- model_code = send "\x1DI1"
31
- model_name = case model_code
32
- when "a7" then 'Custom TG2460H'
33
- when "a8" then 'Custom TG2480H'
34
- when "ac" then 'Custom TL80'
35
- when "ad" then 'Custom TL60'
36
- else 'Unknown printer'
37
- end
38
- model_name
39
- rescue
40
- -1
41
- end
42
-
43
- def version
44
- send "\x1DI3", false
45
- end
46
-
47
- private
48
- def send(message, parse_answer = true)
49
- @sp.write message
50
- ans = @sp.gets
51
- if ans
52
- parse_answer ? res = ans.unpack("C*").map{|e| e.to_s(16) } : res = ans
53
- else
54
- res = nil
55
- end
56
- res.is_a?(Array) ? res[0] : res
57
- end
58
-
59
- end
60
-
61
- end
62
- end
63
- end
64
-