diff --git a/Scripts/cli/src/client/client.py b/Scripts/cli/src/client/client.py index 29e3a1e..385f72d 100644 --- a/Scripts/cli/src/client/client.py +++ b/Scripts/cli/src/client/client.py @@ -18,6 +18,8 @@ from ..dto import SettingsTypeCompound from ..dto import SetSettingsDto +from ..tools import perform_request_await + class Client: """Represents client used to connect to remote device via serial port.""" @@ -51,6 +53,9 @@ def __send_data_bus_request_content(self, type: DataBus.DataType) -> Response.Re data = request_container.SerializeToString() self.connection.write(data_length) + + perform_request_await() + self.connection.write(data) result_length_raw = self.connection.read(3) @@ -122,6 +127,9 @@ def __send_info_bus_request_content(self, type: InfoBus.InfoType) -> Response.Re data = request_container.SerializeToString() self.connection.write(data_length) + + perform_request_await() + self.connection.write(data) result_length_raw = self.connection.read(3) @@ -193,6 +201,9 @@ def __send_settings_bus_request_content(self, type: SettingsBus.SettingsType) -> data = request_container.SerializeToString() self.connection.write(data_length) + + perform_request_await() + self.connection.write(data) result_length_raw = self.connection.read(3) diff --git a/Scripts/cli/src/tools/__init__.py b/Scripts/cli/src/tools/__init__.py index acac466..6221ad3 100644 --- a/Scripts/cli/src/tools/__init__.py +++ b/Scripts/cli/src/tools/__init__.py @@ -1 +1,3 @@ -from .prettifier import print_output \ No newline at end of file +from .prettifier import print_output + +from .throttle import perform_request_await \ No newline at end of file diff --git a/Scripts/cli/src/tools/throttle.py b/Scripts/cli/src/tools/throttle.py new file mode 100644 index 0000000..a72c5eb --- /dev/null +++ b/Scripts/cli/src/tools/throttle.py @@ -0,0 +1,10 @@ +import time + +# Represents throttle request duration time. +THROTTLE_REQUEST_DURATION: float = 0.3 + + +def perform_request_await() -> None: + """Performs throttle request operation.""" + + time.sleep(THROTTLE_REQUEST_DURATION)