diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-07-17 17:48:34 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-07-17 17:48:34 +0200 |
| commit | 5b9a51bb1d1f2d8bbb59171f3cea5e4bfd195f5e (patch) | |
| tree | 8310cc77df4d0e5d5121c3728c462d3b01df7d9f /addons/hw_scale/controllers/main.py | |
| parent | 78c8cda97ec71c5f14731b5e9a7fb544fcdb7b49 (diff) | |
| parent | 44b77d3702b3c2957c1381367ebff01e024d13b9 (diff) | |
[MERGE] forward port branch 11.0 up to 44b77d3702b
Diffstat (limited to 'addons/hw_scale/controllers/main.py')
| -rw-r--r-- | addons/hw_scale/controllers/main.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/addons/hw_scale/controllers/main.py b/addons/hw_scale/controllers/main.py index 090e6193fe6..162ab7a866d 100644 --- a/addons/hw_scale/controllers/main.py +++ b/addons/hw_scale/controllers/main.py @@ -28,7 +28,7 @@ except ImportError: def _toledo8217StatusParse(status): """ Parse a scale's status, returning a `(weight, weight_info)` pair. """ weight, weight_info = None, None - stat = ord(status[status.index('?') + 1]) + stat = status[status.index(b'?') + 1] if stat == 0: weight_info = 'ok' else: @@ -68,17 +68,17 @@ Toledo8217Protocol = ScaleProtocol( parity=serial.PARITY_EVEN, timeout=1, writeTimeout=1, - weightRegexp="\x02\\s*([0-9.]+)N?\\r", - statusRegexp="\x02\\s*(\\?.)\\r", + weightRegexp=b"\x02\\s*([0-9.]+)N?\\r", + statusRegexp=b"\x02\\s*(\\?.)\\r", statusParse=_toledo8217StatusParse, commandDelay=0.2, weightDelay=0.5, newWeightDelay=0.2, - commandTerminator='', - weightCommand='W', - zeroCommand='Z', - tareCommand='T', - clearCommand='C', + commandTerminator=b'', + weightCommand=b'W', + zeroCommand=b'Z', + tareCommand=b'T', + clearCommand=b'C', emptyAnswerValid=False, autoResetWeight=False, ) @@ -98,15 +98,15 @@ ADAMEquipmentProtocol = ScaleProtocol( weightRegexp=r"\s*([0-9.]+)kg", # LABEL format 3 + KG in the scale settings, but Label 1/2 should work statusRegexp=None, statusParse=None, - commandTerminator="\r\n", + commandTerminator=b"\r\n", commandDelay=0.2, weightDelay=0.5, newWeightDelay=5, # AZExtra beeps every time you ask for a weight that was previously returned! # Adding an extra delay gives the operator a chance to remove the products # before the scale starts beeping. Could not find a way to disable the beeps. - weightCommand='P', - zeroCommand='Z', - tareCommand='T', + weightCommand=b'P', + zeroCommand=b'Z', + tareCommand=b'T', clearCommand=None, # No clear command -> Tare again emptyAnswerValid=True, # AZExtra does not answer unless a new non-zero weight has been detected autoResetWeight=True, # AZExtra will not return 0 after removing products @@ -165,8 +165,8 @@ class Scale(Thread): if not char: break else: - answer.append(char) - return ''.join(answer) + answer.append(bytes(char)) + return b''.join(answer) def _parse_weight_answer(self, protocol, answer): """ Parse a scale's answer to a weighing request, returning |
