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 1, 2024
1 parent ef8422e commit 66a7ccc
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 32 deletions.
18 changes: 9 additions & 9 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1260508736" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Core/Inc"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer/Request"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer/Response"/>
<listOptionValue builtIn="false" value="../Core/External/Sensor"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Helper"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Codec"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Generated"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Generated/Content"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer/Request"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer/Response"/>
<listOptionValue builtIn="false" value="../Core/External/Scheduler"/>
<listOptionValue builtIn="false" value="../Core/External/Scheduler/Handler"/>
<listOptionValue builtIn="false" value="../Core/External/State"/>
<listOptionValue builtIn="false" value="../Core/External/Tools/Indicator"/>
<listOptionValue builtIn="false" value="../Core/External/Tools/Sequence"/>
<listOptionValue builtIn="false" value="../ThirdParty"/>
<listOptionValue builtIn="false" value="../ThirdParty/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/>
Expand All @@ -78,20 +78,20 @@
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths.239766328" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Core/Inc"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer/Request"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer/Response"/>
<listOptionValue builtIn="false" value="../Core/External/Sensor"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Helper"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Codec"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Generated"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Generated/Content"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer/Request"/>
<listOptionValue builtIn="false" value="../Core/External/Proto/Buffer/Response"/>
<listOptionValue builtIn="false" value="../Core/External/Scheduler"/>
<listOptionValue builtIn="false" value="../Core/External/State"/>
<listOptionValue builtIn="false" value="../Core/External/Scheduler/Handler"/>
<listOptionValue builtIn="false" value="../Core/External/Tools/Indicator"/>
<listOptionValue builtIn="false" value="../Core/External/Tools/Sequence"/>
<listOptionValue builtIn="false" value="../ThirdParty"/>
<listOptionValue builtIn="false" value="../ThirdParty/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/>
Expand Down Expand Up @@ -125,9 +125,9 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ThirdParty"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ThirdParty"/>
</sourceEntries>
</configuration>
</storageModule>
Expand Down
55 changes: 37 additions & 18 deletions Core/External/Scheduler/Handler/scheduler_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@ int SchedulerHandler::handle_response() {

if (!request_container_sequence.is_empty()) {
return request_container_sequence.traverse([](const light_detector::RequestContainer &content) -> int {
if (ProtoHelper::is_data_bus_request_container(content)) {

return SchedulerHandler::process_data_bus_request_content_response(content);
} else if (ProtoHelper::is_info_bus_request_container(content)) {

return SchedulerHandler::process_info_bus_request_content_response(content);
} else if (ProtoHelper::is_settings_bus_request_container(content)) {

return SchedulerHandler::process_settings_bus_request_content_response(content);
}

return EXIT_SUCCESS;
return SchedulerHandler::try_process_response_container(content);
});
}

Expand All @@ -41,6 +30,36 @@ int SchedulerHandler::try_process_request_container() {
return ProtoCodec::decode_request_container();
}

int SchedulerHandler::try_process_response_container(const light_detector::RequestContainer &content) {
if (ProtoHelper::is_data_bus_request_container(content)) {

if (SchedulerHandler::process_data_bus_request_content_response(content) != EXIT_SUCCESS) {
return EXIT_FAILURE;
}
} else if (ProtoHelper::is_info_bus_request_container(content)) {

if (SchedulerHandler::process_info_bus_request_content_response(content) != EXIT_SUCCESS) {
return EXIT_FAILURE;
}
} else if (ProtoHelper::is_settings_bus_request_container(content)) {

if (SchedulerHandler::process_settings_bus_request_content_response(content) != EXIT_SUCCESS) {
return EXIT_FAILURE;
}
}

return SchedulerHandler::try_transmit_response_container();
}

int SchedulerHandler::try_transmit_response_container() {
auto request_buffer = ProtoCodec::get_request_buffer();

HAL_UART_Receive(
&huart2, request_buffer.get_raw_buffer(), request_buffer.get_size(), 1000);

return EXIT_SUCCESS;
}

int SchedulerHandler::process_data_bus_request_content_response(
const light_detector::RequestContainer &content) {
auto data_bus_request_content =
Expand Down Expand Up @@ -78,7 +97,7 @@ int SchedulerHandler::process_data_bus_request_content_of_raw_data_type_response
TSL2591X::invoke_lux_interrupt(LUX_LOW, LUX_HIGH);

data_bus_response_content.set_value(value);
data_bus_response_content.set_nonce(State::get_current_response_nonce());
data_bus_response_content.set_nonce(State::allocate_response_nonce());

response_container.set_dataBus(data_bus_response_content);

Expand All @@ -99,7 +118,7 @@ int SchedulerHandler::process_data_bus_request_content_of_full_data_type_respons
uint32_t value = TSL2591X::read_full();

data_bus_response_content.set_value(value);
data_bus_response_content.set_nonce(State::get_current_response_nonce());
data_bus_response_content.set_nonce(State::allocate_response_nonce());

response_container.set_dataBus(data_bus_response_content);

Expand All @@ -120,7 +139,7 @@ int SchedulerHandler::process_data_bus_request_content_of_infrared_data_type_res
uint16_t value = TSL2591X::read_infrared();

data_bus_response_content.set_value(value);
data_bus_response_content.set_nonce(State::get_current_response_nonce());
data_bus_response_content.set_nonce(State::allocate_response_nonce());

response_container.set_dataBus(data_bus_response_content);

Expand All @@ -141,7 +160,7 @@ int SchedulerHandler::process_data_bus_request_content_of_visible_data_type_resp
uint32_t value = TSL2591X::read_visible();

data_bus_response_content.set_value(value);
data_bus_response_content.set_nonce(State::get_current_response_nonce());
data_bus_response_content.set_nonce(State::allocate_response_nonce());

response_container.set_dataBus(data_bus_response_content);

Expand Down Expand Up @@ -178,7 +197,7 @@ int SchedulerHandler::process_info_bus_request_content_of_gain_info_type_respons
uint8_t value = TSL2591X::get_gain();

info_bus_response_content.set_value(value);
info_bus_response_content.set_nonce(State::get_current_response_nonce());
info_bus_response_content.set_nonce(State::allocate_response_nonce());

response_container.set_infoBus(info_bus_response_content);

Expand All @@ -199,7 +218,7 @@ int SchedulerHandler::process_info_bus_request_content_of_integral_time_info_typ
uint8_t value = TSL2591X::get_integral_time();

info_bus_response_content.set_value(value);
info_bus_response_content.set_nonce(State::get_current_response_nonce());
info_bus_response_content.set_nonce(State::allocate_response_nonce());

response_container.set_infoBus(info_bus_response_content);

Expand Down
15 changes: 15 additions & 0 deletions Core/External/Scheduler/Handler/scheduler_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ class SchedulerHandler {
*/
static int try_process_request_container();

/**
* Attempts to process outcoming response container if there is one.
*
* @param content - given request container content.
* @return status of the response container processing.
*/
static int try_process_response_container(const light_detector::RequestContainer &content);

/**
* Attempts to transmit outcoming response container.
*
* @return status of the response container processing.
*/
static int try_transmit_response_container();

/**
* Attempts to process data bus request content response.
*
Expand Down
4 changes: 2 additions & 2 deletions Core/External/State/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ int State::get_amount_of_processed_requests() {
return amount_of_processed_requests;
};

int State::get_current_response_nonce() {
return current_response_nonce;
int State::allocate_response_nonce() {
return current_response_nonce++;
}

Sequence<light_detector::RequestContainer> State::get_request_container_sequence() {
Expand Down
6 changes: 3 additions & 3 deletions Core/External/State/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class State {
static int get_amount_of_processed_requests();

/**
* Retrieves current(latest) response nonce.
* Allocates new response nonce.
*
* @return retrieved response nonce.
* @return allocated response nonce.
*/
static int get_current_response_nonce();
static int allocate_response_nonce();

/**
* Retrieves request container sequence.
Expand Down
82 changes: 82 additions & 0 deletions light_detector.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.cubeprog_external_loaders" value="[]"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_certif_path" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_check_enable" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_key_path" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_permission" value="debug_non_secure_L3"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.loadList" value="{&quot;fItems&quot;:[{&quot;fIsFromMainTab&quot;:true,&quot;fPath&quot;:&quot;Debug/light_detector.elf&quot;,&quot;fProjectName&quot;:&quot;light_detector&quot;,&quot;fPerformBuild&quot;:true,&quot;fDownload&quot;:true,&quot;fLoadSymbols&quot;:true}]}"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.override_start_address_mode" value="default"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.remoteCommand" value="target remote"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startServer" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.divby0" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="4000000"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_max_halt_delay" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="/Users/yaroslavsvitlytskyi/STM32CubeIDE/workspace_1.14.0/light_detector/Debug/st-link_gdbserver_log.txt"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/>
<intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/light_detector.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="light_detector"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.331241973"/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/light_detector"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
</launchConfiguration>

0 comments on commit 66a7ccc

Please sign in to comment.