Skip to content

Commit

Permalink
add ALN-ENUM
Browse files Browse the repository at this point in the history
  • Loading branch information
semuadmin committed Jun 4, 2024
1 parent 31b4a76 commit 7167374
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from time import process_time_ns

from pyspartn import SPARTNReader
from pyspartn import _version as spartnver
from pyspartn import version as spartnver

KEY = "930d847b779b126863c8b3b2766ae7cc"
BASEDATE = datetime(2024, 4, 18, 20, 48, 29, 977255)
Expand Down
14 changes: 2 additions & 12 deletions src/pyspartn/spartnreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from pyspartn.socket_stream import SocketStream
from pyspartn.spartnhelpers import bitsval, naive2aware, timetag2date, valid_crc
from pyspartn.spartnmessage import SPARTNMessage
from pyspartn.spartntables import ALN_ENUM
from pyspartn.spartntypes_core import ERRLOG, ERRRAISE, SPARTN_PREB, VALCRC


Expand Down Expand Up @@ -212,18 +213,7 @@ def _parse_spartn(self, preamble: bytes) -> tuple:
payload = self._read_bytes(nData)
embAuth = b""
if authInd > 1:
if embAuthLen == 0:
aln = 8
elif embAuthLen == 1:
aln = 12
elif embAuthLen == 2:
aln = 16
elif embAuthLen == 3:
aln = 32
elif embAuthLen == 4:
aln = 64
else:
aln = 0
aln = ALN_ENUM.get(embAuthLen, 0)
embAuth = self._read_bytes(aln)
crcb = self._read_bytes(crcType + 1)
crc = int.from_bytes(crcb, "big")
Expand Down
2 changes: 2 additions & 0 deletions src/pyspartn/spartntables.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
),
}

ALN_ENUM = {0: 8, 1: 12, 2: 16, 3: 32, 4: 64}

SF015_ENUM = SF022_ENUM = {
0: "0 secs",
1: "1 secs",
Expand Down

0 comments on commit 7167374

Please sign in to comment.