Abstractions to compile systemlib for Linux and Nuttx

Modified uint32_t casts of pointers to unsigned long for portability.
It otherwise breaks on x86_64.

Added _PX4_IOC to handle the conflice between _IOC on Linux and NuttX.

Removed use of px4::ok() because it cannot be used in a thread based
implementation. Changed to use px4::AppMgr which uses ok() on ROS.

Removed up_cxxinitialize.c from Linux build.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-04-20 11:00:16 -07:00
parent 89e1b454af
commit 5084a61f0e
25 changed files with 174 additions and 116 deletions
+83
View File
@@ -0,0 +1,83 @@
/****************************************************************************
* include/crc.h
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_CRC32_H
#define __INCLUDE_CRC32_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: crc32part
*
* Description:
* Continue CRC calculation on a part of the buffer.
*
****************************************************************************/
EXTERN uint32_t crc32part(const uint8_t *src, size_t len,
uint32_t crc32val);
/****************************************************************************
* Name: crc32
*
* Description:
* Return a 32-bit CRC of the contents of the 'src' buffer, length 'len'
*
****************************************************************************/
EXTERN uint32_t crc32(const uint8_t *src, size_t len);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_CRC32_H */
-2
View File
@@ -66,8 +66,6 @@ private:
// Task/process based build
#if defined(__PX4_ROS) || defined(__PX4_NUTTX)
#define PX4_MAIN main
// Thread based build
#else
+2
View File
@@ -42,4 +42,6 @@
#if defined(__PX4_NUTTX)
#include <px4_config.h>
#elif defined (__PX4_LINUX)
#define CONFIG_NFILE_STREAMS 1
#endif
+10
View File
@@ -98,12 +98,22 @@ typedef param_t px4_param_t;
(c) == '\r' || (c) == '\f' || c== '\v')
#endif
#define _PX4_IOC(x,y) _IOC(x,y)
/* Linux Specific defines */
#elif defined(__PX4_LINUX)
// Flag is meaningless on Linux
#define O_BINARY 0
// NuttX _IOC is equivalent to Linux _IO
#define _PX4_IOC(x,y) _IO(x,y)
/* FIXME - Used to satisfy build */
#define UNIQUE_ID 0x1FFF7A10 //STM DocID018909 Rev 8 Sect 39.1 (Unique device ID Register)
#define getreg32(a) (*(volatile uint32_t *)(a))
#endif
+7 -3
View File
@@ -42,6 +42,7 @@
#include "px4_subscriber.h"
#include "px4_publisher.h"
#include "px4_middleware.h"
#include "px4_app.h"
#if defined(__PX4_ROS)
/* includes when building for ros */
@@ -141,10 +142,11 @@ protected:
class __EXPORT NodeHandle
{
public:
NodeHandle() :
NodeHandle(AppMgr &a) :
_subs(),
_pubs(),
_sub_min_interval(nullptr)
_sub_min_interval(nullptr),
_mgr(a)
{}
~NodeHandle()
@@ -262,7 +264,7 @@ public:
*/
void spin()
{
while (ok()) {
while (!_mgr.exitRequested()) {
const int timeout_ms = 100;
/* Only continue in the loop if the nodehandle has subscriptions */
@@ -287,6 +289,8 @@ protected:
SubscriberNode *_sub_min_interval; /**< Points to the sub wtih the smallest interval
of all Subscriptions in _subs*/
AppMgr &_mgr;
/**
* Check if this is the smallest interval so far and update _sub_min_interval
*/