mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 08:53:34 +08:00
add simple posix tests to SITL
This commit is contained in:
committed by
Nuno Marques
parent
5eb3e695bb
commit
af9690cf08
@@ -38,6 +38,8 @@
|
||||
* @author Mark Charlebois <mcharleb@gmail.com>
|
||||
*/
|
||||
#include "hello_example.h"
|
||||
|
||||
#include <px4_log.h>
|
||||
#include <px4_app.h>
|
||||
#include <px4_tasks.h>
|
||||
#include <stdio.h>
|
||||
@@ -46,7 +48,7 @@
|
||||
|
||||
#define SCHED_DEFAULT SCHED_FIFO
|
||||
#define SCHED_PRIORITY_MAX sched_get_priority_max(SCHED_FIFO)
|
||||
#define SCHED_PRIORITY_DEFAULT sched_get_priority_max(SCHED_FIFO)
|
||||
//#define SCHED_PRIORITY_DEFAULT sched_get_priority_max(SCHED_FIFO)
|
||||
|
||||
static int daemon_task; /* Handle of deamon task / thread */
|
||||
|
||||
@@ -74,7 +76,7 @@ int hello_main(int argc, char *argv[])
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
2000,
|
||||
PX4_MAIN,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
############################################################################
|
||||
px4_add_module(
|
||||
MODULE platforms__posix__tests__hrt_test
|
||||
MAIN hrttest
|
||||
MAIN hrt_test
|
||||
SRCS
|
||||
hrt_test_main.cpp
|
||||
hrt_test_start_posix.cpp
|
||||
|
||||
@@ -59,7 +59,7 @@ static void timer_expired(void *arg)
|
||||
|
||||
if (i < 5) {
|
||||
i++;
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)0);
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ int HRTTest::main()
|
||||
|
||||
PX4_INFO("HRT_CALL %d\n", hrt_called(&t1));
|
||||
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)0);
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)nullptr);
|
||||
sleep(2);
|
||||
PX4_INFO("HRT_CALL - %d\n", hrt_called(&t1));
|
||||
hrt_cancel(&t1);
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
|
||||
static int daemon_task; /* Handle of deamon task / thread */
|
||||
|
||||
extern "C" __EXPORT int hrttest_main(int argc, char *argv[]);
|
||||
int hrttest_main(int argc, char *argv[])
|
||||
extern "C" __EXPORT int hrt_test_main(int argc, char *argv[]);
|
||||
int hrt_test_main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
PX4_WARN("usage: hrttest_main {start|stop|status}\n");
|
||||
PX4_WARN("usage: hrt_test_main {start|stop|status}\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ int hrttest_main(int argc, char *argv[])
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
2000,
|
||||
PX4_MAIN,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -60,14 +60,14 @@ int MuorbTestExample::DefaultTest()
|
||||
int i = 0;
|
||||
orb_advert_t pub_id = orb_advertise(ORB_ID(esc_status), & m_esc_status);
|
||||
|
||||
if (pub_id == 0) {
|
||||
if (pub_id == nullptr) {
|
||||
PX4_ERR("error publishing esc_status");
|
||||
return -1;
|
||||
}
|
||||
|
||||
orb_advert_t pub_id_vc = orb_advertise(ORB_ID(vehicle_command), & m_vc);
|
||||
|
||||
if (pub_id_vc == 0) {
|
||||
if (pub_id_vc == nullptr) {
|
||||
PX4_ERR("error publishing vehicle_command");
|
||||
return -1;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ int MuorbTestExample::PingPongTest()
|
||||
int i = 0;
|
||||
orb_advert_t pub_id_vc = orb_advertise(ORB_ID(vehicle_command), & m_vc);
|
||||
|
||||
if (pub_id_vc == 0) {
|
||||
if (pub_id_vc == nullptr) {
|
||||
PX4_ERR("error publishing vehicle_command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
############################################################################
|
||||
px4_add_module(
|
||||
MODULE platforms__posix__tests__vcdev_test
|
||||
MAIN vcdevtest
|
||||
MAIN vcdev_test
|
||||
SRCS
|
||||
vcdevtest_main.cpp
|
||||
vcdevtest_start_posix.cpp
|
||||
|
||||
@@ -66,7 +66,7 @@ static int writer_main(int argc, char *argv[])
|
||||
return -px4_errno;
|
||||
}
|
||||
|
||||
int ret;
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
|
||||
while (!g_exit) {
|
||||
@@ -188,7 +188,7 @@ VCDevExample::~VCDevExample()
|
||||
{
|
||||
if (_node) {
|
||||
delete _node;
|
||||
_node = 0;
|
||||
_node = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ int VCDevExample::main()
|
||||
|
||||
_node = new VCDevNode();
|
||||
|
||||
if (_node == 0) {
|
||||
if (_node == nullptr) {
|
||||
PX4_INFO("Failed to allocate VCDevNode");
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ int VCDevExample::main()
|
||||
return -px4_errno;
|
||||
}
|
||||
|
||||
void *p = 0;
|
||||
void *p = nullptr;
|
||||
int ret = px4_ioctl(fd, DIOC_GETPRIV, (unsigned long)&p);
|
||||
|
||||
if (ret < 0) {
|
||||
@@ -318,7 +318,7 @@ int VCDevExample::main()
|
||||
SCHED_PRIORITY_MAX - 6,
|
||||
2000,
|
||||
writer_main,
|
||||
(char *const *)NULL);
|
||||
(char *const *)nullptr);
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ static int daemon_task; /* Handle of deamon task / thread */
|
||||
|
||||
//using namespace px4;
|
||||
|
||||
extern "C" __EXPORT int vcdevtest_main(int argc, char *argv[]);
|
||||
int vcdevtest_main(int argc, char *argv[])
|
||||
extern "C" __EXPORT int vcdev_test_main(int argc, char *argv[]);
|
||||
int vcdev_test_main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -69,7 +69,7 @@ int vcdevtest_main(int argc, char *argv[])
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
2000,
|
||||
PX4_MAIN,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ int wqueue_test_main(int argc, char *argv[])
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
2000,
|
||||
PX4_MAIN,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user