-
Notifications
You must be signed in to change notification settings - Fork 1
Added Event sending through mavlink #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a67736e
Basic event sending throug mavlink
Michal-Mankowski 6041d3d
partially done ut
Michal-Mankowski 2ddab3c
makr fix event_data issue
Mateusz-Krajewski 4bc827b
Fixes
Michal-Mankowski 2e3c9ce
s
Michal-Mankowski ae69f16
Fixed conflicts
Michal-Mankowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
cc_library( | ||
name = "radio_app_lib", | ||
deps = [ | ||
"@srp_platform//ara/exec:adaptive_application_lib", | ||
"@srp_mavlink//lib:mavlink_lib", | ||
"//deployment/apps/fc/radio_app:someip_lib", | ||
"//deployment/apps/fc/radio_app:ara", | ||
"//core/timestamp:timestamp_controller", | ||
"//core/uart:uart_driver" | ||
], | ||
srcs = [ | ||
"radio_app.cc" | ||
], | ||
hdrs = [ | ||
"radio_app.h", | ||
"event_data.h", | ||
], | ||
visibility = ["//apps/fc/radio_service:__subpackages__",], | ||
) | ||
|
||
cc_binary( | ||
name = "radio_service", | ||
srcs = [ | ||
"main.cc", | ||
], | ||
visibility = [ | ||
"//deployment:__subpackages__", | ||
], | ||
deps = [ | ||
"//apps/fc/radio_service:radio_app_lib", | ||
], | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/** | ||
* @file event_data.h | ||
* @author Michał Mańkowski (m.mankowski2004@gmail.com) | ||
* @brief | ||
* @version 0.1 | ||
* @date 2025-04-17 | ||
* | ||
* @copyright Copyright (c) 2025 | ||
* | ||
*/ | ||
#ifndef APPS_FC_RADIO_SERVICE_EVENT_DATA_H_ | ||
#define APPS_FC_RADIO_SERVICE_EVENT_DATA_H_ | ||
|
||
#include <mutex> // NOLINT | ||
#include <shared_mutex> | ||
#include <memory> | ||
|
||
#include "lib/simba/mavlink.h" | ||
#include "ara/core/result.h" | ||
|
||
namespace srp { | ||
namespace apps { | ||
class EventData; | ||
static std::shared_ptr<EventData> event_data = nullptr; | ||
|
||
class EventData { | ||
private: | ||
__mavlink_simba_tank_temperature_t temp; | ||
__mavlink_simba_tank_pressure_t press; | ||
__mavlink_simba_gps_t gps; | ||
__mavlink_simba_actuator_t actuator; | ||
std::mutex mtx_; | ||
template <typename T> | ||
void SetValue(T res, T* field) { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
*field = res; | ||
} | ||
|
||
public: | ||
static std::shared_ptr<EventData> GetInstance() { | ||
if (event_data == nullptr) { | ||
event_data = std::make_shared<EventData>(); | ||
} | ||
return event_data; | ||
} | ||
|
||
void SetTemp1(uint16_t res) { | ||
SetValue(res, &this->temp.temp1); | ||
} | ||
|
||
void SetTemp2(uint16_t res) { | ||
SetValue(res, &this->temp.temp2); | ||
} | ||
|
||
void SetTemp3(uint16_t res) { | ||
SetValue(res, &this->temp.temp3); | ||
} | ||
|
||
void SetDPress(float res) { | ||
SetValue(res, &this->press.Dpressure); | ||
} | ||
|
||
void SetPress(float res) { | ||
SetValue(res, &this->press.pressure); | ||
} | ||
|
||
void SetGPS(int32_t lon, int32_t lat) { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
this->gps.lat = lat; | ||
this->gps.lon = lon; | ||
} | ||
|
||
|
||
|
||
void SetActuatorBit(const std::uint8_t res, uint8_t bit_position) { | ||
if (bit_position > 7 || bit_position < 0 || res > 1) { | ||
return; | ||
} | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
this->actuator.values = (this->actuator.values & ~(1 << bit_position)) | (res << bit_position); | ||
} | ||
|
||
uint16_t GetTemp1() { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
Michal-Mankowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return this->temp.temp1; | ||
} | ||
|
||
uint16_t GetTemp2() { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
return this->temp.temp2; | ||
} | ||
|
||
uint16_t GetTemp3() { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
return this->temp.temp3; | ||
} | ||
|
||
float GetDPress() { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
return this->press.Dpressure; | ||
} | ||
|
||
float GetPress() { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
return this->press.pressure; | ||
} | ||
|
||
int32_t GetGPSLat() { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
return this->gps.lat; | ||
} | ||
|
||
int32_t GetGPSLon() { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
return this->gps.lon; | ||
} | ||
|
||
uint8_t GetActuator() { | ||
std::unique_lock<std::mutex> lock(this->mtx_); | ||
return this->actuator.values; | ||
} | ||
}; | ||
} // namespace apps | ||
} // namespace srp | ||
|
||
#endif // APPS_FC_RADIO_SERVICE_EVENT_DATA_H_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @file main.cc | ||
* @author Michał Mańkowski (m.mankowski2004@gmail.com) | ||
* @brief | ||
* @version 0.1 | ||
* @date 2025-04-07 | ||
* | ||
* @copyright Copyright (c) 2025 | ||
* | ||
*/ | ||
#include "apps/fc/radio_service/radio_app.h" | ||
#include "ara/exec/adaptive_lifecycle.h" | ||
int main(int argc, char const *argv[]) { | ||
// setsid(); | ||
return ara::exec::RunAdaptiveLifecycle<srp::apps::RadioApp>(argc, | ||
argv); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.