2020-09-12 16:04:38 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL && defined(HAL_BUILD_AP_PERIPH)
|
|
|
|
|
2023-08-17 17:18:36 -03:00
|
|
|
#include "SITL_State_common.h"
|
|
|
|
|
2020-09-12 16:04:38 -03:00
|
|
|
#include "AP_HAL_SITL.h"
|
|
|
|
#include "AP_HAL_SITL_Namespace.h"
|
|
|
|
#include "HAL_SITL_Class.h"
|
|
|
|
#include "RCInput.h"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/udp.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2021-10-26 09:31:22 -03:00
|
|
|
#include <SITL/SITL.h>
|
2020-09-12 16:04:38 -03:00
|
|
|
#include <AP_Baro/AP_Baro.h>
|
|
|
|
#include <AP_InertialSensor/AP_InertialSensor.h>
|
|
|
|
#include <AP_Compass/AP_Compass.h>
|
|
|
|
#include <AP_Terrain/AP_Terrain.h>
|
|
|
|
#include <AP_HAL/utility/Socket.h>
|
|
|
|
|
2023-08-17 17:18:36 -03:00
|
|
|
class SimMCast : public SITL::Aircraft {
|
|
|
|
public:
|
|
|
|
SimMCast(const char *frame_str);
|
|
|
|
void update(const struct sitl_input &input) override;
|
|
|
|
|
|
|
|
private:
|
2023-11-23 01:56:12 -04:00
|
|
|
SocketAPM sock{true};
|
|
|
|
SocketAPM servo_sock{true};
|
2023-08-17 17:18:36 -03:00
|
|
|
|
|
|
|
// offset between multicast timestamp and local timestamp
|
|
|
|
uint64_t base_time_us;
|
|
|
|
|
|
|
|
void multicast_open();
|
|
|
|
void multicast_read();
|
2023-08-19 03:09:50 -03:00
|
|
|
|
|
|
|
void servo_send(void);
|
|
|
|
void servo_fd_open(void);
|
2023-08-17 17:18:36 -03:00
|
|
|
};
|
|
|
|
|
2020-09-12 16:04:38 -03:00
|
|
|
class HAL_SITL;
|
|
|
|
|
2023-08-17 17:18:36 -03:00
|
|
|
class HALSITL::SITL_State : public SITL_State_Common {
|
2020-09-12 16:04:38 -03:00
|
|
|
friend class HALSITL::Scheduler;
|
|
|
|
friend class HALSITL::Util;
|
|
|
|
friend class HALSITL::GPIO;
|
|
|
|
public:
|
2023-09-27 20:34:22 -03:00
|
|
|
void init(int argc, char * const argv[]) override;
|
2020-09-12 16:04:38 -03:00
|
|
|
|
|
|
|
bool use_rtscts(void) const {
|
|
|
|
return _use_rtscts;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t base_port(void) const {
|
|
|
|
return _base_port;
|
|
|
|
}
|
|
|
|
|
|
|
|
// paths for UART devices
|
2021-04-26 17:47:21 -03:00
|
|
|
const char *_uart_path[9] {
|
2020-12-28 10:33:56 -04:00
|
|
|
"none:0",
|
2023-08-17 17:18:36 -03:00
|
|
|
"GPS1",
|
2020-12-28 10:33:56 -04:00
|
|
|
"none:1",
|
2023-09-29 01:11:22 -03:00
|
|
|
"sim:adsb",
|
2023-11-21 02:22:00 -04:00
|
|
|
"udpclient:127.0.0.1:15550", // for CAN UART test
|
2020-12-28 10:33:56 -04:00
|
|
|
"none:5",
|
2021-04-26 17:47:21 -03:00
|
|
|
"none:6",
|
|
|
|
"none:7",
|
2023-11-21 02:22:00 -04:00
|
|
|
"none:8",
|
2020-09-12 16:04:38 -03:00
|
|
|
};
|
2020-12-28 10:33:56 -04:00
|
|
|
|
|
|
|
uint8_t get_instance() const { return _instance; }
|
|
|
|
|
2022-04-29 08:48:37 -03:00
|
|
|
bool run_in_maintenance_mode() const { return _maintenance; }
|
|
|
|
|
2020-09-12 16:04:38 -03:00
|
|
|
private:
|
|
|
|
|
|
|
|
void wait_clock(uint64_t wait_time_usec);
|
|
|
|
bool _use_rtscts;
|
|
|
|
uint16_t _base_port;
|
|
|
|
|
|
|
|
const char *defaults_path = HAL_PARAM_DEFAULTS_PATH;
|
2020-12-28 10:33:56 -04:00
|
|
|
|
|
|
|
uint8_t _instance;
|
2022-04-29 08:48:37 -03:00
|
|
|
bool _maintenance;
|
2023-08-17 17:18:36 -03:00
|
|
|
|
|
|
|
// simulated GPS devices
|
|
|
|
SITL::GPS *gps[1]; // constrained by # of parameter sets
|
2020-09-12 16:04:38 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|