From 73ef3647b1d4f5dc43095cc0ddb71289a3bf1a83 Mon Sep 17 00:00:00 2001 From: Yaroslav Svitlytskyi Date: Mon, 8 Apr 2024 10:03:45 +0200 Subject: [PATCH] fix: fixed bugs --- .../External/Scheduler/Handler/scheduler_handler.cpp | 4 ++++ Scripts/cli/src/client/client.py | 12 +++++++----- Scripts/cli/src/command/base.py | 2 +- Scripts/cli/src/command/set_settings.py | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Core/External/Scheduler/Handler/scheduler_handler.cpp b/Core/External/Scheduler/Handler/scheduler_handler.cpp index 91a3e0b..87fb09b 100644 --- a/Core/External/Scheduler/Handler/scheduler_handler.cpp +++ b/Core/External/Scheduler/Handler/scheduler_handler.cpp @@ -412,6 +412,8 @@ int SchedulerHandler::process_settings_bus_request_content_of_set_gain_settings_ } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_max_type( content.settingsBus())) { TSL2591X::set_gain(MAX_AGAIN); + } else { + return EXIT_FAILURE; } settings_bus_response_content.set_result(true); @@ -457,6 +459,8 @@ int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_ } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_sixth_type( content.settingsBus())) { TSL2591X::set_integral_time(ATIME_600MS); + } else { + return EXIT_FAILURE; } settings_bus_response_content.set_result(true); diff --git a/Scripts/cli/src/client/client.py b/Scripts/cli/src/client/client.py index 1a1aa16..377b739 100644 --- a/Scripts/cli/src/client/client.py +++ b/Scripts/cli/src/client/client.py @@ -182,7 +182,7 @@ def send_info_bus_request_device_available_info_type_content(self) -> RetrievedD def __send_settings_bus_request_content( self, type: SettingsBus.SettingsType, - value: Union[None, SettingsTypeCompound] = None) -> ( + value: Union[None, Union[SettingsBus.SetGrainSettingType, SettingsBus.SetIntegralTimeSettingType]] = None) -> ( Response.ResponseContainer): """Sends request to the board via settings bus to set settings.""" @@ -191,11 +191,11 @@ def __send_settings_bus_request_content( settings_bus_request = SettingsBus.SettingsBusRequestContent() settings_bus_request.settingsType = type - match SettingsTypeCompound: - case SettingsTypeCompound.SET_GAIN: + match type: + case SettingsBus.SettingsType.SetGain: settings_bus_request.setGainValue = value - case SettingsTypeCompound.SET_INTEGRAL_TIME: + case SettingsBus.SettingsType.SetIntegralTime: settings_bus_request.setIntegralTimeValue = value request_container.settingsBus.CopyFrom(settings_bus_request) @@ -203,6 +203,8 @@ def __send_settings_bus_request_content( data_length = request_container.ByteSize().to_bytes(1, "big") data = request_container.SerializeToString() + print(request_container) + self.connection.write(data_length) self.connection.write(data) @@ -340,7 +342,7 @@ def send_settings_bus_request_set_integral_time_sixth_settings_type_content(self """Sends request to the board via settings bus to set setting of set integral time sixth type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetIntegralTime, SettingsTypeCompound.SET_INTEGRAL_TIME) + SettingsBus.SettingsType.SetIntegralTime, SettingsBus.SetIntegralTimeSettingType.Sixth) return SetSettingsDto( data.settingsBus.deviceId, diff --git a/Scripts/cli/src/command/base.py b/Scripts/cli/src/command/base.py index ecb89f6..41978fa 100644 --- a/Scripts/cli/src/command/base.py +++ b/Scripts/cli/src/command/base.py @@ -37,7 +37,7 @@ def get_info(device: str, baud_rate: int, type: str) -> None: GetInfoCommand.handle(device, baud_rate, type) @staticmethod - def set_settings(device: str, baud_rate: int, type: str, value: Optional[str]) -> None: + def set_settings(device: str, baud_rate: int, type: str, value: Optional[str] = None) -> None: """ Sets given settings to the board. The available settings types are 'reset', 'set_gain'(with values 'low', 'medium', 'high', 'max'), diff --git a/Scripts/cli/src/command/set_settings.py b/Scripts/cli/src/command/set_settings.py index f6b891c..85935cc 100644 --- a/Scripts/cli/src/command/set_settings.py +++ b/Scripts/cli/src/command/set_settings.py @@ -50,7 +50,7 @@ class SetSettingsCommand: SET_INTEGRAL_TIME_SIXTH_VALUE_TYPE: str = "sixth" @staticmethod - def handle(device: str, baud_rate: int, type: str, value: Optional[str]) -> None: + def handle(device: str, baud_rate: int, type: str, value: Optional[str] = None) -> None: """Handles the execution of command wrapper.""" if not is_device_available(device): @@ -123,7 +123,7 @@ def process_reset_settings(device: str, baud_rate: int) -> SetSettingsDto: """Processes request to set 'reset' setting to the device.""" with Client(device, baud_rate) as client: - return client.send_info_bus_request_gain_info_type_content() + return client.send_settings_bus_request_reset_settings_type_content() @staticmethod def process_set_gain_low_settings(device: str, baud_rate: int) -> SetSettingsDto: