[IMP] hw_escpos: more fault tolerant printer detection
In some cases, the description fails (unknow printer, udev issues,...) and while the printer works fine, the description fails. This is a cherry pick of 994d45f4 to 8.0 (as the posbox is built on top of it)production/rebase-20171130
parent
7a15e52cea
commit
8459860b02
|
@ -86,10 +86,15 @@ class EscposDriver(Thread):
|
|||
printers = usb.core.find(find_all=True, idVendor=0x0519)
|
||||
|
||||
for printer in printers:
|
||||
try:
|
||||
description = usb.util.get_string(printer, 256, printer.iManufacturer) + " " + usb.util.get_string(printer, 256, printer.iProduct)
|
||||
except Exception as e:
|
||||
_logger.error("Can not get printer description: %s" % (e.message or repr(e)))
|
||||
description = 'Unknown printer'
|
||||
connected.append({
|
||||
'vendor': printer.idVendor,
|
||||
'product': printer.idProduct,
|
||||
'name': usb.util.get_string(printer, 256, printer.iManufacturer) + " " + usb.util.get_string(printer, 256, printer.iProduct)
|
||||
'name': description
|
||||
})
|
||||
|
||||
return connected
|
||||
|
|
Loading…
Reference in New Issue