Skip to content

Commit

Permalink
fix: fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikRevich committed Apr 8, 2024
1 parent 2c6b8ac commit 73ef364
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Core/External/Scheduler/Handler/scheduler_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions Scripts/cli/src/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand All @@ -191,18 +191,20 @@ 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)

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)

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Scripts/cli/src/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions Scripts/cli/src/command/set_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 73ef364

Please sign in to comment.