frappy_mlz: Zebra fixes after basic test

Some fixes after the device was tested with socat ptys and NICOS.

Change-Id: I3e9dba2be2547d493c435d1da9844c932a2df4e6
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31662
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
Alexander Zaft 2023-07-12 16:10:10 +02:00 committed by Markus Zolliker
parent f205cf76aa
commit 9ea6082ed8

View File

@ -26,7 +26,7 @@
import threading import threading
from time import sleep, time from time import sleep, time
from frappy.core import Parameter, Command, nopoll from frappy.core import Parameter, Command, nopoll, Readable
from frappy.io import HasIO, BytesIO from frappy.io import HasIO, BytesIO
from frappy.lib import mkthread from frappy.lib import mkthread
from frappy.errors import CommunicationFailedError from frappy.errors import CommunicationFailedError
@ -185,7 +185,7 @@ class ZebraIO(BytesIO):
# Not yet tested # Not yet tested
class ZebraReader(HasIO): class ZebraReader(HasIO, Readable):
"""Reads scanned barcodes from a Zebra barcode reader, using the USB-CDC """Reads scanned barcodes from a Zebra barcode reader, using the USB-CDC
interface mode and the SSI protocol. interface mode and the SSI protocol.
@ -208,9 +208,13 @@ class ZebraReader(HasIO):
ioClass = ZebraIO ioClass = ZebraIO
decoded = Parameter('decoded barcode (updates-only)', StringType(), update_unchanged='always') decoded = Parameter('decoded barcode (updates-only)', StringType(),
update_unchanged='always', default='')
# TODO: Decide, if this is useful, remove otherwise # TODO: Decide, if this is useful, remove otherwise
status = Parameter('status of the module', StatusType('IDLE', 'WARN', 'ERROR')) status = Parameter('status of the module',
StatusType('IDLE', 'WARN', 'ERROR'))
value = Parameter(datatype=StringType(), default='',
update_unchanged='never')
_thread = None _thread = None
_stoprequest = False _stoprequest = False
@ -231,9 +235,13 @@ class ZebraReader(HasIO):
if self._thread and self._thread.is_alive(): if self._thread and self._thread.is_alive():
self._thread.join() self._thread.join()
@nopoll
def read_value(self):
return ''
@nopoll @nopoll
def read_decoded(self): def read_decoded(self):
return '' # TODO: maybe raise Error? return ''
def read_status(self): def read_status(self):
return self.Status.IDLE, '' return self.Status.IDLE, ''
@ -252,6 +260,7 @@ class ZebraReader(HasIO):
code = None code = None
except Exception as e: except Exception as e:
self.log.exception('while receiving barcode: %s', e) self.log.exception('while receiving barcode: %s', e)
self.status = self.Status.ERROR, f'{e!r}'
continue continue
if code is not None: if code is not None:
codetype = BARCODE_TYPES.get(code[0], str(code[0])) codetype = BARCODE_TYPES.get(code[0], str(code[0]))
@ -261,6 +270,7 @@ class ZebraReader(HasIO):
self.log.info('decoded barcode %r with timestamp %s', self.log.info('decoded barcode %r with timestamp %s',
code, tstamp) code, tstamp)
self.decoded = code self.decoded = code
self.decoded = '' # clear value of frappy client cache
sleep(0.5) sleep(0.5)
@Command() @Command()