diff --git a/cwrapper/scrutiny_cwrapper.cpp b/cwrapper/scrutiny_cwrapper.cpp index 291caf9..581273e 100644 --- a/cwrapper/scrutiny_cwrapper.cpp +++ b/cwrapper/scrutiny_cwrapper.cpp @@ -96,8 +96,8 @@ extern "C" get_config(config)->set_published_values( reinterpret_cast(array), // should match as per static_assert above nbr, - reinterpret_cast(reinterpret_cast(rd_cb)), // Expect signature to match - reinterpret_cast(reinterpret_cast(wr_cb))); // Expect signature to match + reinterpret_cast(rd_cb), // Expect signature to match + reinterpret_cast(wr_cb)); // Expect signature to match } void scrutiny_c_config_set_loops(scrutiny_c_config_t *config, scrutiny_c_loop_handler_t **loops, uint8_t const loop_count) diff --git a/lib/inc/datalogging/scrutiny_datalogger.hpp b/lib/inc/datalogging/scrutiny_datalogger.hpp index 5ce21d7..2daa2f7 100644 --- a/lib/inc/datalogging/scrutiny_datalogger.hpp +++ b/lib/inc/datalogging/scrutiny_datalogger.hpp @@ -22,6 +22,7 @@ namespace scrutiny { class MainHandler; + class LoopHandler; namespace datalogging { @@ -120,6 +121,11 @@ namespace scrutiny /// @brief Returns the number of bytes acquired since the trigger event. buffer_size_t data_counter_since_trigger(void) const; + /// @brief Return the LoopHandler that owns the datalogger. Null if owned by the MainHandler. This value is updated by the owner himself. + inline LoopHandler *get_owner(void) const { return m_owner; } + /// @brief Sets the LoopHandler that owns the datalogger. Null if owned by the MainHandler. This value is updated by the owner himself. + inline void set_owner(LoopHandler *const owner) { m_owner = owner; } + /// @brief Forces the trigger condition to be fulfilled, triggering an acquisition if the datalogger is armed. void force_trigger(void) { @@ -143,7 +149,7 @@ namespace scrutiny m_trigger_callback; // A function pointer to be called when the trigger trigs. Executed in the owner loop (no thread safety) Timebase const *m_timebase; // Pointer to the timebase of the owning loop. Used for logging at trigger handling (hold time & timeouts) - State::eState m_state; // Internal state + State::eState m_state; // Internal state timestamp_t m_trigger_timestamp; // The timestamp at which the trigger happened buffer_size_t m_trigger_cursor_location; // Cursor location when trigger point has been recorded @@ -159,6 +165,7 @@ namespace scrutiny uint16_t m_config_id; // The configuration ID given by the server buffer_size_t m_log_points_after_trigger; // Number of log entry counted after the trigger condition was fulfilled. + LoopHandler *m_owner; // A pointer to the loop owning the datalogger. Should reflect MainHandler::m_datalogging.owner. struct { bool previous_val; // Trigger condition result of the previous cycle diff --git a/lib/inc/datalogging/scrutiny_datalogger_raw_encoder.hpp b/lib/inc/datalogging/scrutiny_datalogger_raw_encoder.hpp index 25d5144..97c8d15 100644 --- a/lib/inc/datalogging/scrutiny_datalogger_raw_encoder.hpp +++ b/lib/inc/datalogging/scrutiny_datalogger_raw_encoder.hpp @@ -26,6 +26,8 @@ namespace scrutiny { class MainHandler; + class LoopHandler; + namespace datalogging { class RawFormatEncoder; @@ -62,7 +64,7 @@ namespace scrutiny datalogging::Configuration const *const config, uint8_t *const buffer, datalogging::buffer_size_t const buffer_size); - void encode_next_entry(void); + void encode_next_entry(LoopHandler *const caller); void reset(void); inline void reset_write_counter(void) { m_entry_write_counter = 0; } inline void set_timebase(Timebase const *const timebase) { m_timebase = timebase; } diff --git a/lib/inc/datalogging/scrutiny_datalogging.hpp b/lib/inc/datalogging/scrutiny_datalogging.hpp index 83e473a..3278a12 100644 --- a/lib/inc/datalogging/scrutiny_datalogging.hpp +++ b/lib/inc/datalogging/scrutiny_datalogging.hpp @@ -35,12 +35,14 @@ namespace scrutiny /// @param operand The operand to read /// @param val Output value /// @param variable_type Output variable type + /// @param caller the calling LoopHandler. Null if done by the MainHandler /// @return true on success. false on failure bool fetch_operand( MainHandler const *const main_handler, Operand const *const operand, AnyType *const val, - VariableType::eVariableType *const variable_type); + VariableType::eVariableType *const variable_type, + LoopHandler *const caller); } // namespace datalogging } // namespace scrutiny diff --git a/lib/inc/scrutiny_c_compatible_types.h b/lib/inc/scrutiny_c_compatible_types.h index cff70e5..22043db 100644 --- a/lib/inc/scrutiny_c_compatible_types.h +++ b/lib/inc/scrutiny_c_compatible_types.h @@ -134,9 +134,10 @@ typedef struct } scrutiny_c_runtime_published_value_t; /// @brief Callback called on Runtime Published Value read -typedef int (*scrutiny_c_rpv_read_callback_t)(scrutiny_c_runtime_published_value_t const rpv, scrutiny_c_any_type_t *outval); +typedef int (*scrutiny_c_rpv_read_callback_t)(scrutiny_c_runtime_published_value_t const rpv, scrutiny_c_any_type_t *outval, void *const caller); /// @brief Callback called on Runtime Published Value write -typedef int (*scrutiny_c_rpv_write_callback_t)(scrutiny_c_runtime_published_value_t const rpv, scrutiny_c_any_type_t const *inval); +typedef int ( + *scrutiny_c_rpv_write_callback_t)(scrutiny_c_runtime_published_value_t const rpv, scrutiny_c_any_type_t const *inval, void *const caller); #if SCRUTINY_ENABLE_DATALOGGING typedef void (*scrutiny_c_datalogging_trigger_callback_t)(); diff --git a/lib/inc/scrutiny_loop_handler.hpp b/lib/inc/scrutiny_loop_handler.hpp index b1f6a39..bedfbc7 100644 --- a/lib/inc/scrutiny_loop_handler.hpp +++ b/lib/inc/scrutiny_loop_handler.hpp @@ -96,7 +96,7 @@ namespace scrutiny m_name(name) #if SCRUTINY_ENABLE_DATALOGGING , - m_datalogger(SCRUTINY_NULL), m_owns_datalogger(false), m_datalogger_data_acquired(false), m_support_datalogging(true) + m_datalogger(SCRUTINY_NULL), m_datalogger_data_acquired(false), m_support_datalogging(true) #endif { } @@ -149,7 +149,7 @@ namespace scrutiny inline bool owns_datalogger(void) const { - return m_owns_datalogger; + return (m_datalogger->get_owner() == this); } #endif @@ -171,8 +171,6 @@ namespace scrutiny #if SCRUTINY_ENABLE_DATALOGGING /// @brief A pointer to the datalogger object part of the Main Handler datalogging::DataLogger *m_datalogger; - /// @brief Tells wether this loop is the owner of the datalogger - bool m_owns_datalogger; /// @brief Indicates if data has been acquired and ready to be downloaded or saved bool m_datalogger_data_acquired; /// @brief Indicates if this loop can do datalogging diff --git a/lib/inc/scrutiny_types.hpp b/lib/inc/scrutiny_types.hpp index cb984dc..68ec883 100644 --- a/lib/inc/scrutiny_types.hpp +++ b/lib/inc/scrutiny_types.hpp @@ -14,6 +14,8 @@ namespace scrutiny { + class LoopHandler; + namespace ctypes { #include "scrutiny_c_compatible_types.h" @@ -144,9 +146,9 @@ namespace scrutiny }; /// @brief Callback called on Runtime Published Value read - typedef bool (*RpvReadCallback)(RuntimePublishedValue const rpv, AnyType *outval); + typedef bool (*RpvReadCallback)(RuntimePublishedValue const rpv, AnyType *outval, LoopHandler *const caller); /// @brief Callback called on Runtime Published Value write - typedef bool (*RpvWriteCallback)(RuntimePublishedValue const rpv, AnyType const *inval); + typedef bool (*RpvWriteCallback)(RuntimePublishedValue const rpv, AnyType const *inval, LoopHandler *const caller); /// @brief Represents a memory block with data/mask pointer. Mainly used for memory write operations. struct MemoryBlock diff --git a/lib/src/datalogging/scrutiny_datalogger.cpp b/lib/src/datalogging/scrutiny_datalogger.cpp index 55b2fd8..4a4a78b 100644 --- a/lib/src/datalogging/scrutiny_datalogger.cpp +++ b/lib/src/datalogging/scrutiny_datalogger.cpp @@ -31,6 +31,7 @@ namespace scrutiny m_main_handler = main_handler; m_buffer_size = buffer_size; m_trigger_callback = trigger_callback; + m_owner = SCRUTINY_NULL; m_encoder.init(main_handler, &m_config, buffer, buffer_size); m_acquisition_id = 0; @@ -337,7 +338,7 @@ namespace scrutiny { if (++m_decimation_counter >= m_config.decimation) { - m_encoder.encode_next_entry(); + m_encoder.encode_next_entry(m_owner); m_decimation_counter = 0; } } @@ -371,7 +372,7 @@ namespace scrutiny for (unsigned int i = 0; i < nb_operand; i++) { - if (fetch_operand(m_main_handler, &m_config.trigger.operands[i], &opvals[i], &optypes[i]) == false) + if (fetch_operand(m_main_handler, &m_config.trigger.operands[i], &opvals[i], &optypes[i], SCRUTINY_NULL) == false) { return false; } diff --git a/lib/src/datalogging/scrutiny_datalogger_raw_encoder.cpp b/lib/src/datalogging/scrutiny_datalogger_raw_encoder.cpp index baa68c4..2855f06 100644 --- a/lib/src/datalogging/scrutiny_datalogger_raw_encoder.cpp +++ b/lib/src/datalogging/scrutiny_datalogger_raw_encoder.cpp @@ -114,7 +114,7 @@ namespace scrutiny } /// @brief Takes a snapshot of the data to log and write it into the datalogger buffer - void RawFormatEncoder::encode_next_entry(void) + void RawFormatEncoder::encode_next_entry(LoopHandler *const caller) { if (m_error) { @@ -148,7 +148,10 @@ namespace scrutiny uint16_t const rpv_id = m_config->items_to_log[i].data.rpv.id; m_main_handler->get_rpv(rpv_id, &rpv); uint8_t const typesize = tools::get_type_size(rpv.type); // Should be supported. We rely on datalogger::configure - m_main_handler->get_rpv_read_callback()(rpv, &outval); // We assume that this is not nullptr. We rely on datalogger::configure + m_main_handler->get_rpv_read_callback()( + rpv, + &outval, + caller); // We assume that this is not nullptr. We rely on datalogger::configure codecs::encode_anytype_big_endian(&outval, typesize, &m_buffer[cursor]); cursor += typesize; } diff --git a/lib/src/datalogging/scrutiny_datalogging.cpp b/lib/src/datalogging/scrutiny_datalogging.cpp index 84497a0..a94471a 100644 --- a/lib/src/datalogging/scrutiny_datalogging.cpp +++ b/lib/src/datalogging/scrutiny_datalogging.cpp @@ -100,7 +100,8 @@ namespace scrutiny MainHandler const *const main_handler, Operand const *const operand, AnyType *const val, - VariableType::eVariableType *const variable_type) + VariableType::eVariableType *const variable_type, + LoopHandler *const caller) { bool success = true; if (operand->type == OperandType::LITERAL) @@ -112,7 +113,7 @@ namespace scrutiny { RuntimePublishedValue rpv; main_handler->get_rpv(operand->data.rpv.id, &rpv); - success = main_handler->get_rpv_read_callback()(rpv, val); + success = main_handler->get_rpv_read_callback()(rpv, val, caller); *variable_type = rpv.type; } else if (operand->type == OperandType::VAR) diff --git a/lib/src/scrutiny_loop_handler.cpp b/lib/src/scrutiny_loop_handler.cpp index 0e1d70b..3df6b05 100644 --- a/lib/src/scrutiny_loop_handler.cpp +++ b/lib/src/scrutiny_loop_handler.cpp @@ -20,7 +20,6 @@ namespace scrutiny m_main2loop_msg.clear(); m_loop2main_msg.clear(); #if SCRUTINY_ENABLE_DATALOGGING - m_owns_datalogger = false; m_datalogger_data_acquired = false; m_datalogger = main_handler->datalogger(); #else @@ -42,27 +41,27 @@ namespace scrutiny { #if SCRUTINY_ENABLE_DATALOGGING case Main2LoopMessageID::TAKE_DATALOGGER_OWNERSHIP: - m_owns_datalogger = true; + m_datalogger->set_owner(this); m_datalogger_data_acquired = false; msg_out.message_id = Loop2MainMessageID::DATALOGGER_OWNERSHIP_TAKEN; m_loop2main_msg.send(msg_out); break; case Main2LoopMessageID::DATALOGGER_ARM_TRIGGER: - if (m_owns_datalogger) + if (owns_datalogger()) { m_datalogger->arm_trigger(); } break; case Main2LoopMessageID::DATALOGGER_DISARM_TRIGGER: - if (m_owns_datalogger) + if (owns_datalogger()) { m_datalogger->disarm_trigger(); } break; case Main2LoopMessageID::RELEASE_DATALOGGER_OWNERSHIP: - if (m_owns_datalogger) + if (owns_datalogger()) { - m_owns_datalogger = false; + m_datalogger->set_owner(SCRUTINY_NULL); msg_out.message_id = Loop2MainMessageID::DATALOGGER_OWNERSHIP_RELEASED; m_loop2main_msg.send(msg_out); } @@ -74,7 +73,7 @@ namespace scrutiny } #if SCRUTINY_ENABLE_DATALOGGING - if (m_owns_datalogger) + if (owns_datalogger()) { m_datalogger->process(); diff --git a/lib/src/scrutiny_main_handler.cpp b/lib/src/scrutiny_main_handler.cpp index 9b19ffc..8e56f9b 100644 --- a/lib/src/scrutiny_main_handler.cpp +++ b/lib/src/scrutiny_main_handler.cpp @@ -332,14 +332,15 @@ namespace scrutiny // No owner, can read directly. Otherwise will be updated by an IPC message m_datalogging.threadsafe_data.datalogger_state = m_datalogging.datalogger.get_state(); - if (m_datalogging.new_owner != SCRUTINY_NULL) + if (m_datalogging.new_owner != SCRUTINY_NULL) // We need to give ownership to someone else { - if (!m_datalogging.new_owner->ipc_main2loop()->has_content()) + if (!m_datalogging.new_owner->ipc_main2loop()->has_content()) // If there is room to send a msg { + // Ask the wanted new owner to take ownership LoopHandler::Main2LoopMessage msg; msg.message_id = LoopHandler::Main2LoopMessageID::TAKE_DATALOGGER_OWNERSHIP; m_datalogging.new_owner->ipc_main2loop()->send(msg); - m_datalogging.new_owner = SCRUTINY_NULL; + m_datalogging.new_owner = SCRUTINY_NULL; // } } @@ -349,7 +350,7 @@ namespace scrutiny } else { - if (!m_datalogging.owner->ipc_main2loop()->has_content()) + if (!m_datalogging.owner->ipc_main2loop()->has_content()) // If there is room to send a msg { LoopHandler::Main2LoopMessage msg; if (m_datalogging.request_ownership_release) @@ -371,6 +372,10 @@ namespace scrutiny m_datalogging.owner->ipc_main2loop()->send(msg); m_datalogging.request_disarm_trigger = false; } + else + { + // No message to send, do nothing + } } } } @@ -1185,7 +1190,7 @@ namespace scrutiny break; } - bool const callback_success = m_config.get_rpv_read_callback()(stack.read_rpv.rpv, &stack.read_rpv.v); + bool const callback_success = m_config.get_rpv_read_callback()(stack.read_rpv.rpv, &stack.read_rpv.v, SCRUTINY_NULL); if (!callback_success) { code = protocol::ResponseCode::FailureToProceed; @@ -1237,7 +1242,7 @@ namespace scrutiny continue; } - bool const write_success = m_config.get_rpv_write_callback()(stack.write_rpv.rpv, &stack.write_rpv.v); + bool const write_success = m_config.get_rpv_write_callback()(stack.write_rpv.rpv, &stack.write_rpv.v, SCRUTINY_NULL); if (!write_success) { code = protocol::ResponseCode::FailureToProceed; diff --git a/projects/c_testapp/src/main.c b/projects/c_testapp/src/main.c index 9c37a05..d993a47 100644 --- a/projects/c_testapp/src/main.c +++ b/projects/c_testapp/src/main.c @@ -109,8 +109,9 @@ struct #endif } rpvStorage; -int TestAppRPVReadCallback(const scrutiny_c_runtime_published_value_t rpv, scrutiny_c_any_type_t *outval) +int TestAppRPVReadCallback(const scrutiny_c_runtime_published_value_t rpv, scrutiny_c_any_type_t *outval, scrutiny_c_loop_handler_t* const caller) { + (void)caller; int ok = 1; if (rpv.id == 0x1000) { @@ -166,8 +167,9 @@ int TestAppRPVReadCallback(const scrutiny_c_runtime_published_value_t rpv, scrut return ok; } -int TestAppRPVWriteCallback(const scrutiny_c_runtime_published_value_t rpv, const scrutiny_c_any_type_t *inval) +int TestAppRPVWriteCallback(const scrutiny_c_runtime_published_value_t rpv, const scrutiny_c_any_type_t *inval, scrutiny_c_loop_handler_t* const caller) { + (void) caller; int ok = 1; if (rpv.id == 0x1000) { diff --git a/projects/testapp/src/main.cpp b/projects/testapp/src/main.cpp index 08cc53c..5622634 100644 --- a/projects/testapp/src/main.cpp +++ b/projects/testapp/src/main.cpp @@ -106,8 +106,9 @@ struct #endif } rpvStorage; -bool TestAppRPVReadCallback(const scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval) +bool TestAppRPVReadCallback(const scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval, scrutiny::LoopHandler *const caller) { + static_cast(caller); bool ok = true; if (rpv.id == 0x1000) { @@ -175,8 +176,9 @@ bool TestAppRPVReadCallback(const scrutiny::RuntimePublishedValue rpv, scrutiny: return ok; } -bool TestAppRPVWriteCallback(const scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType const *inval) +bool TestAppRPVWriteCallback(const scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType const *inval, scrutiny::LoopHandler *const caller) { + static_cast(caller); bool ok = true; if (rpv.id == 0x1000) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d22eed1..057a61f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,7 +7,7 @@ include(FetchContent) FetchContent_Declare( scrutinytest GIT_REPOSITORY https://github.com/scrutinydebugger/scrutiny-test-framework - GIT_TAG 2420737a511a073d021e73b7651e7731b8960b89 + GIT_TAG 52110794f54e2c6a7c8026523b23f3f396b1ea44 ) set(SCRUTINYTEST_DISABLE_EXCEPTIONS OFF) diff --git a/test/commands/test_datalog_control.cpp b/test/commands/test_datalog_control.cpp index 00d3172..bbd75e5 100644 --- a/test/commands/test_datalog_control.cpp +++ b/test/commands/test_datalog_control.cpp @@ -16,8 +16,9 @@ using namespace scrutiny; -static bool rpv_read_callback(RuntimePublishedValue rpv, AnyType *outval) +static bool rpv_read_callback(RuntimePublishedValue rpv, AnyType *outval, LoopHandler *const caller) { + static_cast(caller); if (rpv.id == 0x8888 && rpv.type == VariableType::float32) { outval->float32 = 1.7f; diff --git a/test/commands/test_get_info.cpp b/test/commands/test_get_info.cpp index f6913ba..36b9b42 100644 --- a/test/commands/test_get_info.cpp +++ b/test/commands/test_get_info.cpp @@ -261,18 +261,20 @@ TEST_F(TestGetInfo, TestGetSpecialMemoryRegionLocation_WrongIndex) Reads the number of Runtime Published Values */ -static bool rpv_read_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval) +static bool rpv_read_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval, scrutiny::LoopHandler *const caller) { static_cast(rpv); static_cast(outval); + static_cast(caller); // nothing to do here. return true; } -static bool rpv_write_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType const *inval) +static bool rpv_write_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType const *inval, scrutiny::LoopHandler *const caller) { static_cast(rpv); static_cast(inval); + static_cast(caller); // nothing to do here. return true; } diff --git a/test/commands/test_memory_control_rpv.cpp b/test/commands/test_memory_control_rpv.cpp index bbd6020..4a58685 100644 --- a/test/commands/test_memory_control_rpv.cpp +++ b/test/commands/test_memory_control_rpv.cpp @@ -43,8 +43,9 @@ class TestMemoryControlRPV : public ScrutinyTest }; // ==== Test Runtime Published Valuers -static bool rpv_read_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval) +static bool rpv_read_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval, scrutiny::LoopHandler *const caller) { + static_cast(caller); uint32_t v1 = 0x12345678; float v2 = 1.34f; uint16_t v3 = 0xabcd; @@ -150,8 +151,9 @@ struct AllTypeResult }; static AllTypeResult dest_buffer_for_rpv_write; -static bool rpv_write_callback(const scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType const *inval) +static bool rpv_write_callback(const scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType const *inval, scrutiny::LoopHandler *const caller) { + static_cast(caller); if (rpv.id == 0x1000 && rpv.type == scrutiny::VariableType::uint8) { dest_buffer_for_rpv_write.some_u8 = inval->uint8; diff --git a/test/datalogging/test_datalogger.cpp b/test/datalogging/test_datalogger.cpp index c833f5a..82c7f41 100644 --- a/test/datalogging/test_datalogger.cpp +++ b/test/datalogging/test_datalogger.cpp @@ -23,9 +23,11 @@ using namespace std; static uint32_t g_u32_rpv1000 = 0; static uint32_t g_trigger_callback_count = 0; +static LoopHandler *g_last_rpv_callback_caller = SCRUTINY_NULL; -static bool rpv_read_callback(RuntimePublishedValue rpv, AnyType *outval) +static bool rpv_read_callback(RuntimePublishedValue rpv, AnyType *outval, LoopHandler *const caller) { + g_last_rpv_callback_caller = caller; if (rpv.id == 0x1234 && rpv.type == VariableType::uint32) { outval->uint32 = 0xaabbccdd; @@ -120,6 +122,7 @@ class TestDatalogger : public ScrutinyTest memset(buffer_canary_2, 0x55, sizeof(buffer_canary_2)); g_trigger_callback_count = 0; + g_last_rpv_callback_caller = SCRUTINY_NULL; } }; @@ -270,6 +273,8 @@ TEST_F(TestDatalogger, ComplexAcquisition) float var1 = 0.0; int32_t var2 = 0; float trigger_val = 0.0f; + FixedFrequencyLoopHandler loop_handler(100000, "testloop"); + datalogger.set_owner(&loop_handler); datalogging::Configuration dlconfig; dlconfig.items_count = 4; @@ -310,7 +315,10 @@ TEST_F(TestDatalogger, ComplexAcquisition) std::string error_msg = "probe_location=" + NumberToString(probe_location); datalogger.config()->copy_from(&dlconfig); datalogger.configure(&tb); - + if (probe_loop == 0) + { + EXPECT_NULL(g_last_rpv_callback_caller); + } datalogger.process(); tb.step(10); datalogger.process(); @@ -322,6 +330,7 @@ TEST_F(TestDatalogger, ComplexAcquisition) datalogger.process(); tb.step(10); } + EXPECT_EQ(g_last_rpv_callback_caller, &loop_handler); EXPECT_FALSE(datalogger.data_acquired()) << error_msg; datalogger.arm_trigger(); diff --git a/test/datalogging/test_fetch_operands.cpp b/test/datalogging/test_fetch_operands.cpp index 6e1dee8..2b6c22f 100644 --- a/test/datalogging/test_fetch_operands.cpp +++ b/test/datalogging/test_fetch_operands.cpp @@ -1,4 +1,4 @@ -// test_fetch_operands.cpp +// test_fetch_operands.c, SCRUTINY_NULLpp // Test the capacity to decode an operand for log trigger // // - License : MIT - See LICENSE file. @@ -12,8 +12,9 @@ #include "scrutiny.hpp" #include "scrutiny_test.hpp" -static bool rpv_read_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval) +static bool rpv_read_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval, scrutiny::LoopHandler *const caller) { + static_cast(caller); if (rpv.id == 0x1234 && rpv.type == scrutiny::VariableType::uint32) { outval->uint32 = 0xaabbccdd; @@ -96,7 +97,7 @@ TEST_F(TestFetchOperands, TestFetchLiteral) Operand operand; operand.type = OperandType::LITERAL; operand.data.literal.val = 0.1234f; - bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_TRUE(success); EXPECT_EQ(vartype, scrutiny::VariableType::float32); EXPECT_EQ(val.float32, 0.1234f); @@ -114,7 +115,7 @@ TEST_F(TestFetchOperands, TestFetchVar) operand.data.var.addr = &my_var; operand.data.var.datatype = scrutiny::VariableType::float32; - bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_TRUE(success); EXPECT_EQ(vartype, scrutiny::VariableType::float32); @@ -130,13 +131,13 @@ TEST_F(TestFetchOperands, TestFetchRPV) operand.type = OperandType::RPV; operand.data.rpv.id = 0x1234; - bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_TRUE(success); EXPECT_EQ(vartype, scrutiny::VariableType::uint32); EXPECT_EQ(val.uint32, 0xaabbccdd); operand.data.rpv.id = 0x5678; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_TRUE(success); EXPECT_EQ(vartype, scrutiny::VariableType::float32); EXPECT_EQ(val.float32, 3.1415926f); @@ -166,7 +167,7 @@ TEST_F(TestFetchOperands, TestFetchVarBit) operand.data.varbit.bitoffset = 3; operand.data.varbit.bitsize = 11; - bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_TRUE(success); EXPECT_EQ(vartype, scrutiny::VariableType::sint16); EXPECT_EQ(val.sint16, my_struct.val); @@ -180,7 +181,7 @@ TEST_F(TestFetchOperands, TestBadOperandType) Operand operand; operand.type = static_cast(0xff); - bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_FALSE(success); } @@ -194,7 +195,7 @@ TEST_F(TestFetchOperands, TestFetchForbiddenMemory) operand.data.var.addr = forbidden_buffer; operand.data.var.datatype = scrutiny::VariableType::uint8; - bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_FALSE(success); } @@ -207,7 +208,7 @@ TEST_F(TestFetchOperands, TestFetchInexistandRPV) operand.type = OperandType::RPV; operand.data.rpv.id = 0xAAAA; - bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + bool success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_FALSE(success); } @@ -239,12 +240,12 @@ TEST_F(TestFetchOperands, TestFetchBitfieldsLimits) operand.data.varbit.bitoffset = 31; operand.data.varbit.bitsize = 1; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_TRUE(success); operand.data.varbit.bitoffset = 32; operand.data.varbit.bitsize = 1; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); #if SCRUTINY_SUPPORT_64BITS EXPECT_TRUE(success); @@ -254,12 +255,12 @@ TEST_F(TestFetchOperands, TestFetchBitfieldsLimits) operand.data.varbit.bitoffset = 0; operand.data.varbit.bitsize = 32; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_TRUE(success); operand.data.varbit.bitoffset = 0; operand.data.varbit.bitsize = 33; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); #if SCRUTINY_SUPPORT_64BITS EXPECT_TRUE(success); #else @@ -268,7 +269,7 @@ TEST_F(TestFetchOperands, TestFetchBitfieldsLimits) operand.data.varbit.bitoffset = 63; operand.data.varbit.bitsize = 1; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); #if SCRUTINY_SUPPORT_64BITS EXPECT_TRUE(success); #else @@ -277,12 +278,12 @@ TEST_F(TestFetchOperands, TestFetchBitfieldsLimits) operand.data.varbit.bitoffset = 64; operand.data.varbit.bitsize = 1; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_FALSE(success); operand.data.varbit.bitoffset = 0; operand.data.varbit.bitsize = 64; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); #if SCRUTINY_SUPPORT_64BITS EXPECT_TRUE(success); #else @@ -291,11 +292,11 @@ TEST_F(TestFetchOperands, TestFetchBitfieldsLimits) operand.data.varbit.bitoffset = 0; operand.data.varbit.bitsize = 65; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_FALSE(success); operand.data.varbit.bitoffset = 0; operand.data.varbit.bitsize = 0; - success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype); + success = fetch_operand(&scrutiny_handler, &operand, &val, &vartype, SCRUTINY_NULL); EXPECT_FALSE(success); } diff --git a/test/datalogging/test_raw_encoder.cpp b/test/datalogging/test_raw_encoder.cpp index 4266b86..07dd55a 100644 --- a/test/datalogging/test_raw_encoder.cpp +++ b/test/datalogging/test_raw_encoder.cpp @@ -95,15 +95,15 @@ TEST_F(TestRawEncoder, BasicEncoding) var1 = 1.0f; var2 = 0x1111u; - encoder.encode_next_entry(); + encoder.encode_next_entry(SCRUTINY_NULL); timebase.step(100); var1 = 2.0f; var2 = 0x2222u; - encoder.encode_next_entry(); + encoder.encode_next_entry(SCRUTINY_NULL); timebase.step(100); var1 = 3.0f; var2 = 0x3333u; - encoder.encode_next_entry(); + encoder.encode_next_entry(SCRUTINY_NULL); datalogging::RawFormatReader *reader = encoder.get_reader(); reader->reset(); diff --git a/test/datalogging/test_trigger_conditions.cpp b/test/datalogging/test_trigger_conditions.cpp index c5bc445..9c2b83a 100644 --- a/test/datalogging/test_trigger_conditions.cpp +++ b/test/datalogging/test_trigger_conditions.cpp @@ -12,8 +12,9 @@ #include "scrutiny.hpp" #include "scrutiny_test.hpp" -static bool rpv_read_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval) +static bool rpv_read_callback(scrutiny::RuntimePublishedValue rpv, scrutiny::AnyType *outval, scrutiny::LoopHandler *const caller) { + static_cast(caller); if (rpv.id == 0x1234 && rpv.type == scrutiny::VariableType::uint32) { outval->uint32 = 0xaabbccdd;