Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
nps_hitl_sensors.c File Reference
#include "nps_ins.h"
#include <sys/time.h>
#include "nps_fdm.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/poll.h>
#include "nps_sensors.h"
#include "nps_main.h"
#include "paparazzi.h"
#include "pprzlink/messages.h"
#include "pprzlink/dl_protocol.h"
#include "pprzlink/pprzlink_device.h"
#include "pprzlink/pprz_transport.h"
#include "arch/linux/serial_port.h"
+ Include dependency graph for nps_hitl_sensors.c:

Go to the source code of this file.

Data Structures

struct  linkdev
 

Macros

#define AP_DEV   "/dev/ttyUSB0"
 
#define AP_BAUD   B921600
 
#define NPS_HITL_DEBUG   0
 
#define DEBUG_PRINT(...)   {}
 
#define PPRZLINK_BUFFER_SIZE   256
 

Functions

void * nps_sensors_loop (void *data)
 
void * nps_ap_data_loop (void *data)
 
static int check_free_space (struct linkdev *d, long *fd, uint16_t len)
 
static void put_byte (struct linkdev *d, long fd, uint8_t data)
 
static void put_buffer (struct linkdev *d, long fd, const uint8_t *data, uint16_t len)
 
static void send_message (struct linkdev *d, long fd)
 
static uint8_t getch (struct linkdev *d)
 
static int char_available (struct linkdev *d)
 
void nps_hitl_impl_init (void)
 END pprzlink_dev. More...
 

Variables

pthread_t th_sensors
 
pthread_t th_ap_data
 
static struct linkdev dev
 

Data Structure Documentation

◆ linkdev

struct linkdev

Definition at line 68 of file nps_hitl_sensors.c.

+ Collaboration diagram for linkdev:
Data Fields
struct link_device device Generic device interface.
struct pollfd fds[1]
struct SerialPort * port Serial port.
struct pprz_transport pprz_tp transport
uint8_t rx_buf[PPRZLINK_BUFFER_SIZE] Receive buffer.
uint16_t rx_idx
uint8_t tx_buf[PPRZLINK_BUFFER_SIZE] Transmit buffer.
uint16_t tx_idx

Macro Definition Documentation

◆ AP_BAUD

#define AP_BAUD   B921600

Definition at line 50 of file nps_hitl_sensors.c.

◆ AP_DEV

#define AP_DEV   "/dev/ttyUSB0"

Definition at line 47 of file nps_hitl_sensors.c.

◆ DEBUG_PRINT

#define DEBUG_PRINT (   ...)    {}

Definition at line 58 of file nps_hitl_sensors.c.

◆ NPS_HITL_DEBUG

#define NPS_HITL_DEBUG   0

Definition at line 54 of file nps_hitl_sensors.c.

◆ PPRZLINK_BUFFER_SIZE

#define PPRZLINK_BUFFER_SIZE   256

Definition at line 67 of file nps_hitl_sensors.c.

Function Documentation

◆ char_available()

static int char_available ( struct linkdev d)
static

Definition at line 135 of file nps_hitl_sensors.c.

References DEBUG_PRINT, and linkdev::fds.

Referenced by generic_uart_event(), nps_hitl_impl_init(), and px4flash_event().

+ Here is the caller graph for this function:

◆ check_free_space()

static int check_free_space ( struct linkdev d,
long *  fd,
uint16_t  len 
)
static

Definition at line 87 of file nps_hitl_sensors.c.

References PPRZLINK_BUFFER_SIZE, and linkdev::tx_idx.

Referenced by nps_hitl_impl_init().

+ Here is the caller graph for this function:

◆ getch()

static uint8_t getch ( struct linkdev d)
static

Definition at line 116 of file nps_hitl_sensors.c.

References DEBUG_PRINT, SerialPort::fd, linkdev::port, PPRZLINK_BUFFER_SIZE, linkdev::rx_buf, and linkdev::rx_idx.

Referenced by nps_hitl_impl_init().

+ Here is the caller graph for this function:

◆ nps_ap_data_loop()

void * nps_ap_data_loop ( void *  data)

Definition at line 284 of file nps_hitl_sensors.c.

References cmd_buf, NpsAutopilot::commands, dev, linkdev::device, fdm_mutex, MAX_PPRZ, nps_autopilot, NPS_COMMANDS_NB, linkdev::pprz_tp, PPRZLINK_BUFFER_SIZE, linkdev::rx_idx, and TRUE.

Referenced by nps_hitl_impl_init().

+ Here is the caller graph for this function:

◆ nps_hitl_impl_init()

void nps_hitl_impl_init ( void  )

END pprzlink_dev.

Definition at line 154 of file nps_hitl_sensors.c.

References AP_BAUD, AP_DEV, char_available(), check_free_space(), dev, linkdev::device, SerialPort::fd, linkdev::fds, getch(), nps_ap_data_loop(), nps_sensors_loop(), linkdev::port, linkdev::pprz_tp, put_buffer(), put_byte(), send_message(), serial_port_free(), serial_port_new(), serial_port_open_raw(), th_ap_data, and th_sensors.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nps_sensors_loop()

void * nps_sensors_loop ( void *  data)

◆ put_buffer()

static void put_buffer ( struct linkdev d,
long  fd,
const uint8_t data,
uint16_t  len 
)
static

Definition at line 98 of file nps_hitl_sensors.c.

References linkdev::tx_buf, and linkdev::tx_idx.

Referenced by nps_hitl_impl_init().

+ Here is the caller graph for this function:

◆ put_byte()

static void put_byte ( struct linkdev d,
long  fd,
uint8_t  data 
)
static

Definition at line 93 of file nps_hitl_sensors.c.

References linkdev::tx_buf, and linkdev::tx_idx.

Referenced by nps_hitl_impl_init().

+ Here is the caller graph for this function:

◆ send_message()

static void send_message ( struct linkdev d,
long  fd 
)
static

Definition at line 104 of file nps_hitl_sensors.c.

References DEBUG_PRINT, SerialPort::fd, linkdev::port, linkdev::tx_buf, and linkdev::tx_idx.

Referenced by nps_hitl_impl_init().

+ Here is the caller graph for this function:

Variable Documentation

◆ dev

struct linkdev dev
static

Definition at line 64 of file nps_hitl_sensors.c.

Referenced by nps_ap_data_loop(), nps_hitl_impl_init(), and nps_sensors_loop().

◆ th_ap_data

pthread_t th_ap_data

Definition at line 64 of file nps_hitl_sensors.c.

Referenced by nps_hitl_impl_init().

◆ th_sensors

pthread_t th_sensors

Definition at line 63 of file nps_hitl_sensors.c.

Referenced by nps_hitl_impl_init().