POSIX: Changed px4_debug.h to px4_log.h

Also changed use of printf to PX4_WARN or PX4_INFO in posix and
qurt tests.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-05-11 16:04:39 -07:00
parent 0ba5305e94
commit a99f916bdf
14 changed files with 93 additions and 72 deletions
@@ -37,7 +37,7 @@
* Implementation of existing task API for Linux
*/
#include <px4_debug.h>
#include <px4_log.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -57,14 +57,14 @@ int hello_main(int argc, char *argv[])
{
if (argc < 2) {
printf("usage: hello {start|stop|status}\n");
PX4_WARN("usage: hello {start|stop|status}\n");
return 1;
}
if (!strcmp(argv[1], "start")) {
if (HelloExample::appState.isRunning()) {
printf("already running\n");
PX4_INFO("already running\n");
/* this is not an error */
return 0;
}
@@ -86,15 +86,15 @@ int hello_main(int argc, char *argv[])
if (!strcmp(argv[1], "status")) {
if (HelloExample::appState.isRunning()) {
printf("is running\n");
PX4_INFO("is running\n");
} else {
printf("not started\n");
PX4_INFO("not started\n");
}
return 0;
}
printf("usage: hello_main {start|stop|status}\n");
PX4_WARN("usage: hello_main {start|stop|status}\n");
return 1;
}
@@ -59,7 +59,7 @@ static int writer_main(int argc, char *argv[])
int fd = px4_open(TESTDEV, PX4_F_RDONLY);
if (fd < 0) {
printf("--- Open failed %d %d", fd, px4_errno);
PX4_INFO("--- Open failed %d %d", fd, px4_errno);
return -px4_errno;
}
@@ -67,14 +67,14 @@ static int writer_main(int argc, char *argv[])
int i=0;
while (i<3) {
// Wait for 3 seconds
printf("--- Sleeping for 4 sec\n");
PX4_INFO("--- Sleeping for 4 sec\n");
ret = sleep(4);
if (ret < 0) {
printf("--- sleep failed %d %d\n", ret, errno);
PX4_INFO("--- sleep failed %d %d\n", ret, errno);
return ret;
}
printf("--- writing to fd\n");
PX4_INFO("--- writing to fd\n");
ret = px4_write(fd, buf, 1);
++i;
}
@@ -110,16 +110,16 @@ static int test_pub_block(int fd, unsigned long blocked)
{
int ret = px4_ioctl(fd, DEVIOCSPUBBLOCK, blocked);
if (ret < 0) {
printf("ioctl PX4_DEVIOCSPUBBLOCK failed %d %d", ret, px4_errno);
PX4_INFO("ioctl PX4_DEVIOCSPUBBLOCK failed %d %d", ret, px4_errno);
return -px4_errno;
}
ret = px4_ioctl(fd, DEVIOCGPUBBLOCK, 0);
if (ret < 0) {
printf("ioctl PX4_DEVIOCGPUBBLOCK failed %d %d", ret, px4_errno);
PX4_INFO("ioctl PX4_DEVIOCGPUBBLOCK failed %d %d", ret, px4_errno);
return -px4_errno;
}
printf("pub_blocked = %d %s\n", ret, (unsigned long)ret == blocked ? "PASS" : "FAIL");
PX4_INFO("pub_blocked = %d %s\n", ret, (unsigned long)ret == blocked ? "PASS" : "FAIL");
return 0;
}
@@ -131,29 +131,29 @@ int VCDevExample::main()
_node = new VCDevNode();
if (_node == 0) {
printf("Failed to allocate VCDevNode\n");
PX4_INFO("Failed to allocate VCDevNode\n");
return -ENOMEM;
}
if (_node->init() != PX4_OK) {
printf("Failed to init VCDevNode\n");
PX4_INFO("Failed to init VCDevNode\n");
return 1;
}
int fd = px4_open(TESTDEV, PX4_F_RDONLY);
if (fd < 0) {
printf("Open failed %d %d", fd, px4_errno);
PX4_INFO("Open failed %d %d", fd, px4_errno);
return -px4_errno;
}
void *p = 0;
int ret = px4_ioctl(fd, DIOC_GETPRIV, (unsigned long)&p);
if (ret < 0) {
printf("ioctl DIOC_GETPRIV failed %d %d", ret, px4_errno);
PX4_INFO("ioctl DIOC_GETPRIV failed %d %d", ret, px4_errno);
return -px4_errno;
}
printf("priv data = %p %s\n", p, p == (void *)_node ? "PASS" : "FAIL");
PX4_INFO("priv data = %p %s\n", p, p == (void *)_node ? "PASS" : "FAIL");
ret = test_pub_block(fd, 1);
if (ret < 0)
@@ -174,32 +174,32 @@ int VCDevExample::main()
(char* const*)NULL);
while (!appState.exitRequested() && i<13) {
printf("=====================\n");
printf("==== sleeping 2 sec ====\n");
PX4_INFO("=====================\n");
PX4_INFO("==== sleeping 2 sec ====\n");
sleep(2);
fds[0].fd = fd;
fds[0].events = POLLIN;
fds[0].revents = 0;
printf("==== Calling Poll\n");
PX4_INFO("==== Calling Poll\n");
ret = px4_poll(fds, 1, 1000);
printf("==== Done poll\n");
PX4_INFO("==== Done poll\n");
if (ret < 0) {
printf("==== poll failed %d %d\n", ret, px4_errno);
PX4_INFO("==== poll failed %d %d\n", ret, px4_errno);
px4_close(fd);
}
else if (i > 0) {
if (ret == 0)
printf("==== Nothing to read - PASS\n");
PX4_INFO("==== Nothing to read - PASS\n");
else
printf("==== poll returned %d\n", ret);
PX4_INFO("==== poll returned %d\n", ret);
}
else if (i == 0) {
if (ret == 1)
printf("==== %d to read - %s\n", ret, fds[0].revents & POLLIN ? "PASS" : "FAIL");
PX4_INFO("==== %d to read - %s\n", ret, fds[0].revents & POLLIN ? "PASS" : "FAIL");
else
printf("==== %d to read - FAIL\n", ret);
PX4_INFO("==== %d to read - FAIL\n", ret);
}
++i;
@@ -37,6 +37,7 @@
*
* @author Mark Charlebois <charlebm@gmail.com>
*/
#include <px4_log.h>
#include <px4_middleware.h>
#include <px4_app.h>
#include "wqueue_test.h"
@@ -46,10 +47,10 @@ int PX4_MAIN(int argc, char **argv)
{
px4::init(argc, argv, "wqueue_test");
printf("wqueue hello\n");
PX4_INFO("wqueue hello\n");
WQueueTest wq;
wq.main();
printf("goodbye\n");
PX4_INFO("goodbye\n");
return 0;
}
@@ -39,6 +39,7 @@
*/
#include "wqueue_test.h"
#include <px4_app.h>
#include <px4_log.h>
#include <px4_tasks.h>
#include <stdio.h>
#include <string.h>
@@ -53,14 +54,14 @@ int wqueue_test_main(int argc, char *argv[])
{
if (argc < 2) {
printf("usage: wqueue_test {start|stop|status}\n");
PX4_INFO("usage: wqueue_test {start|stop|status}\n");
return 1;
}
if (!strcmp(argv[1], "start")) {
if (WQueueTest::appState.isRunning()) {
printf("already running\n");
PX4_INFO("already running\n");
/* this is not an error */
return 0;
}
@@ -82,15 +83,15 @@ int wqueue_test_main(int argc, char *argv[])
if (!strcmp(argv[1], "status")) {
if (WQueueTest::appState.isRunning()) {
printf("is running\n");
PX4_INFO("is running\n");
} else {
printf("not started\n");
PX4_INFO("not started\n");
}
return 0;
}
printf("usage: wqueue_test {start|stop|status}\n");
PX4_INFO("usage: wqueue_test {start|stop|status}\n");
return 1;
}