Skip to content

Commit

Permalink
differentiate low level errors
Browse files Browse the repository at this point in the history
  • Loading branch information
drunsinn committed Dec 13, 2023
1 parent 96af3d1 commit 439db4d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pyLSV2/low_level_com.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import struct
from typing import Union

from .const import CMD, RSP
from .const import CMD, RSP, LSV2StatusCode
from .dat_cls import LSV2Error
from .err import LSV2StateException, LSV2ProtocolException

Expand Down Expand Up @@ -230,10 +230,14 @@ def telegram(
else:
response_content = bytearray()

self._last_error = LSV2Error()
if self._last_lsv2_response in [RSP.T_ER, RSP.T_BD]:
self._last_error = LSV2Error.from_ba(response_content)
else:
self._last_error = LSV2Error()
if len(response_content) == 2:
self._last_error = LSV2Error.from_ba(response_content)
elif len(response_content) == 0:
self._last_error.e_type = 1
else:
raise Exception(response_content)

return response_content

Expand Down

0 comments on commit 439db4d

Please sign in to comment.