Class: Extface::Driver::StarTsp200
- Inherits:
-
GenericPos
- Object
- ActiveRecord::Base
- Extface::Driver
- GenericPos
- Extface::Driver::StarTsp200
- Defined in:
- app/models/extface/driver/star_tsp200.rb
Direct Known Subclasses
Constant Summary collapse
- NAME =
'Star TSP200 (Base Receipt Protocol)'.freeze
- GROUP =
Extface::PRINT_DRIVER
- DEVELOPMENT =
driver is not ready for production (not passing all tests or has major bugs)
true
- RAW =
Select driver features
true
- PRINT =
responds to #push(data) and #pull
true
- FISCAL =
POS, slip printers
false
- REPORT =
cash registers, fiscal printers
false
Constants inherited from Extface::Driver
Instance Method Summary collapse
- #autocut(partial = true) ⇒ Object
- #check_status ⇒ Object
- #handle(buffer) ⇒ Object
- #human_status_errors(status_byte) ⇒ Object
Methods inherited from GenericPos
Methods inherited from Extface::Driver
#flush, has_serial_config, #notify, #pre_handle, #pull, #push, #rpush, #serial?, #set_job
Instance Method Details
#autocut(partial = true) ⇒ Object
22 23 24 25 26 27 |
# File 'app/models/extface/driver/star_tsp200.rb', line 22 def autocut(partial = true) # <ESC> “d” “0” - Full-cut command # <ESC> “d” “1” - Partial-cut command push "\r\n\r\n\r\n" push partial ? "\x1B\x64\x31" : "\x1B\x64\x30" end |
#check_status ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/extface/driver/star_tsp200.rb', line 29 def check_status flush push "\x05" # <ENQ> - Causes the printer to transmit a status byte if status = pull(3) #wait 3 sec for data human_status_errors(status) return errors.empty? else errors.add :base, "No data received from device" return false end end |
#handle(buffer) ⇒ Object
16 17 18 19 20 |
# File 'app/models/extface/driver/star_tsp200.rb', line 16 def handle(buffer) #expecting only 1 status byte, move it to receive_buffer rpush buffer return buffer.length # return number of bytes processed end |
#human_status_errors(status_byte) ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/models/extface/driver/star_tsp200.rb', line 41 def human_status_errors(status_byte) errors.add :base, "Vertical parity error" unless (status_byte.ord & 0x01).zero? errors.add :base, "Framing error" unless (status_byte.ord & 0x02).zero? errors.add :base, "Mechanical error" unless (status_byte.ord & 0x04).zero? errors.add :base, "Receipt paper empty" unless (status_byte.ord & 0x08).zero? errors.add :base, "Buffer overflow" unless (status_byte.ord & 0x40).zero? end |