전체 애플리케이션을 위한 모듈 템플릿
An application can be written to run as either a task (a module with its own stack and process priority) or as a work queue task (a module that runs on a work queue thread, sharing the stack and thread priority with other tasks on the work queue). 대부분은, 리소스 최소화를 위하여 작업 대기열을 사용합니다.
INFO
Architectural Overview > Runtime Environment provides more information about tasks and work queue tasks.
INFO
All the things learned in the First Application Tutorial are relevant for writing a full application.
작업 대기열 작업
PX4-Autopilot contains a template for writing a new application (module) that runs as a work queue task: src/examples/work_item.
작업 대기열 작업 응용 프로그램은 작업 대기열 작업임을 지정하고 초기화중에 실행되도록 예약해야 한다는 점을 제외하고 일반(작업) 응용 프로그램과 동일합니다.
예제는 방법을 설명합니다. 요약
Specify the dependency on the work queue library in the cmake definition file (CMakeLists.txt):
... DEPENDS px4_work_queue
In addition to
ModuleBase
, the task should also derive fromScheduledWorkItem
(included from ScheduledWorkItem.hpp)생성자 초기화에서 작업을 추가할 대기열을 지정합니다. The work_item example adds itself to the
wq_configurations::test1
work queue as shown below:cppWorkItemExample::WorkItemExample() : ModuleParams(nullptr), ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::test1) { }
INFO
The available work queues (
wq_configurations
) are listed in WorkQueueManager.hpp.
:::
Implement the
ScheduledWorkItem::Run()
method to perform "work".Implement the
task_spawn
method, specifying that the task is a work queue (using thetask_id_is_work_queue
id.Schedule the work queue task using one of the scheduling methods (in the example we use
ScheduleOnInterval
from within theinit
method).
작업
PX4/PX4-Autopilot contains a template for writing a new application (module) that runs as a task on its own stack: src/templates/template_module.
템플릿은 전체 애플리케이션에 필요하거나 유용한 다음과 같은 추가 기능/측면을 보여줍니다.
- 매개변수에 액세스하고 매개변수 업데이트에 반응합니다.
- uORB 구독 및 주제 업데이트 대기 중입니다.
- Controlling the task that runs in the background via
start
/stop
/status
. Themodule start [<arguments>]
command can then be directly added to the startup script. - 명령줄 인수 구문 분석.
- Documentation: the
PRINT_MODULE_*
methods serve two purposes (the API is documented in the source code):- They are used to print the command-line usage when entering
module help
on the console. - They are automatically extracted via script to generate the Modules & Commands Reference page.
- They are used to print the command-line usage when entering