plantstar-shared 2.0.3.0.2.13__tar.gz → 2.0.3.0.2.15__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.
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/PKG-INFO +1 -1
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/tcp_socket_utils.py +28 -12
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared.egg-info/PKG-INFO +1 -1
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/setup.py +1 -1
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/README.md +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/DataCollectionModuleProcessNames.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/HuskyInterfacePacketTypes.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/MockRawDataProcessor.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/RawDataProcessorInterfaceActions.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/SysconType.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/__init__.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/add_size_onto_string_and_return.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/api_types.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/convert_bytes_to_object.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/convert_object_to_bytes.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/errors.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/global_definitions.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/is_valid_signed_string.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/obtain_raw_data_processor_function_for_action_name.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/syscon_image_field.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/syscon_json.py +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared.egg-info/SOURCES.txt +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared.egg-info/dependency_links.txt +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared.egg-info/requires.txt +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared.egg-info/top_level.txt +0 -0
- {plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/setup.cfg +0 -0
{plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/tcp_socket_utils.py
RENAMED
@@ -8,11 +8,11 @@ SIZE_OF_UNSIGNED_INT_FOR_HUSKY = 2 # size of the integer value that precedes da
|
|
8
8
|
SIZE_OF_UNSIGNED_INT_STRUCT = 4 # size of the integer value that precedes data coming from most sockets (DeviceController, DCM, etc)
|
9
9
|
|
10
10
|
|
11
|
-
def read_size_value_from_socket(*, remote_socket, is_big_endian, number_of_bytes_for_size_prefix):
|
11
|
+
def read_size_value_from_socket(*, remote_socket, is_big_endian, number_of_bytes_for_size_prefix, size_value_includes_size_prefix_bytes=False):
|
12
12
|
size_bytes = remote_socket.recv(number_of_bytes_for_size_prefix)
|
13
13
|
|
14
14
|
if not size_bytes:
|
15
|
-
|
15
|
+
raise SocketConnectionError
|
16
16
|
|
17
17
|
if number_of_bytes_for_size_prefix == SIZE_OF_UNSIGNED_INT_FOR_HUSKY:
|
18
18
|
size_for_message = int.from_bytes(size_bytes, 'big') if is_big_endian else int.from_bytes(size_bytes, 'little')
|
@@ -26,10 +26,16 @@ def read_size_value_from_socket(*, remote_socket, is_big_endian, number_of_bytes
|
|
26
26
|
else:
|
27
27
|
raise SysconProgrammingError("A size prefix was set to something other than 2 or 4")
|
28
28
|
|
29
|
+
if size_value_includes_size_prefix_bytes:
|
30
|
+
size_for_message = size_for_message - number_of_bytes_for_size_prefix
|
31
|
+
|
29
32
|
return size_for_message, size_bytes
|
30
33
|
|
31
34
|
|
32
|
-
def get_bytes_from_socket(
|
35
|
+
def get_bytes_from_socket(
|
36
|
+
*, remote_socket, number_of_bytes_to_read=None, is_big_endian=True, number_of_bytes_for_size_prefix=0, size_value_includes_size_prefix_bytes=False,
|
37
|
+
size_value_should_be_included_in_final_message=False
|
38
|
+
):
|
33
39
|
"""Obtains a number of bytes from a provided socket, with options for different configurations and situations.
|
34
40
|
Returns byte sequence, and the size value that was obtained from the prefix bytes.
|
35
41
|
|
@@ -38,11 +44,13 @@ def get_bytes_from_socket(*, remote_socket, number_of_bytes_to_read=None, is_big
|
|
38
44
|
|
39
45
|
number_of_bytes_to_read -- the number of bytes to read on the socket, if this is known, this is the only optional parameter needed (default: 0)
|
40
46
|
|
41
|
-
is_big_endian -- bool
|
47
|
+
is_big_endian -- bool: what format string should be used for unpacking the size value (default: True)
|
42
48
|
|
43
49
|
number_of_bytes_for_size_prefix -- the number of bytes to read to determine the total size of the message to pass (default: 0)
|
44
50
|
|
45
|
-
|
51
|
+
size_value_includes_size_prefix_bytes -- bool: if size value includes the size_prefix_bytes based on the systems implementation
|
52
|
+
|
53
|
+
size_value_should_be_included_in_final_message -- bool: if size value should be prepended to the byte sequence, likely only Husky logic wants this (default: False)
|
46
54
|
|
47
55
|
-----
|
48
56
|
|
@@ -55,18 +63,24 @@ def get_bytes_from_socket(*, remote_socket, number_of_bytes_to_read=None, is_big
|
|
55
63
|
|
56
64
|
"""
|
57
65
|
|
66
|
+
packets = []
|
67
|
+
|
58
68
|
if not number_of_bytes_to_read:
|
59
69
|
if number_of_bytes_for_size_prefix:
|
60
70
|
number_of_bytes_to_read, size_bytes = read_size_value_from_socket(
|
61
|
-
remote_socket=remote_socket, is_big_endian=is_big_endian, number_of_bytes_for_size_prefix=number_of_bytes_for_size_prefix
|
71
|
+
remote_socket=remote_socket, is_big_endian=is_big_endian, number_of_bytes_for_size_prefix=number_of_bytes_for_size_prefix,
|
72
|
+
size_value_includes_size_prefix_bytes=size_value_includes_size_prefix_bytes
|
62
73
|
)
|
63
74
|
|
64
75
|
if not number_of_bytes_to_read:
|
65
|
-
|
76
|
+
raise SocketConnectionError
|
77
|
+
|
78
|
+
if size_value_should_be_included_in_final_message:
|
79
|
+
packets.append(size_bytes)
|
80
|
+
|
66
81
|
else:
|
67
82
|
raise SysconProgrammingError("get_bytes_from_socket was called with no parameters for number_of_bytes_to_read or number_of_bytes_for_size_prefix")
|
68
83
|
|
69
|
-
packets = []
|
70
84
|
bytes_received = 0
|
71
85
|
|
72
86
|
# While loop that will stream in data if the full request is not available yet
|
@@ -75,7 +89,7 @@ def get_bytes_from_socket(*, remote_socket, number_of_bytes_to_read=None, is_big
|
|
75
89
|
packet = remote_socket.recv(buffer_size)
|
76
90
|
|
77
91
|
if not packet:
|
78
|
-
|
92
|
+
raise SocketConnectionError
|
79
93
|
|
80
94
|
packets.append(packet)
|
81
95
|
bytes_received = bytes_received + len(packet)
|
@@ -102,15 +116,17 @@ def send_encoded_message_on_socket(*, remote_socket, encoded_message):
|
|
102
116
|
|
103
117
|
|
104
118
|
def get_object_from_socket(
|
105
|
-
*, remote_socket, number_of_bytes_to_read=None, is_big_endian=True, number_of_bytes_for_size_prefix=SIZE_OF_UNSIGNED_INT_STRUCT
|
119
|
+
*, remote_socket, number_of_bytes_to_read=None, is_big_endian=True, number_of_bytes_for_size_prefix=SIZE_OF_UNSIGNED_INT_STRUCT,
|
120
|
+
size_value_includes_size_prefix_bytes=False
|
106
121
|
):
|
107
122
|
"""Function that is used between the APU and DCM to send dictionaries. Returns a tuple of the object and its size in bytes."""
|
108
123
|
object_from_interface_as_bytes, size_of_object_in_bytes = get_bytes_from_socket(
|
109
|
-
remote_socket=remote_socket, number_of_bytes_to_read=number_of_bytes_to_read, is_big_endian=is_big_endian, number_of_bytes_for_size_prefix=number_of_bytes_for_size_prefix
|
124
|
+
remote_socket=remote_socket, number_of_bytes_to_read=number_of_bytes_to_read, is_big_endian=is_big_endian, number_of_bytes_for_size_prefix=number_of_bytes_for_size_prefix,
|
125
|
+
size_value_includes_size_prefix_bytes=size_value_includes_size_prefix_bytes
|
110
126
|
)
|
111
127
|
|
112
128
|
if not object_from_interface_as_bytes:
|
113
|
-
|
129
|
+
raise SocketConnectionError
|
114
130
|
|
115
131
|
object_from_interface = convert_bytes_to_object(object_from_interface_as_bytes)
|
116
132
|
return object_from_interface, size_of_object_in_bytes
|
@@ -7,7 +7,7 @@ setuptools.setup(
|
|
7
7
|
name="plantstar-shared",
|
8
8
|
# MAJOR_MILESTONE_VERSION.MINOR_MILESTONE_VERSION.MAJOR_VERSION.MINOR_VERSION.HOTFIX_VERSION.SUBVERSION
|
9
9
|
# The main version should stay as v2.0.3.0.x until we have passed that in the plantstar_apu/plantstar_dcm projects
|
10
|
-
version="2.0.3.0.2.
|
10
|
+
version="2.0.3.0.2.15",
|
11
11
|
author="SYSCON International",
|
12
12
|
author_email="dev@syscon-intl.com",
|
13
13
|
description="Shared code used in plantstar_apu and plantstar_dcm",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/SysconType.py
RENAMED
File without changes
|
{plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/__init__.py
RENAMED
File without changes
|
File without changes
|
{plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/api_types.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{plantstar-shared-2.0.3.0.2.13 → plantstar-shared-2.0.3.0.2.15}/plantstar_shared/syscon_json.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|