plantstar-shared 2.0.3.0.2.10__tar.gz → 2.0.3.0.2.11__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.10 → plantstar-shared-2.0.3.0.2.11}/PKG-INFO +1 -1
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/tcp_socket_utils.py +22 -18
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared.egg-info/PKG-INFO +1 -1
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/setup.py +1 -1
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/README.md +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/DataCollectionModuleProcessNames.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/HuskyInterfacePacketTypes.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/MockRawDataProcessor.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/RawDataProcessorInterfaceActions.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/SysconType.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/__init__.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/add_size_onto_string_and_return.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/api_types.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/convert_bytes_to_object.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/convert_object_to_bytes.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/errors.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/global_definitions.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/is_valid_signed_string.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/obtain_raw_data_processor_function_for_action_name.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/syscon_image_field.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/syscon_json.py +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared.egg-info/SOURCES.txt +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared.egg-info/dependency_links.txt +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared.egg-info/requires.txt +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared.egg-info/top_level.txt +0 -0
- {plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/setup.cfg +0 -0
{plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/tcp_socket_utils.py
RENAMED
@@ -4,6 +4,7 @@ from plantstar_shared.convert_bytes_to_object import convert_bytes_to_object
|
|
4
4
|
from plantstar_shared.convert_object_to_bytes import convert_object_to_bytes
|
5
5
|
from plantstar_shared.errors import SocketConnectionError, SysconProgrammingError
|
6
6
|
|
7
|
+
SIZE_OF_UNSIGNED_INT_FOR_HUSKY = 2 # size of integer value that preceds data coming from Husky OIs
|
7
8
|
SIZE_OF_UNSIGNED_INT_STRUCT = 4 # size of integer value that precedes data coming from DCM
|
8
9
|
|
9
10
|
|
@@ -11,25 +12,26 @@ def read_size_value_from_socket(*, remote_socket, is_big_endian, number_of_bytes
|
|
11
12
|
size_bytes = remote_socket.recv(number_of_bytes_for_size_prefix)
|
12
13
|
|
13
14
|
if not size_bytes:
|
14
|
-
return None
|
15
|
+
return None, None
|
15
16
|
|
16
|
-
if number_of_bytes_for_size_prefix ==
|
17
|
-
|
17
|
+
if number_of_bytes_for_size_prefix == SIZE_OF_UNSIGNED_INT_FOR_HUSKY:
|
18
|
+
size_for_message = int.from_bytes(size_bytes, 'big') if is_big_endian else int.from_bytes(size_bytes, 'little')
|
18
19
|
elif number_of_bytes_for_size_prefix == SIZE_OF_UNSIGNED_INT_STRUCT:
|
19
20
|
number_format = ">I" if is_big_endian else "<I"
|
20
21
|
|
21
22
|
try:
|
22
|
-
|
23
|
+
size_for_message = struct.unpack(number_format, size_bytes)[0]
|
23
24
|
except struct.error as error:
|
24
25
|
raise SocketConnectionError
|
25
26
|
else:
|
26
27
|
raise SysconProgrammingError("A size prefix was set to something other than 2 or 4")
|
27
28
|
|
28
|
-
return
|
29
|
+
return size_for_message, size_bytes
|
29
30
|
|
30
31
|
|
31
|
-
def get_bytes_from_socket(*, remote_socket, number_of_bytes_to_read=None, is_big_endian=True, number_of_bytes_for_size_prefix=0
|
32
|
-
"""Obtains a number of bytes from a provided socket, with options for different configurations and situations
|
32
|
+
def get_bytes_from_socket(*, remote_socket, number_of_bytes_to_read=None, is_big_endian=True, number_of_bytes_for_size_prefix=0):
|
33
|
+
"""Obtains a number of bytes from a provided socket, with options for different configurations and situations.
|
34
|
+
Returns byte sequence, and the size value that was obtained from the prefix bytes.
|
33
35
|
|
34
36
|
Keywords / Example Configurations:
|
35
37
|
remote_socket -- the connection that bytes will be read from
|
@@ -55,15 +57,14 @@ def get_bytes_from_socket(*, remote_socket, number_of_bytes_to_read=None, is_big
|
|
55
57
|
|
56
58
|
if not number_of_bytes_to_read:
|
57
59
|
if number_of_bytes_for_size_prefix:
|
58
|
-
number_of_bytes_to_read = read_size_value_from_socket(
|
60
|
+
number_of_bytes_to_read, size_bytes = read_size_value_from_socket(
|
59
61
|
remote_socket=remote_socket, is_big_endian=is_big_endian, number_of_bytes_for_size_prefix=number_of_bytes_for_size_prefix
|
60
62
|
)
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
number_of_bytes_to_read = number_of_bytes_to_read - number_of_bytes_for_size_prefix
|
64
|
+
if not number_of_bytes_to_read:
|
65
|
+
return None, None
|
66
|
+
else:
|
67
|
+
raise SysconProgrammingError("get_bytes_from_socket was called with no parameters for number_of_bytes_to_read or number_of_bytes_for_size_prefix")
|
67
68
|
|
68
69
|
packets = []
|
69
70
|
bytes_received = 0
|
@@ -74,13 +75,13 @@ def get_bytes_from_socket(*, remote_socket, number_of_bytes_to_read=None, is_big
|
|
74
75
|
packet = remote_socket.recv(buffer_size)
|
75
76
|
|
76
77
|
if not packet:
|
77
|
-
return None
|
78
|
+
return None, number_of_bytes_to_read
|
78
79
|
|
79
80
|
packets.append(packet)
|
80
81
|
bytes_received = bytes_received + len(packet)
|
81
82
|
|
82
83
|
data = b''.join(packets)
|
83
|
-
return data
|
84
|
+
return data, number_of_bytes_to_read
|
84
85
|
|
85
86
|
|
86
87
|
def send_message_on_socket(*, remote_socket, dumpsable_object):
|
@@ -104,9 +105,12 @@ def get_object_from_socket(
|
|
104
105
|
*, remote_socket, number_of_bytes_to_read=None, is_big_endian=True, number_of_bytes_for_size_prefix=SIZE_OF_UNSIGNED_INT_STRUCT, should_remove_prefix_size_from_read=False
|
105
106
|
):
|
106
107
|
"""Function that is used between the APU and DCM to send dictionaries """
|
107
|
-
object_from_interface_as_bytes = get_bytes_from_socket(
|
108
|
-
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
|
109
|
-
should_remove_prefix_size_from_read=should_remove_prefix_size_from_read
|
108
|
+
object_from_interface_as_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
|
110
110
|
)
|
111
|
+
|
112
|
+
if not object_from_interface_as_bytes:
|
113
|
+
return None
|
114
|
+
|
111
115
|
object_from_interface = convert_bytes_to_object(object_from_interface_as_bytes)
|
112
116
|
return object_from_interface
|
@@ -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.11",
|
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.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/SysconType.py
RENAMED
File without changes
|
{plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/__init__.py
RENAMED
File without changes
|
File without changes
|
{plantstar-shared-2.0.3.0.2.10 → plantstar-shared-2.0.3.0.2.11}/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.10 → plantstar-shared-2.0.3.0.2.11}/plantstar_shared/syscon_json.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|