├── tests ├── __init__.py ├── stoqdrivers-inverteddrawer.conf ├── data │ ├── image.png │ ├── elgin-I9-init.txt │ ├── sweda-SI300-init.txt │ ├── sweda-SI300-open-drawer.txt │ ├── sweda-SI300-check-drawer.txt │ ├── elgin-I9-open-drawer.txt │ ├── elgin-I9-print.txt │ ├── bematech-MP2100TH-init.txt │ ├── elgin-I9-cut.txt │ ├── sweda-SI300-print.txt │ ├── elgin-I9-check-drawer.txt │ ├── elgin-I9-print-inline.txt │ ├── sweda-SI300-cut.txt │ ├── sweda-SI300-print-inline.txt │ ├── bematech-MP2100TH-cut.txt │ ├── bematech-MP2100TH-open-drawer.txt │ ├── bematech-MP2100TH-print.txt │ ├── elgin-I9-init-conditions.txt │ ├── bematech-MP2100TH-print-inline.txt │ ├── sweda-SI300-init-conditions.txt │ ├── dataregis-EP375-till-add-cash.txt │ ├── elgin-I9-bold.txt │ ├── sweda-SI300-bold.txt │ ├── bematech-MP2100TH-check-drawer.txt │ ├── dataregis-EP375-till-remove-cash.txt │ ├── elgin-I9-condensed.txt │ ├── bematech-MP2100TH-init-conditions.txt │ ├── bematech-MP2100TH-bold.txt │ ├── elgin-I9-double-height.txt │ ├── sweda-SI300-condensed.txt │ ├── elgin-I9-centralize.txt │ ├── sweda-SI300-double-height.txt │ ├── sweda-SI300-centralize.txt │ ├── bematech-MP2100TH-condensed.txt │ ├── bematech-MP2100TH-double-height.txt │ ├── bematech-MP2100TH-centralize.txt │ ├── elgin-I9-qrcode.txt │ ├── sweda-SI300-qrcode.txt │ ├── bematech-MP2100TH-barcode.txt │ ├── dataregis-EP375-coupon-open.txt │ ├── elgin-I9-barcode.txt │ ├── sweda-SI300-barcode.txt │ ├── dataregis-EP375-cancel-coupon.txt │ ├── dataregis-EP375-totalize.txt │ ├── dataregis-EP375-add-payment.txt │ ├── dataregis-EP375-close-coupon.txt │ ├── dataregis-EP375-add-item.txt │ ├── dataregis-EP375-cancel-item.txt │ ├── bematech-MP2100TH-qrcode.txt │ ├── daruma-FS2100-summarize.txt │ ├── daruma-FS2100-read-memory.txt │ ├── daruma-FS2100-read-memory-by-reductions.txt │ ├── daruma-FS2100-till-add-cash.txt │ ├── daruma-FS2100-till-remove-cash.txt │ ├── daruma-FS345-summarize.txt │ ├── daruma-FS345-read-memory.txt │ ├── daruma-FS345-read-memory-by-reductions.txt │ ├── daruma-FS345-till-remove-cash.txt │ ├── daruma-FS345-till-add-cash.txt │ ├── daruma-FS2100-coupon-open.txt │ ├── epson-FBIII-summarize.txt │ ├── epson-FBIII-read-memory-by-reductions.txt │ ├── daruma-FS2100-cancel-coupon.txt │ ├── epson-FBIII-read-memory.txt │ ├── daruma-FS345-coupon-open.txt │ ├── daruma-FS345-cancel-coupon.txt │ ├── daruma-FS2100-has-open-coupon.txt │ ├── epson-FBIII-till-add-cash.txt │ ├── epson-FBIII-till-remove-cash.txt │ ├── daruma-FS345-has-open-coupon.txt │ ├── daruma-FS2100-gerencial-report.txt │ ├── epson-FBIII-has-open-coupon.txt │ ├── daruma-FS345-gerencial-report.txt │ ├── epson-FBIII-coupon-open.txt │ ├── epson-FBIII-cancel-coupon.txt │ ├── epson-FBIII-totalize.txt │ ├── daruma-FS2100-sintegra.txt │ ├── epson-FBIII-add-payment.txt │ └── daruma-FS345-sintegra.txt ├── test_stoqdrivers.py ├── test_utils.py └── check_ifaces_impl.py ├── debian ├── compat ├── clean ├── pydist-overrides ├── watch ├── rules ├── copyright └── control ├── stoqdrivers ├── devices │ └── __init__.py ├── printers │ ├── __init__.py │ ├── elgin │ │ ├── __init__.py │ │ ├── KFiscal.py │ │ └── I9.py │ ├── epson │ │ ├── __init__.py │ │ ├── TMT70.py │ │ ├── TMT20.py │ │ └── FBIII.py │ ├── perto │ │ ├── __init__.py │ │ └── Pay2023.py │ ├── snbc │ │ ├── __init__.py │ │ └── BKC310.py │ ├── sweda │ │ ├── __init__.py │ │ ├── SI150.py │ │ └── SI300.py │ ├── tanca │ │ ├── __init__.py │ │ └── TP650.py │ ├── bematech │ │ ├── __init__.py │ │ ├── MP2100.py │ │ ├── MP4200TH.py │ │ └── DP20C.py │ ├── daruma │ │ ├── __init__.py │ │ ├── FS345.py │ │ ├── FS600MFD.py │ │ └── DR700.py │ ├── dataregis │ │ ├── __init__.py │ │ └── Quick.py │ ├── fiscnet │ │ └── __init__.py │ ├── virtual │ │ └── __init__.py │ └── nonfiscal.py ├── readers │ ├── __init__.py │ └── barcode │ │ ├── __init__.py │ │ ├── metrologic │ │ ├── __init__.py │ │ └── MC630.py │ │ ├── reader.py │ │ └── base.py ├── scales │ ├── __init__.py │ ├── toledo │ │ ├── __init__.py │ │ └── PrixIII.py │ ├── micheletti │ │ ├── __init__.py │ │ └── MicP15.py │ ├── scales.py │ └── base.py ├── locale │ └── POTFILES.list ├── translation.py ├── enum.py ├── __init__.py ├── constants.py ├── escp.py ├── usbbase.py ├── configparser.py └── exceptions.py ├── .gitreview ├── .gitignore ├── .gitmodules ├── .tx └── config ├── MANIFEST.in ├── AUTHORS ├── setup.cfg ├── create-release.sh ├── pyproject.toml ├── docs ├── release-checklist.txt └── examples │ └── fiscal.py ├── bin └── echo_server ├── setup_old.py ├── Makefile ├── README.md ├── .gitlab-ci.yml ├── stoqdrivers.spec └── tools └── testdriver.py /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /stoqdrivers/devices/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/readers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/scales/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/elgin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/epson/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/perto/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/snbc/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/sweda/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/tanca/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/scales/toledo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/clean: -------------------------------------------------------------------------------- 1 | stoqdrivers.egg-info/* 2 | -------------------------------------------------------------------------------- /stoqdrivers/printers/bematech/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/daruma/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/dataregis/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/fiscnet/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/printers/virtual/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/readers/barcode/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/scales/micheletti/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/pydist-overrides: -------------------------------------------------------------------------------- 1 | pyusb python-usb 2 | -------------------------------------------------------------------------------- /stoqdrivers/readers/barcode/metrologic/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stoqdrivers/locale/POTFILES.list: -------------------------------------------------------------------------------- 1 | recursive-include stoqdrivers *.py 2 | -------------------------------------------------------------------------------- /tests/stoqdrivers-inverteddrawer.conf: -------------------------------------------------------------------------------- 1 | [Printer] 2 | inverted_drawer = True 3 | -------------------------------------------------------------------------------- /tests/data/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stoq/stoqdrivers/HEAD/tests/data/image.png -------------------------------------------------------------------------------- /tests/data/elgin-I9-init.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-init.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | -------------------------------------------------------------------------------- /.gitreview: -------------------------------------------------------------------------------- 1 | [gerrit] 2 | host=gerrit.async.com.br 3 | port=29418 4 | project=stoqdrivers 5 | defaultbranch=master 6 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-open-drawer.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .noseids 3 | .coverage 4 | nosetests.xml 5 | *.sw? 6 | dist/ 7 | stoqdrivers.egg-info/ 8 | *.mo 9 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-check-drawer.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "utils"] 2 | path = utils 3 | url = https://github.com/stoq/stoq-utils.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | https://pypi.python.org/packages/source/s/stoqdrivers/stoqdrivers-(.*)\.(?:tar\.gz|zip|tar\.bz2) 3 | -------------------------------------------------------------------------------- /stoqdrivers/printers/daruma/FS345.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stoq/stoqdrivers/HEAD/stoqdrivers/printers/daruma/FS345.py -------------------------------------------------------------------------------- /tests/data/elgin-I9-open-drawer.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \x1bp005 7 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-print.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W Print line\n 7 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-init.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-cut.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \n\n\n 7 | W \x1dV\x00 8 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-print.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W Print line\n 7 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-check-drawer.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \x1dr2 7 | R \x01 8 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-print-inline.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W Print 7 | W inline\n 8 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-cut.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W \n\n\n\n 7 | W \x1dV\x00 8 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-print-inline.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W Print 7 | W inline\n 8 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-cut.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \n\n 8 | W \x1bm 9 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-open-drawer.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \x1bv9 8 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-print.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W Print line\n 8 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-init-conditions.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W Init: Condensed and descentralized\n 7 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-print-inline.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W Print 8 | W inline\n 9 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-init-conditions.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W Init: Condensed and descentralized\n 7 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-till-add-cash.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00j*01Valor = 10.00 \xc5 2 | R \x04\r 3 | W \x04 4 | W \xfe\x01k\x00k 5 | R \x04\r 6 | W \x04 7 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-bold.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \x1bE\x01 7 | W Bold 8 | W \x1bE\x00 9 | W Normal\n 10 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-bold.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W \x1b!\t 7 | W Bold 8 | W \x1b!\x01 9 | W Normal\n 10 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-check-drawer.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \x1bb1 8 | W \x05 9 | R \x05 10 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-till-remove-cash.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00j*01Valor = 10.00 \xc5 2 | R \x04\r 3 | W \x04 4 | W \xfe\x01k\x00k 5 | R \x04\r 6 | W \x04 7 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-condensed.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \x1bM0 7 | W Uncondensed 8 | W \x1bM1 9 | W Normal\n 10 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-init-conditions.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W Init: Condensed and descentralized\n 8 | -------------------------------------------------------------------------------- /.tx/config: -------------------------------------------------------------------------------- 1 | [main] 2 | host = https://www.transifex.com 3 | 4 | [stoqdrivers.stoqdriverspot] 5 | file_filter = po/.po 6 | source_file = po/stoqdrivers.pot 7 | source_lang = en 8 | 9 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-bold.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \x1bE 8 | W Bold 9 | W \x1bF 10 | W Normal\n 11 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-double-height.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \x1d!\x01 7 | W Double Height 8 | W \x1d!\x00 9 | W Normal\n 10 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-condensed.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W \x1b!\x00 7 | W Uncondensed 8 | W \x1b!\x01 9 | W Normal\n 10 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-centralize.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \x1ba\x01 7 | W Centralized\n 8 | W \x1ba\x00 9 | W Descentralized\n 10 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-double-height.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W \x1b!\x11 7 | W Double Height 8 | W \x1b!\x01 9 | W Normal\n 10 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-centralize.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W \x1ba\x01 7 | W Centralized\n 8 | W \x1ba\x00 9 | W Descentralized\n 10 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-condensed.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \x1bH 8 | W Uncondensed 9 | W \x1b\x0f 10 | W Normal\n 11 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-double-height.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \x1bd1 8 | W Double Height 9 | W \x1bd0 10 | W Normal\n 11 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-centralize.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \x1ba\x01 8 | W Centralized\n 9 | W \x1ba\x00 10 | W Descentralized\n 11 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-qrcode.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \x1d(k\x03\x001C\x04 7 | W \x1d(k\x03\x001E0 8 | W \x1d(k\x14\x001P0This is a qr code 9 | W \x1d(k\x03\x001Q0 10 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-qrcode.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W \x1d(k\x03\x001C\x04 7 | W \x1d(k\x03\x001E0 8 | W \x1d(k\x14\x001P0This is a qr code 9 | W \x1d(k\x03\x001Q0 10 | -------------------------------------------------------------------------------- /tests/test_stoqdrivers.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from stoqdrivers import __version__ 4 | 5 | 6 | class TestStoqdrivers(unittest.TestCase): 7 | def test_package_version(self): 8 | self.assertEquals(__version__, (2, 1, 0)) 9 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # For reference, see: 4 | # https://wiki.debian.org/Python/Packaging 5 | # https://wiki.debian.org/Python/LibraryStyleGuide 6 | 7 | %: 8 | dh $@ --with python3 --buildsystem=pybuild 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-barcode.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \x1dh\x1e 8 | W \x1dw\x02 9 | W \x1dH\x00 10 | W \x1dkI-123456789123456789123456789123456789123456789 11 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-coupon-open.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00R\x00R 2 | R \x08\r\xfe0R\x06LSNNNK,\x1a\r 3 | W \x04 4 | W \xfe\x02R\x00R 5 | R \x08\r\xfe1R\x06LSNNNK,\x1a\r 6 | W \x04 7 | W \xfe\x04R\x00R 8 | R \x08\r\xfe2R\x06LSNNNK,\x1a\r 9 | W \x04 10 | -------------------------------------------------------------------------------- /tests/data/elgin-I9-barcode.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1bM1 3 | W \x1ba\x00 4 | W \x1bE\x00 5 | W \x1d!\x00 6 | W \x1dh\x1e 7 | W \x1dw\x02 8 | W \x1df\x00 9 | W \x1dH\x00 10 | W \x1dkH\x161234567891234567891234 11 | W \n 12 | W \x1dh\x1e 13 | W \x1dw\x02 14 | W \x1df\x00 15 | W \x1dH\x00 16 | W \x1dkH\x1756789123456789123456789 17 | -------------------------------------------------------------------------------- /tests/data/sweda-SI300-barcode.txt: -------------------------------------------------------------------------------- 1 | W \x1bt\x02 2 | W \x1b!\x01 3 | W \x1ba\x00 4 | W \x1b!\x01 5 | W \x1b!\x01 6 | W \x1dh\x1e 7 | W \x1dw\x02 8 | W \x1df\x00 9 | W \x1dH\x00 10 | W \x1dkH\x161234567891234567891234 11 | W \n 12 | W \x1dh\x1e 13 | W \x1dw\x02 14 | W \x1df\x00 15 | W \x1dH\x00 16 | W \x1dkH\x1756789123456789123456789 17 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README 2 | include NEWS 3 | include AUTHORS 4 | include ChangeLog 5 | include COPYING 6 | include stoqdrivers.spec 7 | include debian/changelog debian/clean debian/compat debian/control 8 | include debian/copyright debian/pydist-overrides debian/rules debian/watch 9 | include requirements.txt 10 | recursive-include stoqdrivers/conf *.ini 11 | recursive-include * *.po *.mo 12 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Maintainer: 2 | 3 | Johan Dahlin 4 | 5 | Contributors: 6 | 7 | Evandro Vale Miquelito 8 | Henrique Romano 9 | Cleber Rodrigues 10 | Adriano Monteiro 11 | Rafael Villar Burke 12 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 2.1.0 3 | tag = True 4 | commit = True 5 | 6 | [flake8] 7 | ignore = E41,E226,E302,E731,W503,W504,W605,E266,E265,E252,E713 8 | max-line-length = 100 9 | exclude = utils,venv,build 10 | filename = *.py 11 | 12 | [bumpversion:file:pyproject.toml] 13 | search = version = "{current_version}" 14 | replace = version = "{new_version}" 15 | 16 | [bumpversion:file:stoqdrivers/__init__.py] 17 | -------------------------------------------------------------------------------- /create-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | version=$1 4 | 5 | regex="([0-9]+)\.([0-9]+)\.?([0-9]*)?(~([a-z]*[0-9]*))?" 6 | if [[ $version =~ $regex ]] 7 | then 8 | major=${BASH_REMATCH[1]} 9 | minor=${BASH_REMATCH[2]} 10 | micro=${BASH_REMATCH[3]:-0} 11 | else 12 | echo "Version doesn't match expected regex" 13 | exit 1 14 | fi 15 | 16 | debchange -v $1 "Release $version" -D xenial 17 | year=`date +%Y` 18 | month=`date +%m | sed "s/^0//"` 19 | day=`date +%d` 20 | 21 | sed -i "s/version = .*/version = \"$major.$minor.$micro\"/" stoqdrivers/__init__.py 22 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "stoqdrivers" 3 | version = "2.1.0" 4 | description = "Drivers for the retail sector." 5 | authors = ["Stoq Team "] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.5" 9 | Pillow = ">=3.1.2" 10 | pyserial = ">=2.2" 11 | qrcode = "~5.3" 12 | "zope.interface" = "^4.0" 13 | 14 | [tool.poetry.dev-dependencies] 15 | Babel = "^2.9.0" 16 | nose = "^1.3.7" 17 | nosexcover = "^1.0.11" 18 | flake8 = "^3.8.4" 19 | bump2version = "^1.0.1" 20 | 21 | [build-system] 22 | requires = ["poetry-core>=1.0.0"] 23 | build-backend = "poetry.core.masonry.api" 24 | -------------------------------------------------------------------------------- /tests/test_utils.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from stoqdrivers.utils import get_obj_from_module 4 | 5 | 6 | class TestUtils(unittest.TestCase): 7 | def test_get_obj_from_module(self): 8 | with self.assertRaises(ImportError): 9 | get_obj_from_module('stoqdrivers.does.not.exists.I.hope', obj_name='FooBarBaz') 10 | 11 | with self.assertRaises(ImportError): 12 | get_obj_from_module('stoqdrivers.utils', obj_name='FooBarBazDoesNotExists') 13 | 14 | obj = get_obj_from_module('stoqdrivers.utils', obj_name='get_obj_from_module') 15 | self.assertEquals(obj, get_obj_from_module) 16 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-cancel-coupon.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00R\x00R 2 | R \x08\r\xfe\xeaR\x06LSNNNK,\x1a\r 3 | W \x04 4 | W \xfe\x02A;987654 Monitor LG 775N 04001000000001000000002\xa7 5 | R \x04\r 6 | W \x04 7 | W \xfe\x03R\x00R 8 | R \x08\r\xfe\xebR\x06VSNNNK6\x1a\r 9 | W \x04 10 | W \xfe\x05C\x00C 11 | R \x08\r\xfe\xecC\x12S00000000001000001\xda\x1a\r 12 | W \x04 13 | W \xfe\x07R\x00R 14 | R \x08\r\xfe\xedR\x06VSNNNK6\x1a\r 15 | W \x04 16 | W \xfe\tD\x100000000000001000U 17 | R \x04\r 18 | W \x04 19 | W \xfe\nC\x00C 20 | R \x08\r\xfe\xeeC\x12T00000000000000001\xda\x1a\r 21 | W \x04 22 | W \xfe\x0cF\x00F 23 | R \x04\r 24 | W \x04 25 | -------------------------------------------------------------------------------- /docs/release-checklist.txt: -------------------------------------------------------------------------------- 1 | Update translations: 2 | kiwi-i18n -pstoqdrivers -u -c 3 | make Changelog 4 | Update NEWS 5 | Update README 6 | Bump version number: 7 | stoqdrivers/__init__.py 8 | make release 9 | Update debian/changelog, add marker (dch -v newversion) 10 | Update debian/control (verify dependencies) 11 | make apidocs 12 | add a release mark in Changelog 13 | make deb 14 | Test the package and fix some lintian errors 15 | Commit 16 | make release-tag 17 | make upload-release 18 | Add bugzilla version: 19 | Use your browser, wget won't work 20 | http://bugs/editversions.cgi?action=new&product=Stoqdrivers&submit=Add&version=0.x.0 21 | -------------------------------------------------------------------------------- /bin/echo_server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | def start_server(): 4 | import socket 5 | 6 | HOST = '127.0.0.1' # Standard loopback interface address (localhost) 7 | PORT = 9100 # Port to listen on (non-privileged ports are > 1023) 8 | 9 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: 10 | s.bind((HOST, PORT)) 11 | s.listen() 12 | conn, addr = s.accept() 13 | with conn: 14 | print('Connected by', addr) 15 | while True: 16 | data = conn.recv(1024) 17 | print(data) 18 | 19 | 20 | if __name__ == "__main__": 21 | import sys 22 | sys.exit(start_server()) 23 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-totalize.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00R\x00R 2 | R \x08\r\xfe!R\x06LSNNNK,\x1a\r 3 | W \x04 4 | W \xfe\x02A;987654 Monitor LG 775N 04001000000001000000002\xa7 5 | R \x04\r 6 | W \x04 7 | W \xfe\x03C\x00C 8 | R \x08\r\xfe"C\x12S00000000001000001\xda\x1a\r 9 | W \x04 10 | W \xfe\x05R\x00R 11 | R \x08\r\xfe#R\x06VSNNNK6\x1a\r 12 | W \x04 13 | W \xfe\x07c\x1f000000000000120000000000000010Ag 14 | R \x04\r 15 | W \x04 16 | W \xfe\x08C\x00C 17 | R \x08\r\xfe$C\x12T00000000000190001\xe4\x1a\r 18 | W \x04 19 | W \xfe\no\x00o 20 | R \x08\r\xfe%o\x03001\x03\r\xfe&o\x040039?\r\xfe'o\x06000024\x9b\r\xfe(o\x0400025\r\xfe)o\x06000004\x99\r\xfe*o\x06000004\x99\r\xfe+o\x0400003\r\xfe,o\x0400003\r\xfe-o\x06000397\xa8\r\xfe.o\x06000427\xa2\r\xfe/o\x042161=\x1a\r 21 | W \x04 22 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-add-payment.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00R\x00R 2 | R \x08\r\xfe\xdbR\x06LSNNNK,\x1a\r 3 | W \x04 4 | W \xfe\x02A;987654 Monitor LG 775N 04001000000001000000002\xa7 5 | R \x04\r 6 | W \x04 7 | W \xfe\x03C\x00C 8 | R \x08\r\xfe\xdcC\x12S00000000001000001\xda\x1a\r 9 | W \x04 10 | W \xfe\x05R\x00R 11 | R \x08\r\xfe\xddR\x06VSNNNK6\x1a\r 12 | W \x04 13 | W \xfe\x07D\x100000000000010000U 14 | R \x04\r 15 | W \x04 16 | W \xfe\x08C\x00C 17 | R \x08\r\xfe\xdeC\x12T00000000009000001\xe3\x1a\r 18 | W \x04 19 | W \xfe\no\x00o 20 | R \x08\r\xfe\xdfo\x03001\x03\r\xfe\xe0o\x040039?\r\xfe\xe1o\x06000019\x9f\r\xfe\xe2o\x0400014\r\xfe\xe3o\x06000002\x97\r\xfe\xe4o\x06000002\x97\r\xfe\xe5o\x0400003\r\xfe\xe6o\x0400003\r\xfe\xe7o\x06000397\xa8\r\xfe\xe8o\x06000419\xa3\r\xfe\xe9o\x042161=\x1a\r 21 | W \x04 22 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-close-coupon.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00R\x00R 2 | R \x08\r\xfe\x10R\x06LSNNNK,\x1a\r 3 | W \x04 4 | W \xfe\x02A;987654 Monitor LG 775N 04001000000001000000002\xa7 5 | R \x04\r 6 | W \x04 7 | W \xfe\x03C\x00C 8 | R \x08\r\xfe\x11C\x12S00000000001000001\xda\x1a\r 9 | W \x04 10 | W \xfe\x05R\x00R 11 | R \x08\r\xfe\x12R\x06VSNNNK6\x1a\r 12 | W \x04 13 | W \xfe\x07D\x100000000000000500Y 14 | R \x04\r 15 | W \x04 16 | W \xfe\x08C\x00C 17 | R \x08\r\xfe\x13C\x12S00000000000500001\xde\x1a\r 18 | W \x04 19 | W \xfe\nR\x00R 20 | R \x08\r\xfe\x14R\x06FSNNNK&\x1a\r 21 | W \x04 22 | W \xfe\x0cD\x100000000000010000U 23 | R \x04\r 24 | W \x04 25 | W \xfe\rC\x00C 26 | R \x08\r\xfe\x15C\x12T00000000009500001\xe8\x1a\r 27 | W \x04 28 | W \xfe\x0fo\x00o 29 | R \x08\r\xfe\x16o\x03001\x03\r\xfe\x17o\x040039?\r\xfe\x18o\x06000023\x9a\r\xfe\x19o\x0400025\r\xfe\x1ao\x06000002\x97\r\xfe\x1bo\x06000002\x97\r\xfe\x1co\x0400003\r\xfe\x1do\x0400003\r\xfe\x1eo\x06000397\xa8\r\xfe\x1fo\x06000424\x9f\r\xfe o\x042161=\x1a\r 30 | W \x04 31 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Copyright: 2 | Copyright (C) 2005-2009 Async Open Source 3 | 4 | License: 5 | 6 | This package is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This package is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this package; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | On Debian systems, the complete text of the GNU Lesser General 21 | Public License can be found in `/usr/share/common-licenses/LGPL'. 22 | 23 | -------------------------------------------------------------------------------- /stoqdrivers/printers/epson/TMT70.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | # 5 | # Stoqdrivers 6 | # Copyright (C) 2020 Stoq Tecnologia 7 | # All rights reserved 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | from zope.interface import implementer 20 | 21 | from stoqdrivers.interfaces import INonFiscalPrinter 22 | from stoqdrivers.printers.epson.TMT20 import TMT20 23 | 24 | 25 | @implementer(INonFiscalPrinter) 26 | class TMT70(TMT20): 27 | 28 | max_characters = 56 29 | 30 | model_name = "Epson TM-T70" 31 | -------------------------------------------------------------------------------- /setup_old.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Setup file for StoqDrivers 4 | # Code by Async Open Source 5 | 6 | from setuptools import setup, find_packages 7 | 8 | 9 | install_requires = [ 10 | "babel", 11 | "pillow", 12 | "pyserial >= 2.2", 13 | "pyusb", 14 | "qrcode ~= 5.3", 15 | "zope.interface >= 3.0", 16 | ] 17 | 18 | setup( 19 | name="stoqdrivers", 20 | version="2.0.1", 21 | author="Async Open Source", 22 | author_email="stoq-devel@async.com.br", 23 | description="Python fiscal printer (ECF) drivers", 24 | long_description=("This package provices device drivers " 25 | "for fiscal printers, ECF (Emissor de Coupon Fiscal) " 26 | "written in Python. Supports printers from Bematech, " 27 | "Daruma, Dataregis, Perto, Sweda and the generic " 28 | "FiscNET protocol."), 29 | url="http://www.stoq.com.br", 30 | license="GNU LGPL 2.1 (see COPYING)", 31 | packages=find_packages(exclude=['tests']), 32 | install_requires=install_requires, 33 | ) 34 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-add-item.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00R\x00R 2 | R \x08\r\xfe\xccR\x06LSNNNK,\x1a\r 3 | W \x04 4 | W \xfe\x02A;000000 Monitor LG 775N 04002000000001000000002\x81 5 | R \x04\r 6 | W \x04 7 | W \xfe\x03A;987654 Monitor LG 775N 04001000000001000000002\xa7 8 | R \x04\r 9 | W \x04 10 | W \xfe\x04A;123456 Monitor LG 775N 04001000000001000000002\x95 11 | R \x04\r 12 | W \x04 13 | W \xfe\x05v;123456 Monitor LG 775N 04001000000001000010002\xcb 14 | R \x04\r 15 | W \x04 16 | W \xfe\x06C\x00C 17 | R \x08\r\xfe\xcdC\x12S00000000005010004\xe2\x1a\r 18 | W \x04 19 | W \xfe\x08R\x00R 20 | R \x08\r\xfe\xceR\x06VSNNNK6\x1a\r 21 | W \x04 22 | W \xfe\nD\x100000000000010000U 23 | R \x04\r 24 | W \x04 25 | W \xfe\x0bC\x00C 26 | R \x08\r\xfe\xcfC\x12T00000000004990004\xf3\x1a\r 27 | W \x04 28 | W \xfe\ro\x00o 29 | R \x08\r\xfe\xd0o\x03001\x03\r\xfe\xd1o\x040039?\r\xfe\xd2o\x06000018\x9e\r\xfe\xd3o\x0400014\r\xfe\xd4o\x06000002\x97\r\xfe\xd5o\x06000002\x97\r\xfe\xd6o\x0400003\r\xfe\xd7o\x0400003\r\xfe\xd8o\x06000397\xa8\r\xfe\xd9o\x06000418\xa2\r\xfe\xdao\x042161=\x1a\r 30 | W \x04 31 | -------------------------------------------------------------------------------- /stoqdrivers/printers/sweda/SI150.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2017 Stoq Tecnologia 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | 19 | from zope.interface import implementer 20 | 21 | from stoqdrivers.usbbase import UsbBase 22 | from stoqdrivers.escpos import EscPosMixin 23 | from stoqdrivers.interfaces import INonFiscalPrinter 24 | 25 | 26 | @implementer(INonFiscalPrinter) 27 | class SI150(UsbBase, EscPosMixin): 28 | 29 | out_ep = 0x03 30 | 31 | supported = True 32 | model_name = "Sweda SI-150" 33 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PACKAGE=stoqdrivers 2 | TEST_PACKAGES=$(PACKAGE) tests 3 | WEBDOC_DIR=/mondo/htdocs/stoq.com.br/doc/devel 4 | # FIXME: This probably should be on utils.mk 5 | TESTS_RUNNER=python3 -m nose --nocapture --nologcapture --verbose --detailed-errors 6 | 7 | stoqdrivers.pickle: 8 | pydoctor --project-name="Stoqdrivers" \ 9 | --add-package=stoqdrivers \ 10 | -o stoqdrivers.pickle stoqdrivers 11 | 12 | apidocs: stoqdrivers.pickle 13 | pydoctor --project-name="Stoqdrivers" \ 14 | --make-html \ 15 | -p stoqdrivers.pickle 16 | 17 | web: apidocs 18 | cp -r apidocs $(WEBDOC_DIR)/stoqdrivers-tmp 19 | rm -fr $(WEBDOC_DIR)/stoqdrivers 20 | mv $(WEBDOC_DIR)/stoqdrivers-tmp $(WEBDOC_DIR)/stoqdrivers 21 | cp stoqdrivers.pickle $(WEBDOC_DIR)/stoqdrivers 22 | 23 | lint: 24 | flake8 . 25 | 26 | check: lint 27 | @rm -f .noseids 28 | $(TESTS_RUNNER) --failed $(TEST_PACKAGES) 29 | 30 | check-failed: 31 | $(TESTS_RUNNER) --failed $(TEST_PACKAGES) 32 | 33 | coverage: lint 34 | $(TESTS_RUNNER) --with-coverage --with-xunit \ 35 | --cover-package=$(PACKAGE) --cover-erase $(TEST_PACKAGES) 36 | 37 | include utils/utils.mk 38 | .PHONY: clean stoqdrivers.pickle 39 | -------------------------------------------------------------------------------- /tests/data/dataregis-EP375-cancel-item.txt: -------------------------------------------------------------------------------- 1 | W \xfe\x00R\x00R 2 | R \x08\r\xfe\xefR\x06LSNNNK,\x1a\r 3 | W \x04 4 | W \xfe\x02A;987654 Monitor LG 775N 04001000000001000000002\xa7 5 | R \x04\r 6 | W \x04 7 | W \xfe\x03b;987654 Monitor LG 775N 04001000000001000000002\xc8 8 | R \x04\r 9 | W \x04 10 | W \xfe\x04b;987654 Monitor LG 775N 04001000000001000000002\xc8 11 | R \x06\r 12 | W \xfe\x05R\x00R 13 | R \x08\r\xfe\xf0R\x06VSNNNbM\x1a\r 14 | W \x04 15 | W \xfe\x07A;987654 Monitor LG 775N 04001000000001000000002\xa7 16 | R \x04\r 17 | W \x04 18 | W \xfe\x08C\x00C 19 | R \x08\r\xfe\xf1C\x12S00000000001000001\xda\x1a\r 20 | W \x04 21 | W \xfe\nR\x00R 22 | R \x08\r\xfe\xf2R\x06VSNNNK6\x1a\r 23 | W \x04 24 | W \xfe\x0cD\x100000000000010000U 25 | R \x04\r 26 | W \x04 27 | W \xfe\rC\x00C 28 | R \x08\r\xfe\xf3C\x12T00000000009000001\xe3\x1a\r 29 | W \x04 30 | W \xfe\x0fo\x00o 31 | R \x08\r\xfe\xf4o\x03001\x03\r\xfe\xf5o\x040039?\r\xfe\xf6o\x06000021\x98\r\xfe\xf7o\x0400025\r\xfe\xf8o\x06000002\x97\r\xfe\xf9o\x06000002\x97\r\xfe\xfao\x0400003\r\xfe\xfbo\x0400003\r\xfe\xfco\x06000397\xa8\r\xfe\xfdo\x06000422\x9d\r\xfe\xfeo\x042161=\x1a\r 32 | W \x04 33 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: stoqdrivers 2 | Section: python 3 | Priority: optional 4 | Maintainer: Stoq Team 5 | Build-Depends: debhelper (>= 8.0.0), python3-all (>= 3.4), python3-setuptools 6 | Build-Depends-Indep: python3-zope.interface (>= 3.5.2)|python3-zopeinterface (>= 3.2.1), 7 | python3-serial (>= 2.2) 8 | Homepage: http://www.stoq.com.br 9 | Vcs-Git: https://github.com/stoq/stoqdrivers.git 10 | Vcs-Browser: https://github.com/stoq/stoqdrivers/ 11 | Standards-Version: 3.9.3 12 | X-Python3-Version: >= 3.4 13 | 14 | Package: python3-stoqdrivers 15 | Architecture: all 16 | Depends: ${misc:Depends}, ${python:Depends}, 17 | python3-zope.interface (>= 3.5.2) | python3-zopeinterface (>= 3.2.1), 18 | python3-serial (>= 2.2), python3-qrcode (>= 4.0.1), python3-usb, python3-babel 19 | Breaks: stoq (< 2.1.90), python-qrcode 20 | Replaces: stoqdrivers 21 | Homepage: http://www.stoq.com.br 22 | Description: Python fiscal printer (ECF) drivers 23 | This package provices device drivers 24 | for fiscal printers, ECF (Emissor de Coupon Fiscal) 25 | written in Python. 26 | . 27 | Supports printers from Bematech, Daruma, Dataregis, 28 | Perto, Sweda and the generic FiscNET protocol. 29 | -------------------------------------------------------------------------------- /stoqdrivers/translation.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2006 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | """ 25 | Stoqdrivers translation functions 26 | """ 27 | 28 | import gettext 29 | 30 | 31 | def stoqdrivers_gettext(message): 32 | return gettext.dgettext('stoqdrivers', message) 33 | -------------------------------------------------------------------------------- /stoqdrivers/printers/epson/TMT20.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2016 Stoq Tecnologia 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | 19 | from zope.interface import implementer 20 | 21 | from stoqdrivers.usbbase import UsbBase 22 | from stoqdrivers.escpos import EscPosMixin, GS 23 | from stoqdrivers.interfaces import INonFiscalPrinter 24 | 25 | 26 | @implementer(INonFiscalPrinter) 27 | class TMT20(UsbBase, EscPosMixin): 28 | DOUBLE_HEIGHT_ON = GS + '!' + '\x01' 29 | DOUBLE_HEIGHT_OFF = GS + '!' + '\x00' 30 | 31 | out_ep = 0x01 32 | 33 | supported = True 34 | model_name = "Epson TM-T20" 35 | -------------------------------------------------------------------------------- /stoqdrivers/readers/barcode/metrologic/MC630.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2006 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Henrique Romano 25 | ## 26 | 27 | from stoqdrivers.readers.barcode.base import BaseBarcodeReader 28 | 29 | 30 | class MC630(BaseBarcodeReader): 31 | model_name = "Metrologic MC630" 32 | -------------------------------------------------------------------------------- /stoqdrivers/printers/bematech/MP2100.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2008 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Ronaldo Maia 25 | ## 26 | """ 27 | Bematech MP2100 driver 28 | """ 29 | 30 | from stoqdrivers.printers.bematech.MP25 import MP25 31 | 32 | 33 | class MP2100(MP25): 34 | model_name = "Bematech MP2100 TH FI" 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Stoqdrivers 2 | 3 | Stoqdrivers has as goal the implementation of drivers for the most 4 | common equipments that interacts with retail systems. The main 5 | example usage of this package is in Stoq: http://www.stoq.com.br. 6 | 7 | ## Requirements 8 | 9 | * Python 3 (http://www.python.org/) 10 | * pySerial 1.3 (http://pyserial.sourceforge.net/) 11 | * pyUSB 1.3 (https://walac.github.io/pyusb/) 12 | * Zope interfaces 3.5.2 (http://www.zope.org/Products/ZopeInterface/) 13 | 14 | ## New Versions 15 | 16 | New versions of the package can be found always by the gerrit repository: 17 | 18 | http://gerrit.async.com.br/stoqdrivers 19 | 20 | There's also a mirror at github: 21 | 22 | $ git clone http://github.com/stoq/stoqdrivers.git 23 | 24 | ## Mailing list 25 | 26 | There are two mailing lists where you can put questions and suggestions 27 | about Stoqdrivers. You can subscribe to them through the web interface 28 | at: 29 | 30 | * http://www.async.com.br/mailman/listinfo/stoq-users 31 | * http://www.async.com.br/mailman/listinfo/stoq-devel 32 | 33 | ## Starting a server to have a ethernet connection 34 | 35 | To start the echo server to do simple tests just run the following command 36 | 37 | ``` 38 | ./bin/echo_server 39 | ``` 40 | -------------------------------------------------------------------------------- /stoqdrivers/printers/daruma/FS600MFD.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2005 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Henrique Romano 25 | ## 26 | """ 27 | Daruma FS600MFD driver 28 | """ 29 | 30 | from stoqdrivers.printers.daruma.FS2100 import FS2100 31 | 32 | 33 | class FS600MFD(FS2100): 34 | model_name = "Daruma FS 600 MFD" 35 | -------------------------------------------------------------------------------- /stoqdrivers/printers/elgin/KFiscal.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2005-2007 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Stoq Team 25 | ## 26 | """ 27 | Elgin Fiscal K 28 | """ 29 | 30 | from stoqdrivers.printers.fiscnet.FiscNetECF import FiscNetECF 31 | 32 | 33 | class KFiscal(FiscNetECF): 34 | log_domain = 'KFiscal' 35 | supported = True 36 | model_name = "Elgin K Fiscal" 37 | -------------------------------------------------------------------------------- /stoqdrivers/printers/snbc/BKC310.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2019 Stoq Tecnologia 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | import qrcode 19 | 20 | from zope.interface import implementer 21 | 22 | from stoqdrivers.utils import GRAPHICS_24BITS 23 | from stoqdrivers.usbbase import UsbBase 24 | from stoqdrivers.escpos import EscPosMixin 25 | from stoqdrivers.interfaces import INonFiscalPrinter 26 | 27 | 28 | @implementer(INonFiscalPrinter) 29 | class BKC310(UsbBase, EscPosMixin): 30 | out_ep = 0x02 31 | cut_line_feeds = 0 32 | 33 | supported = True 34 | model_name = "SNBC BK-C310" 35 | 36 | def print_qrcode(self, code): 37 | qr = qrcode.QRCode(version=1, border=4) 38 | qr.add_data(code) 39 | self.print_matrix(qr.get_matrix(), GRAPHICS_24BITS, multiplier=3) 40 | -------------------------------------------------------------------------------- /stoqdrivers/printers/bematech/MP4200TH.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Copyright (C) 2016 Async Open Source 6 | ## All rights reserved 7 | ## 8 | ## This program is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU Lesser General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## This program is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., or visit: http://www.gnu.org/. 21 | ## 22 | ## Author(s): Stoq Team 23 | ## 24 | 25 | from zope.interface import implementer 26 | 27 | from stoqdrivers.printers.bematech.MP2100TH import MP2100TH, ESC 28 | from stoqdrivers.interfaces import INonFiscalPrinter 29 | 30 | 31 | @implementer(INonFiscalPrinter) 32 | class MP4200TH(MP2100TH): 33 | 34 | supported = True 35 | model_name = "Bematech MP4200 TH" 36 | max_characters = 64 37 | 38 | def cut_paper(self): 39 | self.write(ESC + '\x6d') 40 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: cprov/stoq:candidate 2 | 3 | variables: 4 | GIT_SUBMODULE_STRATEGY: recursive 5 | 6 | stages: 7 | - test 8 | - build 9 | 10 | before_script: 11 | - apt update 12 | - apt --yes install devscripts debhelper python3-all libcairo2-dev libgirepository1.0-dev python3-pip python3-virtualenv python3-venv libpq-dev swig pkg-config libpq-dev swig libjpeg8-dev zlib1g-dev 13 | - apt --yes install build-essential libssl-dev libffi-dev python3-dev 14 | # Some tests assume the timezone is America/Sao_Paulo. We should properly mock the date generation 15 | # to include the timezone 16 | - ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime 17 | - dpkg-reconfigure --frontend noninteractive tzdata 18 | 19 | - export LC_ALL=pt_BR.UTF-8 20 | # Stoq is not installing correctly using pip outside of a venv 21 | - python3 -m venv venv 22 | - source venv/bin/activate 23 | - pip install -U pip setuptools 24 | - pip install -U poetry 25 | - poetry install -vvv 26 | - poetry show 27 | - cp setup_old.py setup.py 28 | 29 | test: 30 | stage: test 31 | script: 32 | - poetry run make check 33 | 34 | .create_deb: 35 | stage: build 36 | script: 37 | - rm -rf dist 38 | - poetry run make deb 39 | artifacts: 40 | paths: 41 | - dist/*.deb 42 | 43 | create_deb_master: 44 | extends: .create_deb 45 | only: 46 | - master 47 | 48 | create_deb_manual: 49 | extends: .create_deb 50 | stage: test 51 | when: manual 52 | -------------------------------------------------------------------------------- /stoqdrivers/printers/dataregis/Quick.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2009 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Ronaldo Maia 25 | ## 26 | """ 27 | Dataregis Quick driver implementation. 28 | """ 29 | 30 | from stoqdrivers.printers.fiscnet.FiscNetECF import FiscNetECF 31 | from stoqdrivers.translation import stoqdrivers_gettext 32 | 33 | _ = stoqdrivers_gettext 34 | 35 | 36 | class Quick(FiscNetECF): 37 | log_domain = 'DataregisQuick' 38 | supported = True 39 | 40 | model_name = "Dataregis ECF-IF 3202DT (Quick)" 41 | -------------------------------------------------------------------------------- /stoqdrivers/printers/perto/Pay2023.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2005-2007 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Henrique Romano 25 | ## Johan Dahlin 26 | ## 27 | """ 28 | PertoPay 2023 driver implementation. 29 | """ 30 | 31 | from stoqdrivers.printers.fiscnet.FiscNetECF import FiscNetChequePrinter 32 | from stoqdrivers.translation import stoqdrivers_gettext 33 | 34 | _ = stoqdrivers_gettext 35 | 36 | 37 | class Pay2023(FiscNetChequePrinter): 38 | log_domain = 'PertoPay2023' 39 | supported = True 40 | 41 | model_name = "Pertopay Fiscal 2023" 42 | -------------------------------------------------------------------------------- /stoqdrivers/printers/epson/FBIII.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2012 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Stoq Team 25 | ## 26 | """ 27 | Epson FBIII ECF driver 28 | """ 29 | from decimal import Decimal 30 | 31 | from stoqdrivers.printers.epson.FBII import FBII 32 | 33 | # Coupons status 34 | CLOSED_COUPON = '0000' 35 | OPENED_FISCAL_COUPON = '0001' 36 | OPENED_NON_FISCAL_COUPON = '1000' 37 | 38 | 39 | class FBIII(FBII): 40 | model_name = "Epson FBIII" 41 | 42 | def apply_discount(self, id, discount): 43 | value = int(discount * Decimal('1e2')) 44 | self._send_command('0A07', '0010', id, str(value)) 45 | 46 | def apply_markup(self, id, markup): 47 | value = int(markup * Decimal('1e2')) 48 | self._send_command('0A07', '0011', id, str(value)) 49 | -------------------------------------------------------------------------------- /stoqdrivers/scales/scales.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2005 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Henrique Romano 25 | ## 26 | """ 27 | Base class implementation for all the scales drivers. 28 | """ 29 | 30 | 31 | from stoqdrivers.scales.base import BaseScale 32 | 33 | # 34 | # Scale interface 35 | # 36 | 37 | 38 | class Scale(BaseScale): 39 | def read_data(self): 40 | return self._driver.read_data() 41 | 42 | 43 | def test(): 44 | scale = Scale() 45 | 46 | print("Waiting for scale reply... ") 47 | data = scale.read_data() 48 | print("...ok") 49 | print("Weight: %.02f" % data.weight) 50 | print("Price per Kg: %.02f" % data.price_per_kg) 51 | print("Total price: %.02f" % data.total_price) 52 | 53 | 54 | if __name__ == "__main__": 55 | test() 56 | -------------------------------------------------------------------------------- /stoqdrivers/readers/barcode/reader.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2006 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Henrique Romano 25 | ## 26 | """ 27 | Barcode reader interface implementation. 28 | """ 29 | 30 | from zope.interface import providedBy 31 | 32 | from stoqdrivers.interfaces import IBarcodeReader 33 | from stoqdrivers.base import BaseDevice 34 | from stoqdrivers.enum import DeviceType 35 | 36 | 37 | class BarcodeReader(BaseDevice): 38 | device_dirname = "readers.barcode" 39 | device_type = DeviceType.BARCODE_READER 40 | 41 | def check_interfaces(self): 42 | if not IBarcodeReader in providedBy(self._driver): 43 | raise TypeError("The driver `%r' doesn't implements a valid " 44 | "interface" % self._driver) 45 | 46 | def get_code(self): 47 | return self._driver.get_code() 48 | -------------------------------------------------------------------------------- /tests/data/bematech-MP2100TH-qrcode.txt: -------------------------------------------------------------------------------- 1 | W \x1d\xf9 \x00 2 | W \x1d\xf972 3 | W \x1b\x0f 4 | W \x1ba\x00 5 | W \x1bF 6 | W \x1bd0 7 | W \x00 8 | W \x1b3\x00 9 | W \x1bKc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0f\x0f\x08\x08\x08\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x08\x08\x08\x0f\x0f\x0f\x00\x00\x00\r\r\r\x0e\x0e\x0e\x0b\x0b\x0b\x07\x07\x07\x03\x03\x03\x0c\x0c\x0c\x01\x01\x01\t\t\t\x04\x04\x04\x00\x00\x00\x0f\x0f\x0f\x08\x08\x08\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x08\x08\x08\x0f\x0f\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 10 | W \n 11 | W \x1bKc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xed\xed\xed \xaf\xaf\xaf\xaf\xaf\xaf\xa5\xa5\xa5***\xea\xea\xea\x0b\x0b\x0b000\x1c\x1c\x1c\xff\xff\xff\x8f\x8f\x8f000NNN\xa4\xa4\xa4\x81\x81\x81\xfe\xfe\xfe\x02\x02\x02\xe8\xe8\xe8###\xa2\xa2\xa2\xaf\xaf\xaf\xa5\xa5\xa5(((\xe8\xe8\xe8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 12 | W \n 13 | W \x1bKc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x93\x93\x93bbb\xda\xda\xdabbb\x8a\x8a\x8a"""\xab\xab\xab\xd8\xd8\xd8\xbf\xbf\xbf!!!IIIqqq\xc8\xc8\xc8###\xdf\xdf\xdfAAAOOO\x98\x98\x98\xda\xda\xdahhh\xcf\xcf\xcf333\x8c\x8c\x8cfffRRR\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 14 | W \n 15 | W \x1bKc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\xf8\xf8\x08\x08\x08\xe8\xe8\xe8\xe8\xe8\xe8\xe8\xe8\xe8\x08\x08\x08\xf8\xf8\xf8\x00\x00\x00hhh\x08\x08\x08@@@\x18\x18\x18\x10\x10\x10\x90\x90\x90\xb0\xb0\xb0HHH\x80\x80\x80\xc0\xc0\xc0\xe0\xe0\xe0\x80\x80\x80\xf0\xf0\xf0pppXXXhhhHHH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 16 | W \n 17 | W \x1bKc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 18 | W \n 19 | W \x1b2 20 | -------------------------------------------------------------------------------- /stoqdrivers/enum.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | # 5 | # Stoqdrivers 6 | # Copyright (C) 2007 Async Open Source 7 | # All rights reserved 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | # USA. 23 | # 24 | # Author(s): Johan Dahlin 25 | # 26 | """ 27 | StoqDrivers enums 28 | """ 29 | 30 | from enum import IntEnum 31 | 32 | 33 | class PaymentMethodType(IntEnum): 34 | """ 35 | Enum for Payment Methods 36 | """ 37 | (MONEY, 38 | CHECK, 39 | BILL, 40 | CREDIT_CARD, 41 | DEBIT_CARD, 42 | FINANCIAL, 43 | GIFT_CERTIFICATE, 44 | CUSTOM, 45 | MULTIPLE) = range(9) 46 | 47 | 48 | class UnitType(IntEnum): 49 | """ 50 | Enum for units 51 | """ 52 | (WEIGHT, 53 | METERS, 54 | LITERS, 55 | EMPTY, 56 | CUSTOM) = range(20, 25) 57 | 58 | 59 | class TaxType(IntEnum): 60 | """ 61 | Enum for taxes 62 | """ 63 | (ICMS, 64 | SUBSTITUTION, 65 | EXEMPTION, 66 | NONE, 67 | SERVICE, 68 | CUSTOM) = range(40, 46) 69 | 70 | 71 | class DeviceType(IntEnum): 72 | """ 73 | Enum for device types 74 | """ 75 | 76 | (PRINTER, 77 | SCALE, 78 | BARCODE_READER) = range(3) 79 | -------------------------------------------------------------------------------- /stoqdrivers/printers/elgin/I9.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Copyright (C) 2016-2019 Stoq Tecnologia 6 | ## All rights reserved 7 | ## 8 | ## This program is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU Lesser General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## This program is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., or visit: http://www.gnu.org/. 21 | ## 22 | ## Author(s): Stoq Team 23 | ## 24 | 25 | from zope.interface import implementer 26 | from stoqdrivers.escpos import EscPosMixin, ESC, GS 27 | from stoqdrivers.interfaces import INonFiscalPrinter 28 | from stoqdrivers.serialbase import SerialBase 29 | 30 | 31 | @implementer(INonFiscalPrinter) 32 | class I9(SerialBase, EscPosMixin): 33 | DOUBLE_HEIGHT_ON = GS + '!' + '\x01' 34 | DOUBLE_HEIGHT_OFF = GS + '!' + '\x00' 35 | 36 | cut_line_feeds = 3 37 | supported = True 38 | model_name = "Elgin I9" 39 | 40 | def __init__(self, port, consts=None): 41 | SerialBase.__init__(self, port) 42 | EscPosMixin.__init__(self) 43 | 44 | def open_drawer(self): 45 | m = '0' 46 | t1 = '0' 47 | t2 = '5' # number of milliseconds to activate the electrical signal. 48 | self.write(ESC + 'p' + m + t1 + t2) 49 | 50 | def is_drawer_open(self): 51 | self.write(GS + 'r2') 52 | data = ord(self.read(1)[0]) 53 | if self.inverted_drawer: 54 | return data != 0 55 | else: 56 | return data == 0 57 | -------------------------------------------------------------------------------- /stoqdrivers.spec: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # Authority: jdahlin 3 | 4 | %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} 5 | 6 | Summary: Python fiscal printer (ECF) drivers 7 | 8 | Name: stoqdrivers 9 | Version: 1.2.1 10 | Release: 1 11 | License: LGPL 12 | Group: System Environment/Libraries 13 | URL: http://www.stoq.com.br/ 14 | Source: http://download.stoq.com.br/sources/LATEST/stoqdrivers-%{version}.tar.gz 15 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root 16 | Requires: pygobject2 >= 2.8.0, python-zope-interface >= 3.0.1, pyserial >= 2.2, python-usb 17 | Requires: python-abi = %(%{__python} -c "import sys; print sys.version[:3]") 18 | BuildArch: noarch 19 | 20 | %description 21 | This package provices device drivers 22 | for fiscal printers, ECF (Emissor de Coupon Fiscal) 23 | written in Python. Supports printers from Bematech, 24 | Daruma, Dataregis, Perto, Sweda and the generic 25 | FiscNET protocol. 26 | 27 | %prep 28 | 29 | %setup 30 | 31 | %build 32 | 33 | %install 34 | %{__rm} -rf %{buildroot} 35 | %{__python} setup.py install --root=%{buildroot} 36 | 37 | %clean 38 | %{__rm} -rf %{buildroot} 39 | 40 | %files 41 | %defattr(-, root, root, 0755) 42 | %doc AUTHORS ChangeLog COPYING NEWS README 43 | %{python_sitelib}/stoqdrivers 44 | %{_libdir}/python*/site-packages/*.egg-info 45 | %{_datadir}/locale/*/LC_MESSAGES/stoqdrivers.mo 46 | %{_datadir}/stoqdrivers/conf/*.ini 47 | 48 | %changelog 49 | * Tue Jan 31 2011 Ronaldo Maia 0.9.15-1 50 | - New Release. 51 | 52 | * Fri Jul 28 2011 Ronaldo Maia 0.9.14-1 53 | - New Release. 54 | 55 | * Fri Jul 22 2011 Johan Dahlin 0.9.13-1 56 | - New Release. 57 | 58 | * Thu Jul 14 2011 Johan Dahlin 0.9.12-1 59 | - New Release. 60 | 61 | * Thu Nov 08 2007 Fabio Morbec 0.9.1-2 62 | - New Release. 63 | 64 | * Thu Nov 08 2007 Fabio Morbec 0.9.1 65 | - New Release. 66 | 67 | * Thu Aug 30 2007 Fabio Morbec 0.9.0 68 | - Initial RPM release. 69 | 70 | -------------------------------------------------------------------------------- /stoqdrivers/printers/tanca/TP650.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2018 Stoq Tecnologia 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | 19 | from zope.interface import implementer 20 | 21 | from stoqdrivers.usbbase import UsbBase 22 | from stoqdrivers.escpos import EscPosMixin 23 | from stoqdrivers.interfaces import INonFiscalPrinter 24 | 25 | 26 | @implementer(INonFiscalPrinter) 27 | class TP650(UsbBase, EscPosMixin): 28 | 29 | out_ep = 0x02 30 | 31 | supported = True 32 | model_name = "Tanca TP650" 33 | 34 | # This is for normal printing. Condensed mode is 64 35 | max_characters = 48 36 | 37 | 38 | if __name__ == '__main__': 39 | dev = TP650(vendor_id=0x0fe6, product_id=0x811e) 40 | dev.write('\n\n\nbegin\n\n\n') 41 | dev.unset_condensed() 42 | print(dev) 43 | dev.write('-' * dev.max_characters) 44 | dev.write('right aligned >'.rjust(48)) 45 | dev.write('< left aligned'.ljust(48)) 46 | dev.set_condensed() 47 | dev.write('right aligned >'.rjust(64)) 48 | dev.write('< left aligned'.ljust(64)) 49 | dev.unset_condensed() 50 | 51 | dev.centralize() 52 | dev.set_bold() 53 | dev.write('Bold Centralized text\n') 54 | 55 | dev.set_double_height() 56 | dev.write('Bold Double Height\n') 57 | 58 | dev.descentralize() 59 | dev.unset_bold() 60 | 61 | dev.write('Normal Double Height\n') 62 | dev.unset_double_height() 63 | 64 | dev.write('Back to normal text\n') 65 | 66 | dev.write('\n\n\n') 67 | 68 | dev.print_barcode('1234567890') 69 | dev.print_qrcode('https://www.stoq.com.br') 70 | dev.write('\n\n\n') 71 | dev.write('\n\n\nend\n\n\n') 72 | -------------------------------------------------------------------------------- /stoqdrivers/readers/barcode/base.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | # 5 | # Stoqdrivers 6 | # Copyright (C) 2006 Async Open Source 7 | # All rights reserved 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | # USA. 23 | # 24 | # Author(s): Henrique Romano 25 | # 26 | 27 | from importlib import import_module 28 | 29 | from zope.interface import implementer 30 | 31 | from stoqdrivers.interfaces import IBarcodeReader 32 | from stoqdrivers.serialbase import SerialBase 33 | 34 | 35 | @implementer(IBarcodeReader) 36 | class BaseBarcodeReader(SerialBase): 37 | # Should be defined in subclasses 38 | model_name = None 39 | 40 | def __init__(self, port, consts=None): 41 | SerialBase.__init__(self, port) 42 | 43 | def get_code(self): 44 | return self.readline() 45 | 46 | 47 | def get_supported_barcode_readers(): 48 | result = {} 49 | for brand, module_names in [('metrologic', ['MC630'])]: 50 | result[brand] = [] 51 | for module_name in module_names: 52 | module = import_module("stoqdrivers.readers.barcode.%s.%s" % (brand, module_name)) 53 | try: 54 | obj = getattr(module, module_name) 55 | except AttributeError: 56 | raise ImportError("Can't find class %s for module %s" % (module_name, module_name)) 57 | if not IBarcodeReader.implementedBy(obj): 58 | raise TypeError("The driver %s %s doesn't implements a " 59 | "valid interface" % (brand, obj.model_name)) 60 | result[brand].append(obj) 61 | return result 62 | -------------------------------------------------------------------------------- /stoqdrivers/scales/base.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | # 5 | # Stoqdrivers 6 | # Copyright (C) 2005 Async Open Source 7 | # All rights reserved 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | # USA. 23 | # 24 | # Author(s): Henrique Romano 25 | # 26 | """ 27 | Useful functions related to all scales supported by stoqdrivers 28 | """ 29 | 30 | from zope.interface import providedBy 31 | 32 | from stoqdrivers.base import BaseDevice 33 | from stoqdrivers.enum import DeviceType 34 | from stoqdrivers.interfaces import IScale 35 | from stoqdrivers.utils import get_obj_from_module 36 | 37 | 38 | class BaseScale(BaseDevice): 39 | device_dirname = "scales" 40 | device_type = DeviceType.SCALE 41 | 42 | def check_interfaces(self): 43 | driver_interfaces = providedBy(self._driver) 44 | if IScale not in driver_interfaces: 45 | raise TypeError("This driver doesn't implements a valid interface") 46 | 47 | 48 | def get_supported_scales(): 49 | result = {} 50 | 51 | for brand, module_names in [ 52 | (u'toledo', [u'PrixIII']), 53 | (u'micheletti', [u'MicP15']) 54 | ]: 55 | result[brand] = [] 56 | for module_name in module_names: 57 | full_module_name = "stoqdrivers.scales.%s.%s" % (brand, module_name) 58 | obj = get_obj_from_module(full_module_name, obj_name=module_name) 59 | if not IScale.implementedBy(obj): 60 | raise TypeError("The driver %s %s doesn't implements a " 61 | "valid interface" 62 | % (brand, obj.model_name)) 63 | result[brand].append(obj) 64 | return result 65 | -------------------------------------------------------------------------------- /stoqdrivers/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | # 5 | # Stoqdrivers 6 | # Copyright (C) 2005-2011 Async Open Source 7 | # All rights reserved 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | # USA. 23 | # 24 | # Author(s): Henrique Romano 25 | # Johan Dahlin 26 | # 27 | 28 | import gettext 29 | import importlib.util 30 | import locale 31 | import os 32 | import platform 33 | 34 | import pkg_resources 35 | 36 | version = "2.1.0" 37 | __version__ = tuple(int(n) for n in version.split('.')) 38 | 39 | __all__ = ["library", "__version__"] 40 | 41 | 42 | def enable_translation(domain, root='..', enable_global=None): 43 | installed = importlib.util.find_spec("stoqdrivers") 44 | if installed and pkg_resources.resource_exists(domain, 'locale'): 45 | localedir = pkg_resources.resource_filename(domain, 'locale') 46 | elif installed: 47 | localedir = None 48 | else: 49 | localedir = os.path.join(root, 'locale') 50 | 51 | gettext.bindtextdomain(domain, localedir) 52 | # For libglade, but only on non-win32 systems 53 | if hasattr(locale, 'bindtextdomain'): 54 | locale.bindtextdomain(domain, localedir) 55 | 56 | gettext.bind_textdomain_codeset(domain, 'utf-8') 57 | 58 | if enable_global: 59 | gettext.textdomain(domain) 60 | # For libglade, but only on non-win32 systems 61 | if hasattr(locale, 'textdomain'): 62 | locale.textdomain(domain) 63 | 64 | if platform.system() == 'Windows': 65 | from ctypes import cdll 66 | libintl = cdll.LoadLibrary("libintl-8.dll") 67 | libintl.bindtextdomain(domain, localedir) 68 | libintl.bind_textdomain_codeset(domain, 'UTF-8') 69 | if enable_global: 70 | libintl.textdomain(domain) 71 | del libintl 72 | 73 | 74 | enable_translation('stoqdrivers') 75 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-summarize.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1b\xcf 8 | R :X000835\r 9 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-read-memory.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1b\xd1x010113300113 8 | R :M000833\r 9 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-read-memory-by-reductions.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1b\xd1x000001000010 8 | R :M000834\r 9 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-till-add-cash.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1cF\xec00000001000\xffx 8 | R :0000040\xec000842\r\xe1 9 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-till-remove-cash.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1cF\xe300000001000\xffw 8 | R :0000040\xe3000841\r\xed 9 | -------------------------------------------------------------------------------- /tests/check_ifaces_impl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- Mode: Python; coding: iso-8859-1 -*- 3 | # vi:si:et:sw=4:sts=4:ts=4 4 | 5 | ## 6 | ## Stoqdrivers 7 | ## Copyright (C) 2006 Async Open Source 8 | ## All rights reserved 9 | ## 10 | ## This program is free software; you can redistribute it and/or modify 11 | ## it under the terms of the GNU General Public License as published by 12 | ## the Free Software Foundation; either version 2 of the License, or 13 | ## (at your option) any later version. 14 | ## 15 | ## This program is distributed in the hope that it will be useful, 16 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ## GNU General Public License for more details. 19 | ## 20 | ## You should have received a copy of the GNU General Public License 21 | ## along with this program; if not, write to the Free Software 22 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 23 | ## USA. 24 | ## 25 | ## Author(s): Henrique Romano 26 | ## 27 | """ This is a simple module to check if all the drivers implements properly 28 | its interfaces. """ 29 | 30 | from zope.interface.verify import verifyClass 31 | from zope.interface.exceptions import Invalid 32 | 33 | from stoqdrivers.interfaces import (ICouponPrinter, 34 | IChequePrinter, 35 | IScale) 36 | from stoqdrivers.printers.base import get_supported_printers_by_iface 37 | from stoqdrivers.scales.base import get_supported_scales 38 | 39 | 40 | def _check_drivers(iface, brand, drivers): 41 | print("\t- Checking %s devices:" % brand) 42 | for driver in drivers: 43 | print("\t\t- %s" % driver.model_name) 44 | try: 45 | verifyClass(iface, driver) 46 | except Invalid as e: 47 | print("ERROR: ", e) 48 | 49 | 50 | def _check_printers(iface): 51 | printers_dict = get_supported_printers_by_iface(iface) 52 | for brand, drivers in printers_dict.items(): 53 | _check_drivers(iface, brand, drivers) 54 | 55 | 56 | def check_coupon_printers(): 57 | print("Checking Coupon Printers...") 58 | _check_printers(ICouponPrinter) 59 | 60 | 61 | def check_cheque_printers(): 62 | print("Checking Cheque Printers...") 63 | _check_printers(IChequePrinter) 64 | 65 | 66 | def check_scales(): 67 | print("Checking Scales...") 68 | for brand, drivers in get_supported_scales().items(): 69 | _check_drivers(IScale, brand, drivers) 70 | 71 | 72 | if __name__ == "__main__": 73 | check_coupon_printers() 74 | check_cheque_printers() 75 | check_scales() 76 | -------------------------------------------------------------------------------- /docs/examples/fiscal.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- Mode: Python; coding: utf-8 -*- 3 | # vi:si:et:sw=4:sts=4:ts=4 4 | 5 | ## 6 | ## Stoqdrivers 7 | ## Copyright (C) 2006 Async Open Source 8 | ## All rights reserved 9 | ## 10 | ## This program is free software; you can redistribute it and/or modify 11 | ## it under the terms of the GNU General Public License as published by 12 | ## the Free Software Foundation; either version 2 of the License, or 13 | ## (at your option) any later version. 14 | ## 15 | ## This program is distributed in the hope that it will be useful, 16 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ## GNU General Public License for more details. 19 | ## 20 | ## You should have received a copy of the GNU General Public License 21 | ## along with this program; if not, write to the Free Software 22 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 23 | ## USA. 24 | ## 25 | ## Author(s): Johan Dahlin 26 | ## Henrique Romano 27 | ## 28 | 29 | 30 | from decimal import Decimal 31 | 32 | from stoqdrivers.printers.fiscal import FiscalPrinter 33 | from stoqdrivers.exceptions import (PendingReduceZ, 34 | PendingReadX, 35 | CouponOpenError,) 36 | from stoqdrivers.enum import PaymentMethodType, TaxType, UnitType 37 | 38 | 39 | def example(): 40 | printer = FiscalPrinter() 41 | printer.identify_customer('Henrique Romano', 'Async', '1234567890') 42 | while True: 43 | try: 44 | printer.open() 45 | break 46 | except PendingReduceZ: 47 | printer.close_till() 48 | return 49 | except PendingReadX: 50 | printer.summarize() 51 | return 52 | except CouponOpenError: 53 | printer.cancel() 54 | 55 | item1_id = printer.add_item("123456", u"Hollywóód", 56 | Decimal("2.00"), TaxType.SUBSTITUTION, 57 | unit=UnitType.CUSTOM, unit_desc=u"mç") 58 | printer.add_item("654321", u"Heineken Beer", 59 | Decimal("1.53"), TaxType.NONE, 60 | items_quantity=Decimal("5"), 61 | unit=UnitType.LITERS) 62 | printer.cancel_item(item1_id) 63 | printer.totalize(discount=Decimal('1.0')) 64 | printer.add_payment(PaymentMethodType.MONEY, Decimal('2.00')) 65 | printer.add_payment(PaymentMethodType.MONEY, Decimal('11.00')) 66 | coupon_id = printer.close() 67 | print("+++ coupon %d created." % coupon_id) 68 | 69 | 70 | if __name__ == "__main__": 71 | example() 72 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-summarize.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1b\xcf 6 | R :X003282\r 7 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-read-memory.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1b\xd1x010113300113 6 | R :M003293\r 7 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-read-memory-by-reductions.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1b\xd1x000001000010 6 | R :M003294\r 7 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-till-remove-cash.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1b\xd9A1000000000000000000001000\xff 6 | R :N003267A000000001000\r 7 | -------------------------------------------------------------------------------- /stoqdrivers/printers/sweda/SI300.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2017-2019 Stoq Tecnologia 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | 19 | from zope.interface import implementer 20 | 21 | from stoqdrivers.serialbase import SerialBase 22 | from stoqdrivers.escpos import EscPosMixin, ESC 23 | from stoqdrivers.interfaces import INonFiscalPrinter 24 | 25 | 26 | @implementer(INonFiscalPrinter) 27 | class SI300(SerialBase, EscPosMixin): 28 | LINE_FEED = '\x0a' 29 | 30 | FLAG_CONDENSED = 0 # 1 31 | FLAG_BOLD = 3 # 8 32 | FLAG_DOUBLE_HEIGHT = 4 # 16 33 | 34 | max_characters = 56 35 | supported = True 36 | model_name = "Sweda SI-300" 37 | 38 | def __init__(self, port, consts=None): 39 | self._text_mode = 0 40 | SerialBase.__init__(self, port) 41 | EscPosMixin.__init__(self) 42 | 43 | def _set_text_mode(self, mode): 44 | self._text_mode = mode 45 | self.write(ESC + '!' + chr(mode)) 46 | 47 | def set_condensed(self): 48 | mode = self._text_mode | (2 ** self.FLAG_CONDENSED) 49 | self._set_text_mode(mode) 50 | 51 | def unset_condensed(self): 52 | mode = self._text_mode & ~(2 ** self.FLAG_CONDENSED) 53 | self._set_text_mode(mode) 54 | 55 | def set_bold(self): 56 | mode = self._text_mode | (2 ** self.FLAG_BOLD) 57 | self._set_text_mode(mode) 58 | 59 | def unset_bold(self): 60 | mode = self._text_mode & ~(2 ** self.FLAG_BOLD) 61 | self._set_text_mode(mode) 62 | 63 | def set_double_height(self): 64 | mode = self._text_mode | (2 ** self.FLAG_DOUBLE_HEIGHT) 65 | self._set_text_mode(mode) 66 | 67 | def unset_double_height(self): 68 | mode = self._text_mode & ~(2 ** self.FLAG_DOUBLE_HEIGHT) 69 | self._set_text_mode(mode) 70 | 71 | def print_matrix(self, matrix, api=None, linefeed=True, multiplier=None): 72 | # Unset condensed to prevent blank spaces between lines 73 | was_condensed = self._text_mode & (2 ** self.FLAG_CONDENSED) 74 | self.unset_condensed() 75 | super().print_matrix(matrix, api, linefeed, multiplier=multiplier) 76 | # Reset the previous state if necessary 77 | if was_condensed: 78 | self.set_condensed() 79 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-till-add-cash.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1b\xd9B1000000000000000000001000\xff 6 | R :N003266B000000001000\r 7 | W \x1b\xf2A000000001000\xff 8 | R :000000000000\r 9 | -------------------------------------------------------------------------------- /stoqdrivers/constants.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2005-2007 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Evandro Vale Miquelito 25 | ## Henrique Romano 26 | ## Johan Dahlin 27 | ## 28 | """ 29 | StoqDrivers constants 30 | """ 31 | 32 | from stoqdrivers.enum import PaymentMethodType, TaxType, UnitType 33 | from stoqdrivers.translation import stoqdrivers_gettext 34 | 35 | _ = stoqdrivers_gettext 36 | 37 | # TODO: Improve these descriptions 38 | _constant_descriptions = { 39 | UnitType.WEIGHT: _(u"Weight unit"), 40 | UnitType.METERS: _(u"Meters unit"), 41 | UnitType.LITERS: _(u"Liters unit"), 42 | UnitType.EMPTY: _(u"Empty unit"), 43 | TaxType.ICMS: _(u"ICMS"), 44 | TaxType.SUBSTITUTION: _(u"Substitution"), 45 | TaxType.EXEMPTION: _(u"Exemption"), 46 | TaxType.NONE: _(u"No tax"), 47 | TaxType.SERVICE: _(u"Service tax"), 48 | PaymentMethodType.MONEY: _(u"Money Payment Method"), 49 | PaymentMethodType.CHECK: _(u"Check Payment Method"), 50 | PaymentMethodType.DEBIT_CARD: _(u"Debit card Payment Method"), 51 | PaymentMethodType.CREDIT_CARD: _(u"Credit card Payment Method"), 52 | PaymentMethodType.BILL: _(u"Bill Payment Method"), 53 | PaymentMethodType.FINANCIAL: _(u"Financial Payment Method"), 54 | PaymentMethodType.GIFT_CERTIFICATE: _(u"Gift certificate Payment Method"), 55 | PaymentMethodType.CUSTOM: _(u"Custom Payment Method"), 56 | PaymentMethodType.MULTIPLE: _(u"Multiple Payment Method"), 57 | } 58 | 59 | 60 | def describe_constant(constant_id): 61 | """ Given the constant identifier, return a short string describing it """ 62 | global _constant_descriptions 63 | if not constant_id in _constant_descriptions: 64 | raise ValueError("The constant by id %r doesn't exists or there " 65 | "is no description for it." % constant_id) 66 | return _constant_descriptions[constant_id] 67 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-coupon-open.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1d\xff 8 | R :A0C00C000000\r 9 | W \x1d\xff 10 | R :A0C00C000000\r 11 | W \x1b\xc8 12 | R :A000840\r 13 | W \x1d\xff 14 | R :A0C50C010000\r 15 | W \x1d\xff 16 | R :A0C50C010000\r 17 | W \x1d\xff 18 | R :A0C50C010000\r 19 | W \x1d\xff 20 | R :A0C50C010000\r 21 | W \x1d\xff 22 | R :A0C50C010000\r 23 | W \x1b\xce 24 | R :C000840\r 25 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-summarize.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\x08\x1b\x02\x1c\x00\x00\x0300DD 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c4\x03029C 69 | W \x06 70 | -------------------------------------------------------------------------------- /tools/testdriver.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | # 5 | # Copyright (C) 2007 Async Open Source 6 | # All rights reserved 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | # USA. 22 | # 23 | # Author(s): Johan Dahlin 24 | # 25 | 26 | 27 | import optparse 28 | import sys 29 | 30 | from stoqdrivers.serialbase import SerialPort 31 | from stoqdrivers.utils import get_obj_from_module 32 | 33 | 34 | def main(args): 35 | usage = "usage: %prog [options] command [args]" 36 | parser = optparse.OptionParser(usage=usage) 37 | parser.add_option('-t', '--type', 38 | action="store", 39 | dest="type", 40 | default="printers", 41 | help='Device type') 42 | parser.add_option('-b', '--brand', 43 | action="store", 44 | dest="brand", 45 | help='Device brand') 46 | parser.add_option('-m', '--model', 47 | action="store", 48 | dest="model", 49 | help='Device model') 50 | parser.add_option('-p', '--port', 51 | action="store", 52 | dest="port", 53 | default="/dev/ttyS0", 54 | help='Device port') 55 | 56 | options, args = parser.parse_args(args) 57 | if len(args) < 2: 58 | raise SystemExit("Need a command") 59 | 60 | module_name = 'stoqdrivers.%s.%s.%s' % (options.type, options.brand, options.model) 61 | driver = get_obj_from_module(module_name, obj_name=options.model) 62 | device = driver(port=SerialPort(options.port)) 63 | 64 | command = args[1] 65 | cb = getattr(device, command) 66 | 67 | items = [] 68 | for item in args[2:]: 69 | try: 70 | item = int(item) 71 | except ValueError: 72 | pass 73 | items.append(item) 74 | print(items) 75 | retval = cb(*items) 76 | if retval is not None: 77 | print('%s returned:' % (command,)) 78 | import pprint 79 | pprint.pprint(retval) 80 | return 0 81 | 82 | 83 | if __name__ == '__main__': 84 | sys.exit(main(sys.argv)) 85 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-read-memory-by-reductions.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\t\x10\x1c\x00\x00\x1c1\x1c10\x1c\x1c\x0301D3 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024C 69 | W \x06 70 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-cancel-coupon.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1d\xff 8 | R :A0C00C000000\r 9 | W \x1d\xff 10 | R :A0C00C000000\r 11 | W \x1b\xc8 12 | R :A000824\r 13 | W \x1cF\xc92100010000000100010000000000000 987654 UNMonitor LG 775N\xffX 14 | R :0000000\xc9001100000001000\r\xff 15 | W \x1d\xff 16 | R :A0C50C010000\r 17 | W \x1d\xff 18 | R :A0C50C010000\r 19 | W \x1d\xff 20 | R :A0C50C010000\r 21 | W \x1b\xce 22 | R :C000824\r 23 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-read-memory.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x80\x030085\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\t\x10\x1c\x00\x01\x1c\x1c\x1c01012013\x1c30012013\x030454 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024C 69 | W \x06 70 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-coupon-open.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1d\xff 6 | R :A5C20C000000\r 7 | W \x1d\xff 8 | R :A5C20C000000\r 9 | W \x1b\xc8 10 | R :A003263\r 11 | W \x1d\xff 12 | R :A5C60C010000\r 13 | W \x1d\xff 14 | R :A5C60C010000\r 15 | W \x1d\xff 16 | R :A5C60C010000\r 17 | W \x1d\xff 18 | R :A5C60C010000\r 19 | W \x1d\xff 20 | R :A5C70C010000\r 21 | W \x1b\xce 22 | R :C003263\r 23 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-cancel-coupon.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1d\xff 6 | R :A5C20C000000\r 7 | W \x1d\xff 8 | R :A5C20C000000\r 9 | W \x1b\xc8 10 | R :A003260\r 11 | W \x1b\xdfNb 98765400000000001000000001000 Monitor LG 775N\xff 12 | R :+001 N 0000000001000\r 13 | W \x1d\xff 14 | R :A5C60C010000\r 15 | W \x1d\xff 16 | R :A5C60C010000\r 17 | W \x1d\xff 18 | R :A5C60C010000\r 19 | W \x1b\xce 20 | R :C003260\r 21 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-has-open-coupon.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1d\xff 8 | R :A0C00C000000\r 9 | W \x1d\xff 10 | R :A0C00C000000\r 11 | W \x1b\xc8 12 | R :A000830\r 13 | W \x1b\xef 14 | R :\x1b\xef000110008301644052711201300000000000000000000000007819596\r 15 | W \x1d\xff 16 | R :A0C40C000000\r 17 | W \x1d\xff 18 | R :A0C40C000000\r 19 | W \x1d\xff 20 | R :A0C40C000000\r 21 | W \x1b\xce 22 | R :C000830\r 23 | W \x1b\xef 24 | R :E99\r 25 | W \x1b\xef 26 | R :\x1b\xef000120008311644062711201300000000000000000000000007819596\r:\x1b\xef000120008311644062711201300000000000000000000000007819596\r 27 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-till-add-cash.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\x0e\x01\x1c\x00\x00\x1c\x0300E3 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x88\x1c\x1c\x00\x00\x1c\x030254 69 | W \x06 70 | W \x02\x98\x0e\x15\x1c\x00\x00\x1c02\x1c1000\x030237 71 | R \x06\x02\x98\x00\x00\x1c\xc0\x88\x1c\x1c\x00\x00\x1c\x030255 72 | W \x06 73 | W \x02\x99\x0e\x06\x1c\x00\x00\x0300CE 74 | R \x06\x02\x99\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c8\x0302A2 75 | W \x06 76 | -------------------------------------------------------------------------------- /stoqdrivers/scales/micheletti/MicP15.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | # Stoqdrivers 4 | # Copyright (C) 2018 Async Open Source 5 | # All rights reserved 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | # USA. 21 | # 22 | from decimal import Decimal 23 | 24 | from zope.interface import implementer 25 | 26 | from stoqdrivers.exceptions import InvalidReply 27 | from stoqdrivers.interfaces import IScale, IScaleInfo 28 | from stoqdrivers.serialbase import SerialBase, SerialPort 29 | 30 | STX = 0x02 31 | ETX = 0x03 32 | 33 | PRICE_PRECISION = 2 34 | QUANTITY_PRECISION = 3 35 | 36 | 37 | @implementer(IScaleInfo) 38 | class Package: 39 | SIZE = 22 40 | 41 | def __init__(self, raw_data): 42 | self.code = None 43 | self.price_per_kg = None 44 | self.total_price = None 45 | self.weight = None 46 | self._parse(raw_data) 47 | 48 | def _parse(self, data): 49 | if not data: 50 | return 51 | elif ord(data[0]) != STX or len(data) != self.SIZE: 52 | raise InvalidReply("Received inconsistent data") 53 | 54 | self.weight = Decimal(data[1:7]) / (10 ** QUANTITY_PRECISION) 55 | self.price_per_kg = Decimal(data[8:14]) / (10 ** PRICE_PRECISION) 56 | self.total_price = Decimal(data[15:21]) / (10 ** PRICE_PRECISION) 57 | 58 | 59 | @implementer(IScale) 60 | class MicP15(SerialBase): 61 | CMD_PREFIX = "\x05" 62 | EOL_DELIMIT = chr(ETX) 63 | 64 | model_name = "Micheletti P15" 65 | 66 | def __init__(self, device, consts=None): 67 | SerialBase.__init__(self, device) 68 | self._package = None 69 | 70 | def _get_package(self): 71 | # PESO, PRECO, TOTAL 72 | # b'\x02 0800 99999 79999\x03' 73 | reply = self.writeline('') 74 | 75 | # The sum is just because readline (called internally by writeline) 76 | # remove the EOL_DELIMIT from the package received and we need send 77 | # to Package's constructor the whole data. 78 | return Package(reply + MicP15.EOL_DELIMIT) 79 | 80 | # 81 | # IScale implementation 82 | # 83 | 84 | def read_data(self): 85 | return self._get_package() 86 | 87 | 88 | if __name__ == "__main__": 89 | port = SerialPort('/dev/ttyS0') 90 | r = MicP15(port) 91 | data = r.read_data() 92 | 93 | print("WEIGHT:", data.weight) 94 | print("PRICE BY KG:", data.price_per_kg) 95 | print("TOTAL PRICE:", data.total_price) 96 | print("CODE:", data.code) 97 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-till-remove-cash.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\x0e\x01\x1c\x00\x00\x1c\x0300E3 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x88\x1c\x1c\x00\x00\x1c\x030254 69 | W \x06 70 | W \x02\x98\x0e\x15\x1c\x00\x00\x1c01\x1c1000\x030236 71 | R \x06\x02\x98\x00\x00\x1c\xc0\x88\x1c\x1c\x00\x00\x1c\x030255 72 | W \x06 73 | W \x02\x99\x0e\x06\x1c\x00\x00\x0300CE 74 | R \x06\x02\x99\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c9\x0302A3 75 | W \x06 76 | -------------------------------------------------------------------------------- /stoqdrivers/escp.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Copyright (C) 2007 Async Open Source 6 | ## All rights reserved 7 | ## 8 | ## This program is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU Lesser General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## This program is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU Lesser General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | ## USA. 22 | ## 23 | ## Author(s): Johan Dahlin 24 | ## 25 | # 26 | # Documentation references: 27 | # 28 | # http://en.wikipedia.org/wiki/ESC/P 29 | # http://www.epson.co.uk/support/manuals/pdf/ESCP/Part_1.pdf 30 | # http://www.epson.co.uk/support/manuals/pdf/ESCP/Part_2.pdf 31 | # 32 | """ Driver for EPSON Esc/P and Esc/P2 printers. """ 33 | 34 | import struct 35 | 36 | ESC = '\x1b' 37 | 38 | CMD_INIT = '@' 39 | CMD_PRINT_QUALITY = 'x' 40 | CMD_PROPORTIONAL = 'p' 41 | CMD_FORM_FEED = '\xff' 42 | CMD_EJECT = '\x19' 43 | 44 | QUALITY_DRAFT = '0' 45 | QUALITY_LQ = '1' 46 | QUALITY_NLQ = '1' 47 | 48 | 49 | class EscPPrinter(object): 50 | def __init__(self, device): 51 | self.device = device 52 | self.fp = open(device, 'w') 53 | 54 | self._command(CMD_INIT) 55 | 56 | def _command(self, command, *args): 57 | chars = command 58 | for arg in args: 59 | if arg is True: 60 | v = '1' 61 | elif arg is False: 62 | v = '0' 63 | else: 64 | v = arg 65 | 66 | chars += v 67 | cmd = '%s%s' % (ESC, chars) 68 | self.send(cmd) 69 | 70 | def send(self, data): 71 | self.fp.write(data) 72 | self.fp.flush() 73 | 74 | def set_draft_mode(self): 75 | self._command(CMD_PRINT_QUALITY, QUALITY_DRAFT) 76 | 77 | def set_proportional(self, proportional): 78 | self._command(CMD_PROPORTIONAL, proportional) 79 | 80 | def done(self): 81 | self._command(CMD_INIT) 82 | 83 | def form_feed(self): 84 | self._command(CMD_FORM_FEED) 85 | 86 | def set_vertical_position(self, position): 87 | args = struct.pack('b', position) 88 | self._command('J', *args) 89 | 90 | 91 | def test(): 92 | printer = EscPPrinter('/dev/lp0') 93 | printer.send( 94 | 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ' 95 | 'Ut a velit sit amet nisl hendrerit lacinia. Nunc eleifend ' 96 | 'cursus risus. Vivamus libero libero, dignissim ut, pulvinar id, ' 97 | 'blandit a, leo amet.\n'.upper()) 98 | 99 | printer.done() 100 | 101 | 102 | if __name__ == '__main__': 103 | test() 104 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-has-open-coupon.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1d\xff 6 | R :A5C60C000000\r 7 | W \x1d\xff 8 | R :A5C60C000000\r 9 | W \x1d\xff 10 | R :A5C60C000000\r 11 | W \x1d\xff 12 | R :A5C60C000000\r 13 | W \x1d\xff 14 | R :A5C60C000000\r 15 | W \x1b\xce 16 | R :C003285\r 17 | W \x1d\xff 18 | R :A5C30C010000\r 19 | W \x1d\xff 20 | R :A5C30C010000\r 21 | W \x1b\xc8 22 | R :A003286\r 23 | W \x1b\xef 24 | R :\x1b\xef000110032860734132204201300000000000000000000000104736184\r 25 | W \x1d\xff 26 | R :A5C70C010000\r 27 | W \x1d\xff 28 | R :A5C70C010000\r 29 | W \x1d\xff 30 | R :A5C70C010000\r 31 | W \x1b\xce 32 | R :C003286\r 33 | W \x1b\xef 34 | R :\x1b\xef000120032870734142204201300000000000000000000000104736184\r 35 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-gerencial-report.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1b\xd3 8 | R :A000829\r 9 | W \x1b\xd5Teste Relatorio Gerencial\xff 10 | R :\r 11 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 12 | R :\r 13 | W \x1b\xd5\xff 14 | R :\r 15 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 16 | R :\r 17 | W \x1b\xd5\xff 18 | R :\r 19 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 20 | R :\r 21 | W \x1b\xd5\xff 22 | R :\r 23 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 24 | R :\r 25 | W \x1b\xd5\xff 26 | R :\r 27 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 28 | R :\r 29 | W \x1b\xd5\xff 30 | R :\r 31 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 32 | R :\r 33 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 34 | R :\r 35 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 36 | R :\r 37 | W \x1b\xd4 38 | R :F\r 39 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-has-open-coupon.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03024D 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03024E 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03024F 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030250 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030251 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030252 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\x00\x01\x1c\x00\x00\x0300B9 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024C 69 | W \x06 70 | W \x02\x98\n\x01\x1c\x00\x00\x1c\x1c\x0300FC 71 | R \x06\x02\x98\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024E 72 | W \x06 73 | W \x02\x99\x00\x01\x1c\x00\x00\x0300BB 74 | R \x06\x02\x99\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024F 75 | W \x06 76 | W \x02\x9a\x00\x01\x1c\x00\x00\x0300BC 77 | R \x06\x02\x9a\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x030250 78 | W \x06 79 | W \x02\x9b\n\x18\x1c\x00\x08\x1c1\x030133 80 | R \x06\x02\x9b\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c0\x1c0\x0302E8 81 | W \x06 82 | W \x02\x9c\x00\x01\x1c\x00\x00\x0300BE 83 | R \x06\x02\x9c\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x030251 84 | W \x06 85 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-gerencial-report.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1b\xd3 6 | R :A003296\r 7 | W \x1b\xd5Teste Relatorio Gerencial\xff 8 | R :E21\r 9 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 10 | R :\r 11 | W \x1b\xd5\xff 12 | R :\r 13 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 14 | R :\r 15 | W \x1b\xd5\xff 16 | R :\r 17 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 18 | R :\r 19 | W \x1b\xd5\xff 20 | R :\r 21 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 22 | R :\r 23 | W \x1b\xd5\xff 24 | R :\r 25 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 26 | R :\r 27 | W \x1b\xd5\xff 28 | R :\r 29 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 30 | R :\r 31 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 32 | R :\r 33 | W \x1b\xd5ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\xff 34 | R :\r 35 | W \x1b\xd4 36 | R :\r 37 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-coupon-open.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x80\x030085\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cTa\x1c1700\x1c0000\x1cTb\x1c1200\x1c0000\x1cTc\x1c2500\x1c0000\x1cTd\x1c0800\x1c0000\x1cTe\x1c0500\x1c0000\x1cSa\x1c0300\x1c0000\x1cSb\x1c0900\x1c0000\x03143E 66 | W \x06 67 | W \x02\x97\x00\x01\x1c\x00\x00\x0300B9 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024C 69 | W \x06 70 | W \x02\x98\n\x01\x1c\x00\x00\x1c\x1c\x0300FC 71 | R \x06\x02\x98\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024E 72 | W \x06 73 | W \x02\x99\x00\x01\x1c\x00\x00\x0300BB 74 | R \x06\x02\x99\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024F 75 | W \x06 76 | W \x02\x9a\x00\x01\x1c\x00\x00\x0300BC 77 | R \x06\x02\x9a\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x030250 78 | W \x06 79 | W \x02\x9b\n\x18\x1c\x00\x08\x1c1\x030133 80 | R \x06\x02\x9b\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c0\x1c0\x0302E8 81 | W \x06 82 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-cancel-coupon.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\x00\x01\x1c\x00\x00\x0300B9 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024C 69 | W \x06 70 | W \x02\x98\n\x01\x1c\x00\x00\x1c\x1c\x0300FC 71 | R \x06\x02\x98\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024E 72 | W \x06 73 | W \x02\x99\x00\x01\x1c\x00\x00\x0300BB 74 | R \x06\x02\x99\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024F 75 | W \x06 76 | W \x02\x9a\n\x1b\x02\x1c\x00\x00\x1c987654\x1cMonitor LG 775N\x1c1000\x1cUN\x1c1000\x1cN\x0309F0 77 | R \x06\x02\x9a\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x1c1\x03029D 78 | W \x06 79 | W \x02\x9b\x00\x01\x1c\x00\x00\x0300BD 80 | R \x06\x02\x9b\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x030251 81 | W \x06 82 | W \x02\x9c\n\x18\x1c\x00\x08\x1c1\x030134 83 | R \x06\x02\x9c\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c0\x1c0\x0302E9 84 | W \x06 85 | -------------------------------------------------------------------------------- /stoqdrivers/printers/daruma/DR700.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Copyright (C) 2015 Async Open Source 6 | ## All rights reserved 7 | ## 8 | ## This program is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU Lesser General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## This program is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., or visit: http://www.gnu.org/. 21 | ## 22 | ## Author(s): Stoq Team 23 | ## 24 | 25 | from zope.interface import implementer 26 | 27 | from stoqdrivers.interfaces import INonFiscalPrinter 28 | from stoqdrivers.serialbase import SerialBase 29 | 30 | ESC = '\x1b' 31 | SI = '\x0f' 32 | DC2 = '\x12' 33 | 34 | NORMAL_FONT = ESC + '\x21\x00\x00' 35 | 36 | CONDENSED_MODE = ESC + SI + '\x00' 37 | NORMAL_MODE = DC2 38 | 39 | CENTRALIZE = ESC + 'j\x01' 40 | DESCENTRALIZE = ESC + 'j\x00' 41 | 42 | DOUBLE_HEIGHT_ON = ESC + 'w\x01' 43 | DOUBLE_HEIGHT_OFF = ESC + 'w\x00' 44 | 45 | SET_BOLD = ESC + 'E' 46 | UNSET_BOLD = ESC + 'F' 47 | 48 | 49 | @implementer(INonFiscalPrinter) 50 | class DR700(SerialBase): 51 | 52 | supported = True 53 | model_name = "Daruma DR 700" 54 | 55 | max_characters = 57 56 | 57 | def __init__(self, port, consts=None): 58 | SerialBase.__init__(self, port) 59 | self.set_condensed() 60 | self.descentralize() 61 | self.unset_bold() 62 | self.unset_double_height() 63 | 64 | def centralize(self): 65 | self.write(CENTRALIZE) 66 | 67 | def descentralize(self): 68 | self.write(DESCENTRALIZE) 69 | 70 | def set_bold(self): 71 | self.write(SET_BOLD) 72 | 73 | def unset_bold(self): 74 | self.write(UNSET_BOLD) 75 | 76 | def set_condensed(self): 77 | self.write(CONDENSED_MODE) 78 | 79 | def unset_condensed(self): 80 | self.write(NORMAL_MODE) 81 | 82 | def set_double_height(self): 83 | self.write(DOUBLE_HEIGHT_ON) 84 | 85 | def unset_double_height(self): 86 | self.write(DOUBLE_HEIGHT_OFF) 87 | 88 | def print_line(self, data): 89 | self.write(data + b'\n') 90 | 91 | def print_inline(self, data): 92 | self.write(data) 93 | 94 | def print_barcode(self, code): 95 | code_128 = chr(5) 96 | width = chr(2) 97 | height = chr(80) 98 | barcode_label = chr(0) 99 | self.write(ESC + '\x62%s%s%s%s%s\x00' % (code_128, width, height, 100 | barcode_label, code)) 101 | self.write('\x0A') 102 | 103 | def print_qrcode(self, code): 104 | bytes_len = len(code) 105 | min_size = chr(bytes_len >> 8) 106 | max_size = chr((bytes_len & 255) + 2) 107 | width = chr(3) 108 | # Correction level: auto 109 | correction = chr(0) 110 | self.write(ESC + '\x81%s%s%s%s%s' % (max_size, min_size, width, correction, code)) 111 | self.write('\x0A') 112 | 113 | def cut_paper(self): 114 | # FIXME: Ensure the paper is safely out of the paper-cutter before 115 | # executing the cut. 116 | self.print_inline('\n' * 2) 117 | self.write(ESC + '\x6d') 118 | -------------------------------------------------------------------------------- /stoqdrivers/usbbase.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2016 Stoq Tecnologia 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | 24 | 25 | try: 26 | import usb.core 27 | import usb.util 28 | has_usb = True 29 | except ImportError: 30 | has_usb = False 31 | 32 | from stoqdrivers.exceptions import USBDriverError 33 | from stoqdrivers.utils import str2bytes 34 | 35 | # Based on python-escpos's escpos.printer.Usb: 36 | # 37 | # https://github.com/python-escpos/python-escpos/blob/master/src/escpos/printer.py 38 | 39 | 40 | class UsbBase(object): 41 | """Base class for a USB Printer""" 42 | 43 | #: Out Endpoint address. Subclasses must define this. 44 | out_ep = None 45 | 46 | def __init__(self, vendor_id, product_id, interface=0, 47 | timeout=0, *args, **kwargs): 48 | assert has_usb 49 | self.device = None 50 | self.vendor_id = vendor_id 51 | self.product_id = product_id 52 | self.interface = interface 53 | self.timeout = timeout 54 | assert self.out_ep is not None 55 | super(UsbBase, self).__init__(*args, **kwargs) 56 | 57 | def __del__(self): 58 | """Stop using any unnecessary resources upon destruction""" 59 | self.close() 60 | 61 | def open(self): 62 | self.device = usb.core.find(idVendor=self.vendor_id, 63 | idProduct=self.product_id) 64 | if self.device is None: 65 | raise USBDriverError('USB Device not found using %s:%s' % 66 | (self.vendor_id, self.product_id)) 67 | 68 | check_driver = None 69 | try: 70 | check_driver = self.device.is_kernel_driver_active(0) 71 | except NotImplementedError: 72 | check_driver = False 73 | 74 | if check_driver is None or check_driver: 75 | try: 76 | self.device.detach_kernel_driver(0) 77 | except usb.core.USBError as e: 78 | if check_driver is not None: 79 | print(("Could not detatch kernel driver: {0}".format(str(e)))) 80 | 81 | # This was required at some point, but stopped working. Is this really necessary? Are we 82 | # doing something wrong? 83 | #self.device.set_configuration() 84 | self.device.reset() 85 | 86 | def close(self): 87 | """Release the USB interface""" 88 | if self.device: 89 | usb.util.dispose_resources(self.device) 90 | self.device = None 91 | 92 | def write(self, data): 93 | """Write any data to the USB printer 94 | 95 | :param data: Any data to be written 96 | :type data: bytes 97 | """ 98 | if not self.device: 99 | self.open() 100 | self.device.write(self.out_ep, str2bytes(data), self.timeout) 101 | # FIXME: we cant keep opening/closing the device, otherwise it gets 102 | # *really* slow to print. 103 | #self.close() 104 | -------------------------------------------------------------------------------- /stoqdrivers/configparser.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2005 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Evandro Vale Miquelito 25 | ## Henrique Romano 26 | ## 27 | """ 28 | Useful routines when parsing the configuration file 29 | """ 30 | import os 31 | from configparser import ConfigParser 32 | 33 | from stoqdrivers.exceptions import ConfigError 34 | from stoqdrivers.translation import stoqdrivers_gettext 35 | 36 | _ = stoqdrivers_gettext 37 | 38 | 39 | class StoqdriversConfig: 40 | 41 | domain = 'stoq' 42 | 43 | def __init__(self, filename=None): 44 | """ filename is the name of the configuration file we're reading """ 45 | 46 | self.filename = filename or ('stoqdrivers.conf') 47 | self.config = ConfigParser() 48 | self._load_config() 49 | 50 | def get_homepath(self): 51 | return os.path.join(os.getenv('HOME'), '.' + self.domain) 52 | 53 | def _open_config(self, path): 54 | filename = os.path.join(path, self.filename) 55 | if not os.path.exists(filename): 56 | return False 57 | self.config.read(filename) 58 | return True 59 | 60 | def _load_config(self): 61 | # Try to load configuration from: 62 | # 1) $HOME/.$domain/$filename 63 | # 2) $PREFIX/etc/$domain/$filename 64 | # 3) /etc/$filename 65 | 66 | # This is a bit hackish: 67 | # $prefix / lib / $DOMAIN / lib / configparser.py 68 | # -4 -3 -2 -1 0 69 | filename = os.path.abspath(__file__) 70 | stripped = filename.split(os.sep)[:-4] 71 | self.prefix = os.path.join(os.sep, *stripped) 72 | 73 | homepath = self.get_homepath() 74 | etcpath = os.path.join(self.prefix, 'etc', self.domain) 75 | globetcpath = os.path.join(os.sep, 'etc', self.domain) 76 | if not (self._open_config(homepath) or self._open_config(etcpath) or 77 | self._open_config(globetcpath)): 78 | raise ConfigError(_("Config file %s not found in: `%s', `%s' and " 79 | "`%s'") % (self.filename, homepath, etcpath, globetcpath)) 80 | 81 | def has_section(self, section): 82 | return self.config.has_section(section) 83 | 84 | def has_option(self, name, section='General'): 85 | return self.config.has_option(section, name) 86 | 87 | def get_option(self, name, section='General'): 88 | if not self.config.has_section(section): 89 | raise ConfigError(_("Invalid section: %s") % section) 90 | elif not self.config.has_option(section, name): 91 | raise ConfigError(_("%s does not have option: %s") 92 | % (self.filename, name)) 93 | return self.config.get(section, name) 94 | 95 | def set_option(self, name, section='General'): 96 | if not self.config.has_section(section): 97 | raise ConfigError(_("Invalid section: %s") % section) 98 | self.config.set(section, name) 99 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-totalize.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\x00\x01\x1c\x00\x00\x0300B9 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024C 69 | W \x06 70 | W \x02\x98\n\x01\x1c\x00\x00\x1c\x1c\x0300FC 71 | R \x06\x02\x98\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024E 72 | W \x06 73 | W \x02\x99\x00\x01\x1c\x00\x00\x0300BB 74 | R \x06\x02\x99\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024F 75 | W \x06 76 | W \x02\x9a\n\x1b\x02\x1c\x00\x00\x1c987654\x1cMonitor LG 775N\x1c1000\x1cUN\x1c1000\x1cN\x0309F0 77 | R \x06\x02\x9a\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x1c1\x03029D 78 | W \x06 79 | W \x02\x9b\n\x04\x1c\x00\x07\x1c100\x03017E 80 | R \x06\x02\x9b\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x1c1100\x03032F 81 | W \x06 82 | W \x02\x9c\n\x05\x1c\x00\x00\x1c1\x1c1200\x1c\x1c\x030230 83 | R \x06\x02\x9c\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x1c0\x1c100\x03034B 84 | W \x06 85 | W \x02\x9d\n \x1c\x00\x1b\x02\x1c1234567890\x1cHenrique Romano\x1cAsync\x1c\x030B4D 86 | R \x06\x02\x9d\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x030253 87 | W \x06 88 | W \x02\x9e\n\x06\x1c\x00\x01\x0300D0 89 | R \x06\x02\x9e\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c1\x1c1100\x1c100\x03042B 90 | W \x06 91 | W \x02\x9f\x07\x1b\x02\x1c\x00\x00\x0300E4 92 | R \x06\x02\x9f\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x030254 93 | W \x06 94 | -------------------------------------------------------------------------------- /tests/data/daruma-FS2100-sintegra.txt: -------------------------------------------------------------------------------- 1 | W \x1cR\xc8139\xbd 2 | R :\xc813932\r\xc5 3 | W \x1b\xee 4 | R : -Sangria +Suprimento +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff +\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Cheque Boleto Cart\xc4o Cr\xc8dito Cart\xc4o D\xc8bito Financeira Vale Compra \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff NDinheiro VCheque VBoleto VCart\xc4o Cr\xc8dito VCart\xc4o D\xc8bito VFinanceira VVale Compra V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff V\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \r 5 | W \x1b\xe7 6 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 7 | W \x1b\xf4 8 | R :\x1b\xf4000819000834000327000400010000000000010050330100000000040000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000278000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025000000000000000000000000\r 9 | W \x1b\xf0 10 | R :\x1b\xf000000000000778339600000000000000000000000240000000000000000000000000013200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200\r 11 | W \x1b\xe7 12 | R :%A0700B1200C1800D2500e0200F////G////H////I////J////K////L////M////N////O////P////\r 13 | W \x1b\xfa 14 | R :271113092953271113164416\r 15 | W \x1b\xec 16 | R :V0025863901010001271113\r 17 | -------------------------------------------------------------------------------- /tests/data/epson-FBIII-add-payment.txt: -------------------------------------------------------------------------------- 1 | W \x02\x81\x05\x85\x1c\x00\x00\x03012C 2 | R \x06\x02\x81\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c3\x1c2\x0302D3 3 | W \x06 4 | W \x02\x82\x05\r\x1c\x00\x00\x1c1\x030102 5 | R \x06\x02\x82\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cDinheiro\x1cN\x0305EF 6 | W \x06 7 | W \x02\x83\x05\r\x1c\x00\x00\x1c2\x030104 8 | R \x06\x02\x83\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCheque\x1cN\x030519 9 | W \x06 10 | W \x02\x84\x05\r\x1c\x00\x00\x1c3\x030106 11 | R \x06\x02\x84\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cBoleto\x1cN\x030524 12 | W \x06 13 | W \x02\x85\x05\r\x1c\x00\x00\x1c4\x030108 14 | R \x06\x02\x85\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao credito\x1cS\x030829 15 | W \x06 16 | W \x02\x86\x05\r\x1c\x00\x00\x1c5\x03010A 17 | R \x06\x02\x86\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cCartao debito\x1cS\x0307B7 18 | W \x06 19 | W \x02\x87\x05\r\x1c\x00\x00\x1c6\x03010C 20 | R \x06\x02\x87\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cFinanceira\x1cN\x0306B2 21 | W \x06 22 | W \x02\x88\x05\r\x1c\x00\x00\x1c7\x03010E 23 | R \x06\x02\x88\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1cVale compra\x1cN\x0306ED 24 | W \x06 25 | W \x02\x89\x05\r\x1c\x00\x00\x1c8\x030110 26 | R \x06\x02\x89\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030253 27 | W \x06 28 | W \x02\x8a\x05\r\x1c\x00\x00\x1c9\x030112 29 | R \x06\x02\x8a\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030254 30 | W \x06 31 | W \x02\x8b\x05\r\x1c\x00\x00\x1c10\x03013B 32 | R \x06\x02\x8b\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030255 33 | W \x06 34 | W \x02\x8c\x05\r\x1c\x00\x00\x1c11\x03013D 35 | R \x06\x02\x8c\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030256 36 | W \x06 37 | W \x02\x8d\x05\r\x1c\x00\x00\x1c12\x03013F 38 | R \x06\x02\x8d\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030257 39 | W \x06 40 | W \x02\x8e\x05\r\x1c\x00\x00\x1c13\x030141 41 | R \x06\x02\x8e\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030258 42 | W \x06 43 | W \x02\x8f\x05\r\x1c\x00\x00\x1c14\x030143 44 | R \x06\x02\x8f\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x030259 45 | W \x06 46 | W \x02\x90\x05\r\x1c\x00\x00\x1c15\x030145 47 | R \x06\x02\x80\x030085\x02\x90\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025A 48 | W \x06 49 | W \x02\x91\x05\r\x1c\x00\x00\x1c16\x030147 50 | R \x06\x02\x91\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025B 51 | W \x06 52 | W \x02\x92\x05\r\x1c\x00\x00\x1c17\x030149 53 | R \x06\x02\x92\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025C 54 | W \x06 55 | W \x02\x93\x05\r\x1c\x00\x00\x1c18\x03014B 56 | R \x06\x02\x93\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025D 57 | W \x06 58 | W \x02\x94\x05\r\x1c\x00\x00\x1c19\x03014D 59 | R \x06\x02\x94\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025E 60 | W \x06 61 | W \x02\x95\x05\r\x1c\x00\x00\x1c20\x030146 62 | R \x06\x02\x95\x00\x00\x1c\xc0\x80\x1c\x1c\t\x0c\x1c\x03025F 63 | W \x06 64 | W \x02\x96\x05B\x1c\x00\x00\x0300FE 65 | R \x06\x02\x96\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024B 66 | W \x06 67 | W \x02\x97\x00\x01\x1c\x00\x00\x0300B9 68 | R \x06\x02\x97\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x03024C 69 | W \x06 70 | W \x02\x98\n\x01\x1c\x00\x00\x1c\x1c\x0300FC 71 | R \x06\x02\x98\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024E 72 | W \x06 73 | W \x02\x99\x00\x01\x1c\x00\x00\x0300BB 74 | R \x06\x02\x99\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x03024F 75 | W \x06 76 | W \x02\x9a\n\x1b\x02\x1c\x00\x00\x1c987654\x1cMonitor LG 775N\x1c1000\x1cUN\x1c1000\x1cN\x0309F0 77 | R \x06\x02\x9a\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x1c1\x03029D 78 | W \x06 79 | W \x02\x9b\n\x1b\x03\x1c\x00\x00\x0300E4 80 | R \x06\x02\x9b\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x1c1000\x03032E 81 | W \x06 82 | W \x02\x9c\n\x05\x1c\x00\x00\x1c1\x1c10000\x1c\x1c\x03025E 83 | R \x06\x02\x9c\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x1c0\x1c9000\x030383 84 | W \x06 85 | W \x02\x9d\n \x1c\x00\x1b\x02\x1c1234567890\x1cHenrique Romano\x1cAsync\x1c\x030B4D 86 | R \x06\x02\x9d\x00\x00\x1c\xc0\x81\x1c\x1c\x00\x00\x1c\x030253 87 | W \x06 88 | W \x02\x9e\n\x06\x1c\x00\x01\x0300D0 89 | R \x06\x02\x9e\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x1c1\x1c1000\x1c9000\x030462 90 | W \x06 91 | W \x02\x9f\x07\x1b\x02\x1c\x00\x00\x0300E4 92 | R \x06\x02\x9f\x00\x00\x1c\xc0\x80\x1c\x1c\x00\x00\x1c\x030254 93 | W \x06 94 | -------------------------------------------------------------------------------- /tests/data/daruma-FS345-sintegra.txt: -------------------------------------------------------------------------------- 1 | W \x1b\xee 2 | R : -SANGRIA +SUPRIMENTO -\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff-\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffDinheiro Cart o Cr dito VCartCartao Credito \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffNDinheiro NCheque NBoleto VCartao Credito VCartao Debito VFinanceira VVale Compra NPagamento Tipo H NPagamento Tipo I NPagamento Tipo J NPagamento Tipo K NPagamento Tipo L NPagamento Tipo M NPagamento Tipo N NPagamento Tipo O NPagamento Tipo P \r 3 | W \x1b\xe7 4 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 5 | W \x1b\xf4 6 | R :\x1b\xf4003292003294000272093200140510000000010228477100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001405250002463404\r 7 | W \x1b\xf0 8 | R :\x1b\xf000000000010473718400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r 9 | W \x1b\xe7 10 | R :%A0018B0012C0005d0500E1800F1500G2500H0800I0500J0327K0592l0200m0300n0400O////P////\r 11 | W \x1b\xfa 12 | R :000000000000220413074621\r 13 | W \x1b\xec 14 | R :V000608611.200001220413\r 15 | -------------------------------------------------------------------------------- /stoqdrivers/exceptions.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2005 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Evandro Vale Miquelito 25 | ## 26 | """ 27 | StoqDrivers exceptions definition 28 | """ 29 | 30 | 31 | class CriticalError(Exception): 32 | "Unknown device type or bad config settings" 33 | 34 | 35 | class ConfigError(Exception): 36 | "Bad config file arguments or sections" 37 | 38 | 39 | class CommError(Exception): 40 | "Common communication failures" 41 | 42 | 43 | class PrinterError(Exception): 44 | "General printer errors" 45 | 46 | 47 | class DriverError(Exception): 48 | "Base exception for all printer errors" 49 | 50 | def __init__(self, error='', code=-1): 51 | if code != -1: 52 | error = '%d: %s' % (code, error) 53 | Exception.__init__(self, error) 54 | self.code = code 55 | 56 | 57 | class USBDriverError(DriverError): 58 | """A USB Error that was raised by StoqDrivers (and not pyusb)""" 59 | 60 | 61 | class OutofPaperError(DriverError): 62 | "No paper left" 63 | 64 | 65 | class PrinterOfflineError(DriverError): 66 | "Printer is offline" 67 | 68 | 69 | class AlmostOutofPaper(DriverError): 70 | "Almost out of paper" 71 | 72 | 73 | class HardwareFailure(DriverError): 74 | "Unknown hardware failure" 75 | 76 | 77 | class PendingReduceZ(DriverError): 78 | "A Reduce Z is pending" 79 | 80 | 81 | class PendingReadX(DriverError): 82 | "A Read X is pending" 83 | 84 | 85 | class CloseCouponError(DriverError): 86 | "Could not close the coupon." 87 | 88 | 89 | class CouponNotOpenError(DriverError): 90 | "Coupon is not open." 91 | 92 | 93 | class CouponOpenError(DriverError): 94 | "Coupon already is open." 95 | 96 | 97 | class AuthenticationFailure(DriverError): 98 | "General authentication failure" 99 | 100 | 101 | class CommandParametersError(DriverError): 102 | "Parameters sent to printer are wrong." 103 | 104 | 105 | class CommandError(DriverError): 106 | "Command sent to printer is wrong." 107 | 108 | 109 | class ClosedTillError(DriverError): 110 | "No transactions can be done while the till is closed." 111 | 112 | 113 | class ReduceZError(DriverError): 114 | "A Reduce already done." 115 | 116 | 117 | class ReadXError(DriverError): 118 | "A Read X is already done." 119 | 120 | 121 | class CouponTotalizeError(DriverError): 122 | "Error while totalizing a coupon." 123 | 124 | 125 | class PaymentAdditionError(DriverError): 126 | "Error while adding a payment." 127 | 128 | 129 | class CancelItemError(DriverError): 130 | "Error while cancelling coupon item." 131 | 132 | 133 | class InvalidState(DriverError): 134 | "Invalid state for the requested operation." 135 | 136 | 137 | class CapabilityError(Exception): 138 | "General capability error." 139 | 140 | 141 | class ItemAdditionError(DriverError): 142 | "Error while adding an item." 143 | 144 | 145 | class InvalidReply(DriverError): 146 | "Invalid reply received" 147 | 148 | 149 | class AlreadyTotalized(DriverError): 150 | "The coupon is already totalized" 151 | 152 | 153 | class InvalidValue(DriverError): 154 | "The value specified is invalid or is not in the expected range" 155 | 156 | 157 | class InvalidReplyException(DriverError): 158 | "Invalid reply exception raised" 159 | -------------------------------------------------------------------------------- /stoqdrivers/scales/toledo/PrixIII.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2005 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Henrique Romano 25 | ## 26 | """ 27 | Implementation of Toled Prix III driver. 28 | """ 29 | 30 | 31 | from zope.interface import implementer 32 | 33 | from stoqdrivers.exceptions import InvalidReply 34 | from stoqdrivers.interfaces import IScale, IScaleInfo 35 | from stoqdrivers.serialbase import SerialBase, SerialPort 36 | 37 | STX = 0x02 38 | ETX = 0x03 39 | 40 | PRICE_PRECISION = 2 41 | QUANTITY_PRECISION = 3 42 | 43 | 44 | @implementer(IScaleInfo) 45 | class PackagePrt4: 46 | """ This class implements a parser for the 4a protocol of Toledo Prix III 47 | 48 | This protocol requires the user to press the print button. 49 | """ 50 | 51 | SIZE = 25 52 | 53 | def __init__(self, raw_data): 54 | self.code = None 55 | self.price_per_kg = None 56 | self.total_price = None 57 | self.weight = None 58 | self._parse(raw_data) 59 | 60 | def _parse(self, data): 61 | if not data: 62 | return 63 | elif ord(data[0]) != STX or len(data) != self.SIZE: 64 | raise InvalidReply("Received inconsistent data") 65 | self.code = int(data[1:7]) 66 | self.price_per_kg = float(data[12:18]) / (10 ** PRICE_PRECISION) 67 | self.weight = float(data[7:12]) / (10 ** QUANTITY_PRECISION) 68 | self.total_price = float(data[18:24]) / (10 ** PRICE_PRECISION) 69 | 70 | 71 | @implementer(IScaleInfo) 72 | class PackagePrt1: 73 | """ This class implements a parser for the protocol prt1 of Toledo Prix III 74 | 75 | this protocol does not require any interaction from the user. The driver 76 | queries the scale for the weight, and the scale replies 77 | """ 78 | SIZE = 7 79 | 80 | def __init__(self, raw_data): 81 | self.code = None 82 | self.price_per_kg = None 83 | self.total_price = None 84 | self.weight = None 85 | self._parse(raw_data) 86 | 87 | def _parse(self, data): 88 | if not data: 89 | return 90 | elif ord(data[0]) != STX or len(data) != self.SIZE: 91 | raise InvalidReply("Received inconsistent data") 92 | self.weight = float(data[1:6]) / (10 ** QUANTITY_PRECISION) 93 | 94 | 95 | @implementer(IScale) 96 | class PrixIII(SerialBase): 97 | CMD_PREFIX = "\x05" 98 | EOL_DELIMIT = chr(ETX) 99 | 100 | model_name = "Toledo Prix III" 101 | 102 | def __init__(self, device, consts=None): 103 | SerialBase.__init__(self, device) 104 | self._package = None 105 | 106 | def _get_package(self): 107 | reply = self.writeline('') 108 | # The sum is just because readline (called internally by writeline) 109 | # remove the EOL_DELIMIT from the package received and we need send 110 | # to Package's constructor the whole data. 111 | return PackagePrt1(reply + PrixIII.EOL_DELIMIT) 112 | 113 | # 114 | # IScale implementation 115 | # 116 | 117 | def read_data(self): 118 | return self._get_package() 119 | 120 | 121 | if __name__ == "__main__": 122 | port = SerialPort('/dev/ttyS0') 123 | r = PrixIII(port) 124 | data = r.read_data() 125 | 126 | print("WEIGHT:", data.weight) 127 | print("PRICE BY KG:", data.price_per_kg) 128 | print("TOTAL PRICE:", data.total_price) 129 | print("CODE:", data.code) 130 | -------------------------------------------------------------------------------- /stoqdrivers/printers/bematech/DP20C.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python; coding: iso-8859-1 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Stoqdrivers 6 | ## Copyright (C) 2006 Async Open Source 7 | ## All rights reserved 8 | ## 9 | ## This program is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## This program is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | ## USA. 23 | ## 24 | ## Author(s): Henrique Romano 25 | ## 26 | """ 27 | Bematech DP20C driver 28 | """ 29 | 30 | import datetime 31 | 32 | from zope.interface import implementer 33 | 34 | from stoqdrivers.interfaces import IChequePrinter 35 | from stoqdrivers.printers.cheque import BaseChequePrinter 36 | from stoqdrivers.printers.capabilities import Capability 37 | from stoqdrivers.serialbase import SerialBase 38 | 39 | 40 | @implementer(IChequePrinter) 41 | class DP20C(SerialBase, BaseChequePrinter): 42 | CMD_PREFIX = '\x1B' 43 | CMD_SUFFIX = '\x0D' 44 | CMD_SETUP_COORDINATES = '\xAA' 45 | 46 | model_name = "Bematech DP20C" 47 | cheque_printer_charset = "cp850" 48 | 49 | def __init__(self, port, consts=None): 50 | SerialBase.__init__(self, port) 51 | BaseChequePrinter.__init__(self) 52 | 53 | def _setup_positions(self, bank): 54 | # man page 24. 55 | data = [(bank.get_x_coordinate("value") - 60) / 10, 56 | (bank.get_x_coordinate("value") - 60) % 10, 57 | bank.get_y_coordinate("value"), 58 | bank.get_x_coordinate("legal_amount") / 10, 59 | bank.get_x_coordinate("legal_amount") % 10, 60 | bank.get_y_coordinate("legal_amount"), 61 | bank.get_x_coordinate("legal_amount2") % 10, 62 | bank.get_y_coordinate("legal_amount2") % 10, 63 | bank.get_x_coordinate("thirdparty") % 10, 64 | bank.get_y_coordinate("thirdparty") % 10, 65 | bank.get_x_coordinate("city") / 10, 66 | bank.get_x_coordinate("day") / 10, 67 | bank.get_x_coordinate("day") % 10, 68 | bank.get_x_coordinate("month") / 10, 69 | bank.get_x_coordinate("month") % 10, 70 | bank.get_x_coordinate("year") % 10] 71 | data = "".join([str(d) for d in data]) 72 | self.write("%c%c987? %s%c" % (DP20C.CMD_PREFIX, 73 | DP20C.CMD_SETUP_COORDINATES, 74 | data, DP20C.CMD_SUFFIX)) 75 | 76 | def _setup_cheque(self, bank, value, thirdparty, city, 77 | date=None): 78 | if date is None: 79 | date = datetime.datetime.now() 80 | self._setup_positions(bank) 81 | value = "%.02f" % value 82 | if "." in value: 83 | value.replace(".", ",") 84 | date = date.strftime("%02d/%02m/%Y") 85 | bank_code = "987" 86 | for idx, data in enumerate((thirdparty, city, bank_code, value, date)): 87 | s = "%c%s" % (0xA0 + idx, data) 88 | self.write(DP20C.CMD_PREFIX + s + DP20C.CMD_SUFFIX) 89 | 90 | def _print_cheque(self): 91 | for data in (0xB1, 0xB0): 92 | self.write(DP20C.CMD_PREFIX + chr(data)) 93 | 94 | # 95 | # IChequePrinter implementation 96 | # 97 | 98 | def print_cheque(self, *args, **kwargs): 99 | self._setup_cheque(*args, **kwargs) 100 | self._print_cheque() 101 | 102 | def get_capabilities(self): 103 | # XXX: The Bematech DP20C manual doesn't specify what are the 104 | # parameter max values, so... 105 | return {'cheque_thirdparty': Capability(), 106 | 'cheque_value': Capability(), 107 | 'cheque_city': Capability()} 108 | -------------------------------------------------------------------------------- /stoqdrivers/printers/nonfiscal.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vi:si:et:sw=4:sts=4:ts=4 3 | 4 | ## 5 | ## Copyright (C) 2015 Async Open Source 6 | ## All rights reserved 7 | ## 8 | ## This program is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU Lesser General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## This program is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU Lesser General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., or visit: http://www.gnu.org/. 21 | ## 22 | ## Author(s): Stoq Team 23 | ## 24 | 25 | import re 26 | 27 | from stoqdrivers.printers.base import BasePrinter 28 | 29 | 30 | class NonFiscalPrinter(BasePrinter): 31 | def __init__(self, brand=None, model=None, device=None, config_file=None, 32 | *args, **kwargs): 33 | BasePrinter.__init__(self, brand, model, device, config_file, *args, 34 | **kwargs) 35 | 36 | @property 37 | def charset(self): 38 | # The driver might not have defined a charset, or it might be None 39 | return getattr(self._driver, 'charset', 'utf8') or 'utf8' 40 | 41 | @property 42 | def max_characters(self): 43 | return self._driver.max_characters 44 | 45 | def centralize(self): 46 | self._driver.centralize() 47 | 48 | def descentralize(self): 49 | self._driver.descentralize() 50 | 51 | def set_bold(self): 52 | self._driver.set_bold() 53 | 54 | def unset_bold(self): 55 | self._driver.unset_bold() 56 | 57 | def set_condensed(self): 58 | self._driver.set_condensed() 59 | 60 | def unset_condensed(self): 61 | self._driver.unset_condensed() 62 | 63 | def set_double_height(self): 64 | self._driver.set_double_height() 65 | 66 | def unset_double_height(self): 67 | self._driver.unset_double_height() 68 | 69 | def print_line(self, data): 70 | if isinstance(data, str): 71 | data = data.encode(self.charset) 72 | self.print_inline(data + b'\n') 73 | 74 | def print_inline(self, data): 75 | if isinstance(data, str): 76 | data = data.encode(self.charset) 77 | start = 0 78 | for tag in re.finditer(b'<\w+>', data): 79 | # Text before the tag 80 | text = data[start: tag.start()] 81 | if text: 82 | self._driver.print_inline(text) 83 | start = tag.end() 84 | 85 | tag = tag.group()[1:-1].decode() # remove < and > 86 | if hasattr(self, tag): 87 | getattr(self, tag)() 88 | 89 | # any remaining text after the last tag 90 | text = data[start:] 91 | if text: 92 | self._driver.print_inline(text) 93 | 94 | def print_barcode(self, barcode): 95 | self._driver.print_barcode(barcode) 96 | 97 | def print_qrcode(self, code): 98 | self._driver.print_qrcode(code) 99 | 100 | def print_matrix(self, data): 101 | if hasattr(self._driver, 'print_matrix'): 102 | self._driver.print_matrix(data) 103 | 104 | def separator(self): 105 | if hasattr(self._driver, 'separator'): 106 | self._driver.separator() 107 | else: 108 | self._driver.print_line(b'-' * self.max_characters) 109 | 110 | def cut_paper(self): 111 | self._driver.cut_paper() 112 | 113 | def open_drawer(self): 114 | if hasattr(self._driver, 'open_drawer'): 115 | self._driver.open_drawer() 116 | 117 | def is_drawer_open(self): 118 | if hasattr(self._driver, 'is_drawer_open'): 119 | return self._driver.is_drawer_open() 120 | else: 121 | return False 122 | 123 | def open(self): 124 | if hasattr(self._driver, 'open'): 125 | self._driver.open() 126 | 127 | def close(self): 128 | if hasattr(self._driver, 'close'): 129 | self._driver.close() 130 | --------------------------------------------------------------------------------