Skip to content

Commit

Permalink
sighandler explicit function
Browse files Browse the repository at this point in the history
  • Loading branch information
David Michaeli committed Jan 29, 2024
1 parent 5ca7c52 commit 43c505d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions software/libcariboulite/src/CaribouLite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ class CaribouLite
std::string GetHwGuid(void);
CaribouLiteRadio* GetRadioChannel(CaribouLiteRadio::RadioType ch);

// Signal Handler
void RegisterSignalHandler(std::function<void(int)> on_signal_caught);

// Static detection and factory
static CaribouLite &GetInstance(bool forceFpgaProg = false, LogLevel logLvl = LogLevel::None);
static bool DetectBoard(SysVersion *sysVer, std::string& name, std::string& guid);
Expand All @@ -258,6 +261,7 @@ class CaribouLite
uint8_t GetPmodState (void);

private:
std::function<void(int)> _on_signal_caught;
std::vector<CaribouLiteRadio*> _channels;
SysVersion _systemVersion;
std::string _productName;
Expand Down
8 changes: 8 additions & 0 deletions software/libcariboulite/src/CaribouLiteCpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ void CaribouLite::DefaultSignalHandler(void* context, int signal_number, siginfo
{
CaribouLite* cl = (CaribouLite*)context;
std::cout << " >> Signal caught: " << signal_number << std::endl << std::flush;

if (cl->_on_signal_caught) cl->_on_signal_caught(signal_number);
//cl->ReleaseResources();
}

//==================================================================
void CaribouLite::RegisterSignalHandler(std::function<void(int)> on_signal_caught)
{
_on_signal_caught = on_signal_caught;
}

//==================================================================
bool CaribouLite::DetectBoard(SysVersion *sysVer, std::string& name, std::string& guid)
{
Expand Down

0 comments on commit 43c505d

Please sign in to comment.