s7datablock 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {s7datablock-0.0.2 → s7datablock-0.0.3}/PKG-INFO +2 -2
- {s7datablock-0.0.2 → s7datablock-0.0.3}/pyproject.toml +1 -1
- {s7datablock-0.0.2 → s7datablock-0.0.3}/src/s7datablock/fields.py +3 -3
- s7datablock-0.0.3/tests/test_byte_order.py +39 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/uv.lock +2 -2
- {s7datablock-0.0.2 → s7datablock-0.0.3}/.coveragerc +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/.github/workflows/ci.yml +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/.gitignore +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/.isort.cfg +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/.pre-commit-config.yaml +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/.readthedocs.yml +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/AUTHORS.md +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/LICENSE.txt +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/README.md +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/docs/example.png +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/examples/basic_usage.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/examples/dtl_date.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/examples/live_monitor.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/examples/parse_file.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/src/s7datablock/__init__.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/src/s7datablock/constants.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/src/s7datablock/grammar.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/src/s7datablock/mapping.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/src/s7datablock/parser.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/src/s7datablock/py.typed +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/test_buffer_mapping_extended.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/conftest.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/definitions/s7_1200_out.db +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/definitions/tester.db +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/test_buffer_mapping.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/test_buffer_mapping_extended.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/test_dtl_struct.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/test_s7_connector.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/test_s7_parsing.py +0 -0
- {s7datablock-0.0.2 → s7datablock-0.0.3}/tests/test_s7_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: s7datablock
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: A Python library for interacting with Siemens S7 PLC datablocks
|
|
5
5
|
Project-URL: Homepage, https://github.com/CEAD-group/s7datablock
|
|
6
6
|
Project-URL: Documentation, https://github.com/CEAD-group/s7datablock
|
|
@@ -278,9 +278,9 @@ class S7DTL(
|
|
|
278
278
|
|
|
279
279
|
|
|
280
280
|
class S7Time(S7Field[timedelta], s7_type="Time"):
|
|
281
|
-
"""Time duration S7Field type."""
|
|
281
|
+
"""Time duration S7Field type (signed 32-bit milliseconds)."""
|
|
282
282
|
|
|
283
|
-
struct_fmt = "
|
|
283
|
+
struct_fmt = ">i"
|
|
284
284
|
|
|
285
285
|
def unpack(self, buffer: bytearray) -> timedelta:
|
|
286
286
|
ms = struct.unpack(self.struct_fmt, buffer[self.buffer_slice])[0]
|
|
@@ -338,4 +338,4 @@ class DBParseResult(NamedTuple):
|
|
|
338
338
|
class S7Int(S7Field[int], s7_type="Int"):
|
|
339
339
|
"""16-bit signed integer S7Field."""
|
|
340
340
|
|
|
341
|
-
struct_fmt = "h"
|
|
341
|
+
struct_fmt = ">h"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""S7 stores every multi-byte value big-endian. These tests decode KNOWN raw bytes,
|
|
2
|
+
so a field format without an explicit ">" fails here instead of round-tripping
|
|
3
|
+
cleanly through pack() and unpack() with the same wrong byte order."""
|
|
4
|
+
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from s7datablock.fields import S7Field
|
|
10
|
+
|
|
11
|
+
BIG_ENDIAN_CASES = [
|
|
12
|
+
("Int", bytes([0x02, 0xD0]), 720),
|
|
13
|
+
("Int", bytes([0xFF, 0xFE]), -2),
|
|
14
|
+
("UInt", bytes([0x02, 0xD0]), 720),
|
|
15
|
+
("Word", bytes([0x02, 0xD0]), 720),
|
|
16
|
+
("DInt", bytes([0x00, 0x01, 0x00, 0x02]), 65538),
|
|
17
|
+
("DInt", bytes([0xFF, 0xFF, 0xFF, 0xFE]), -2),
|
|
18
|
+
("UDInt", bytes([0x00, 0x01, 0x00, 0x02]), 65538),
|
|
19
|
+
("DWord", bytes([0x00, 0x01, 0x00, 0x02]), 65538),
|
|
20
|
+
("Real", bytes([0x43, 0x65, 0x00, 0x00]), 229.0),
|
|
21
|
+
("Time", bytes([0x00, 0x00, 0x03, 0xE8]), timedelta(seconds=1)),
|
|
22
|
+
("Time", bytes([0xFF, 0xFF, 0xFC, 0x18]), timedelta(seconds=-1)),
|
|
23
|
+
("Time_of_Day", bytes([0x00, 0x00, 0x03, 0xE8]), timedelta(seconds=1)),
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.mark.parametrize("s7_type,raw,expected", BIG_ENDIAN_CASES)
|
|
28
|
+
def test_unpack_reads_big_endian(s7_type, raw, expected):
|
|
29
|
+
field = S7Field.create(offset=2, s7_type=s7_type)
|
|
30
|
+
buffer = bytearray(2) + bytearray(raw) + bytearray(2)
|
|
31
|
+
assert field.unpack(buffer) == expected
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@pytest.mark.parametrize("s7_type,raw,expected", BIG_ENDIAN_CASES)
|
|
35
|
+
def test_pack_writes_big_endian(s7_type, raw, expected):
|
|
36
|
+
field = S7Field.create(offset=2, s7_type=s7_type)
|
|
37
|
+
buffer = bytearray(len(raw) + 4)
|
|
38
|
+
field.pack(buffer, expected)
|
|
39
|
+
assert bytes(buffer[2 : 2 + len(raw)]) == raw
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
version = 1
|
|
2
|
-
revision =
|
|
2
|
+
revision = 5
|
|
3
3
|
requires-python = ">=3.11"
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
@@ -218,7 +218,7 @@ wheels = [
|
|
|
218
218
|
|
|
219
219
|
[[package]]
|
|
220
220
|
name = "s7datablock"
|
|
221
|
-
version = "0.0.
|
|
221
|
+
version = "0.0.3"
|
|
222
222
|
source = { editable = "." }
|
|
223
223
|
dependencies = [
|
|
224
224
|
{ name = "pyparsing" },
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|