PX4 Firmware
PX4 Autopilot Software http://px4.io
microRTPS_client.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
4  * Copyright (c) 2019 PX4 Development Team. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * 3. Neither the name of the copyright holder nor the names of its contributors
17  * may be used to endorse or promote products derived from this software without
18  * specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 #pragma once
35 
36 #include "microRTPS_transport.h"
37 
38 #include <inttypes.h>
39 #include <cstdio>
40 #include <ctime>
41 #include <pthread.h>
42 #include <termios.h>
43 
44 #include <ucdr/microcdr.h>
45 #include <px4_platform_common/px4_config.h>
46 #include <px4_platform_common/getopt.h>
47 #include <px4_platform_common/posix.h>
48 #include <px4_platform_common/tasks.h>
49 #include <px4_platform_common/time.h>
50 #include <uORB/uORB.h>
51 
52 #define BUFFER_SIZE 1024
53 #define LOOPS -1
54 #define SLEEP_MS 1
55 #define BAUDRATE 460800
56 #define DEVICE "/dev/ttyACM0"
57 #define POLL_MS 1
58 #define IP "127.0.0.1"
59 #define DEFAULT_RECV_PORT 2019
60 #define DEFAULT_SEND_PORT 2020
61 
62 void *send(void *data);
63 void micrortps_start_topics(struct timespec &begin, uint64_t &total_read, uint64_t &received, int &loop);
64 
65 struct baudtype {
66  speed_t code;
67  uint32_t val;
68 };
69 
70 struct options {
71  enum class eTransports {
72  UART,
73  UDP
74  };
76  char device[64] = DEVICE;
77  char ip[16] = IP;
78  uint16_t recv_port = DEFAULT_RECV_PORT;
79  uint16_t send_port = DEFAULT_SEND_PORT;
80  uint32_t sleep_ms = SLEEP_MS;
81  uint32_t baudrate = BAUDRATE;
82  uint32_t poll_ms = POLL_MS;
83  int loops = LOOPS;
84 };
85 
86 extern struct options _options;
87 extern bool _should_exit_task;
88 extern Transport_node *transport_node;
API for the uORB lightweight object broker.
struct options _options
#define BAUDRATE
void * send(void *data)
#define DEFAULT_SEND_PORT
void micrortps_start_topics(struct timespec &begin, uint64_t &total_read, uint64_t &received, int &loop)
Namespace encapsulating all device framework classes, functions and data.
Definition: CDev.cpp:47
#define POLL_MS
#define SLEEP_MS
#define LOOPS
#define DEFAULT_RECV_PORT
uint8_t * data
Definition: dataman.cpp:149
#define DEVICE
uint32_t val
#define IP
Transport_node * transport_node
speed_t code
bool _should_exit_task