exceptions #1

Merged
bartoszek merged 18 commits from exceptions into main 2025-05-06 09:39:21 +00:00
4 changed files with 49 additions and 41 deletions
Showing only changes of commit 4073332db9 - Show all commits

View File

@ -5,13 +5,11 @@ project(rims_controller C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_MODULE_PATH ${ZEPHYR_BASE}/modules/nanopb)
include(nanopb)
FILE(GLOB app_sources src/*.cpp src/*.c src/*.hpp src/*.h)
FILE(GLOB app_sources src/main.cpp src/*.cpp src/*.c src/*.hpp src/*.h)
FILE(GLOB app_protos proto/*.proto)
target_sources(app PRIVATE ${app_sources} ${app_protos})
target_compile_options(app PUBLIC -fexceptions)
zephyr_nanopb_sources(app ${app_protos})

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 15.0.1, 2025-02-26T20:08:18. -->
<!-- Written by QtCreator 15.0.1, 2025-03-05T20:29:22. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -219,14 +219,36 @@
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">zephyr_final</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">zephyr_final</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/bartoszek/zephyrproject/zephyr/rims_app/build/zephyr</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">zephyr_pre0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">zephyr_pre0</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/bartoszek/zephyrproject/zephyr/rims_app/build/zephyr</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
</valuemap>
</data>
<data>

View File

@ -4,11 +4,11 @@ CONFIG_GEN_ISR_TABLES=y
CONFIG_GEN_IRQ_VECTOR_TABLE=y
# kernel configuration
#CONFIG_EVENTS=y
#CONFIG_POLL=y
CONFIG_EVENTS=y
CONFIG_POLL=y
CONFIG_POSIX_API=y
CONFIG_POSIX_TIMERS=y
CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y
# CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y
#CONFIG_USERSPACE=y
#CONFIG_HW_STACK_PROTECTION=y
@ -22,34 +22,34 @@ CONFIG_CPP_EXCEPTIONS=y
CONFIG_CPP_RTTI=n
#CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=512
CONFIG_REQUIRES_FULL_LIBCPP=y
#CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_NANO=n
#
CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_NAME=y
#
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_EARLY_CONSOLE=n
CONFIG_BOOT_BANNER=n
#
CONFIG_SERIAL=y
# not working as expected for TX
CONFIG_UART_ASYNC_API=n
CONFIG_DMA=n
#CONFIG_UART_ASYNC_API=n
# CONFIG_DMA=n
#
CONFIG_UART_INTERRUPT_DRIVEN=y
#
CONFIG_ADC=y
#CONFIG_LOG=n
#CONFIG_LOG_MODE_IMMEDIATE=n # Log messages are output immediately
#CONFIG_LOG_BACKEND_UART=n # Use UART for log output
#CONFIG_MAIN_STACK_SIZE=512
CONFIG_LOG=n
CONFIG_LOG_MODE_IMMEDIATE=n # Log messages are output immediately
CONFIG_LOG_BACKEND_UART=n # Use UART for log output
CONFIG_MAIN_STACK_SIZE=1500
#
CONFIG_CRC=y
CONFIG_ASSERT=n
#CONFIG_NUM_PREEMPT_PRIORITIES=0

View File

@ -7,12 +7,9 @@
#include "uart.hpp"
#include "zero_cross_detection.hpp"
#include <chrono>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <exception>
#include <thread>
#include <zephyr/kernel.h>
#include <zephyr/kernel/thread.h>
@ -42,10 +39,10 @@ TStack uartStack{k_uartStack, K_THREAD_STACK_SIZEOF(k_uartStack)};
static K_THREAD_STACK_DEFINE(k_temperatureSamplerStack, 2048);
TStack temperatureSamplerStack{k_temperatureSamplerStack, K_THREAD_STACK_SIZEOF(k_temperatureSamplerStack)};
static K_THREAD_STACK_DEFINE(k_zeroCrossDetectionStack, 1500);
static K_THREAD_STACK_DEFINE(k_zeroCrossDetectionStack, 2048);
TStack zeroCrossDetectionStack{k_zeroCrossDetectionStack, K_THREAD_STACK_SIZEOF(k_zeroCrossDetectionStack)};
static K_THREAD_STACK_DEFINE(k_phaseModulationStack, 1500);
static K_THREAD_STACK_DEFINE(k_phaseModulationStack, 2048);
TStack phaseModulationStack{k_phaseModulationStack, K_THREAD_STACK_SIZEOF(k_phaseModulationStack)};
/// TOP LEVEL TODOS ;)
@ -79,15 +76,6 @@ LazyInit<ZeroCrossDetectionThread> zcd;
LazyInit<PhaseModulationThread> phaseModulation;
struct except : std::exception {};
// extern "C"{
// void * _sbrk(int p_amount){
// static char b[1024];
// return b;
// }
// }
int main() {
using namespace rims;
@ -113,12 +101,12 @@ int main() {
phaseModulation->start();
while (1) {
std::this_thread::sleep_for(std::chrono::seconds{2});
// std::this_thread::sleep_for(std::chrono::seconds{2});
try {
throw except{};
} catch (const except &e) {
ULOG_ERROR("got exception");
while(1){}
}
}