-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Document OSAL Integration #3050
Comments
ok fine |
Already saved a file called osal documentation |
@rithvikrajraapeti Thanks for contributing! |
Adding and Configuring OSAL Layers in F PrimeOverviewThis guide explains how to:
Directory StructureAdd your OSAL implementation in the
1. Implementing OSAL FilesTask Implementation Example (Task.cpp)#include <Os/Task.hpp>
namespace Os {
Task::Task() :
m_handle(0),
m_identifier(0),
m_started(false) {
}
Task::TaskStatus Task::start(const Fw::StringBase &name,
NATIVE_INT_TYPE identifier,
NATIVE_INT_TYPE priority,
NATIVE_INT_TYPE stackSize,
taskRoutine routine,
void* arg,
NATIVE_INT_TYPE cpuAffinity) {
// Your RTOS-specific implementation here
return TASK_OK;
}
Task::TaskStatus Task::delay(NATIVE_UINT_TYPE milliseconds) {
// Your RTOS-specific delay implementation
return TASK_OK;
}
// Implement other required methods...
} Queue Implementation Example (Queue.cpp)#include <Os/Queue.hpp>
namespace Os {
Queue::Queue() :
m_handle(nullptr),
m_size(0),
m_maxMsgSize(0) {
}
Queue::QueueStatus Queue::create(const Fw::StringBase &name,
NATIVE_INT_TYPE depth,
NATIVE_INT_TYPE msgSize) {
// Your RTOS-specific queue creation
return QUEUE_OK;
}
// Implement other required methods...
} 2. CMake ConfigurationOSAL Directory CMakeLists.txt# MyNewOsal/CMakeLists.txt
# Create library for your OSAL implementation
add_fprime_library(
MyNewOsal
SOURCES
Task.cpp
Queue.cpp
Mutex.cpp
File.cpp
LINK_LIBRARIES
Fw_Types
) Main Os CMakeLists.txt# Os/CMakeLists.txt
# Add OSAL selection option
set(FPRIME_OSAL "Linux" CACHE STRING "Select OSAL implementation")
set_property(CACHE FPRIME_OSAL PROPERTY STRINGS "Linux" "FreeRTOS" "MyNewOsal")
# Configure based on selection
if(${FPRIME_OSAL} STREQUAL "MyNewOsal")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/MyNewOsal")
set(OSAL_SELECTED_BUILD TRUE)
endif() 3. Required OSAL ImplementationsYour OSAL must implement these core classes:
4. Selecting Your OSALCommand Linefprime-util generate -DFPRIME_OSAL=MyNewOsal CMake Configuration# In your project's CMakeLists.txt
set(FPRIME_OSAL "MyNewOsal" CACHE STRING "Use custom OSAL") 5. OSAL Interface RequirementsTask Interfaceclass Task {
public:
virtual TaskStatus start(
const Fw::StringBase &name,
NATIVE_INT_TYPE identifier,
NATIVE_INT_TYPE priority,
NATIVE_INT_TYPE stackSize,
taskRoutine routine,
void* arg,
NATIVE_INT_TYPE cpuAffinity = -1
) = 0;
virtual TaskStatus delay(NATIVE_UINT_TYPE milliseconds) = 0;
// Other required methods...
}; Queue Interfaceclass Queue {
public:
virtual QueueStatus create(
const Fw::StringBase &name,
NATIVE_INT_TYPE depth,
NATIVE_INT_TYPE msgSize
) = 0;
virtual QueueStatus send(
const U8* buffer,
NATIVE_INT_TYPE size,
NATIVE_INT_TYPE timeout
) = 0;
// Other required methods...
}; 6. Testing Your OSALCreate unit tests in // MyNewOsalTest.cpp
#include <gtest/gtest.h>
#include <Os/Task.hpp>
TEST(MyNewOsal, TaskCreation) {
Os::Task task;
Os::Task::TaskStatus status = task.start(
"TestTask",
0,
100,
1024,
someTaskRoutine,
nullptr
);
ASSERT_EQ(status, Os::Task::TASK_OK);
} 7. Best Practices
8. Example Platform Configuration# platform/MyPlatform/CMakeLists.txt
set(FPRIME_OSAL "MyNewOsal" CACHE STRING "Platform OSAL selection")
set(FPRIME_OSAL_DEFINES
-DFPRIME_CUSTOM_OS_DEFINES
-DSTACK_SIZE=4096
-DMAX_PRIORITY=255
)
add_definitions(${FPRIME_OSAL_DEFINES}) 9. Common Issues and Solutions
|
Feature Description
Document how to add an OSAL layer, and select it in CMake.
The text was updated successfully, but these errors were encountered: