from openerp.tools.translate import _
from .. import escpos
from ..escpos import printer
+from ..escpos import supported_devices
from PIL import Image
from openerp import http
self.queue = Queue()
self.status = {'status':'connecting', 'messages':[]}
- self.supported_printers = [
- { 'vendor' : 0x04b8, 'product' : 0x0e03, 'name' : 'Epson TM-T20' },
- { 'vendor' : 0x04b8, 'product' : 0x0202, 'name' : 'Epson TM-T70' },
- ]
-
- def connected_usb_devices(self,devices):
+ def connected_usb_devices(self):
connected = []
- for device in devices:
+ for device in supported_devices.device_list:
if usb.core.find(idVendor=device['vendor'], idProduct=device['product']) != None:
connected.append(device)
return connected
def get_escpos_printer(self):
try:
- printers = self.connected_usb_devices(self.supported_printers)
+ printers = self.connected_usb_devices()
if len(printers) > 0:
self.set_status('connected','Connected to '+printers[0]['name'])
return escpos.printer.Usb(printers[0]['vendor'], printers[0]['product'])
-__all__ = ["constants","escpos","exceptions","printer"]
+__all__ = ["constants","escpos","exceptions","printer","supported_devices"]
--- /dev/null
+#!/usr/bin/python
+
+# This is a list of esc/pos compatible usb printers. The vendor and product ids can be found by
+# typing lsusb in a linux terminal, this will give you the ids in the form ID VENDOR:PRODUCT
+
+device_list = [
+ { 'vendor' : 0x04b8, 'product' : 0x0e03, 'name' : 'Epson TM-T20' },
+ { 'vendor' : 0x04b8, 'product' : 0x0202, 'name' : 'Epson TM-T70' },
+]
+