SITL: add and use AP_SIM_GPS_FILE_ENABLED

This commit is contained in:
Peter Barker 2021-11-01 15:56:39 +11:00 committed by Peter Barker
parent e6779e91e6
commit bff0b6f970
2 changed files with 13 additions and 0 deletions

View File

@ -996,6 +996,7 @@ uint32_t GPS::CalculateBlockCRC32(uint32_t length, uint8_t *buffer, uint32_t crc
/* /*
temporary method to use file as GPS data temporary method to use file as GPS data
*/ */
#if AP_SIM_GPS_FILE_ENABLED
void GPS::update_file() void GPS::update_file()
{ {
static int fd = -1; static int fd = -1;
@ -1027,6 +1028,7 @@ void GPS::update_file()
lseek(temp_fd, 0, SEEK_SET); lseek(temp_fd, 0, SEEK_SET);
} }
} }
#endif // AP_SIM_GPS_FILE_ENABLED
/* /*
possibly send a new GPS packet possibly send a new GPS packet
@ -1175,9 +1177,11 @@ void GPS::update()
update_nova(&d); update_nova(&d);
break; break;
#if AP_SIM_GPS_FILE_ENABLED
case Type::FILE: case Type::FILE:
update_file(); update_file();
break; break;
#endif
} }
} }

View File

@ -35,6 +35,11 @@ param set SERIAL5_PROTOCOL 5
#define HAL_SIM_GPS_EXTERNAL_FIFO_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) #define HAL_SIM_GPS_EXTERNAL_FIFO_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL)
#endif #endif
#ifndef AP_SIM_GPS_FILE_ENABLED
// really need to use AP_FileSystem for this.
#define AP_SIM_GPS_FILE_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX)
#endif
#include "SIM_SerialDevice.h" #include "SIM_SerialDevice.h"
namespace SITL { namespace SITL {
@ -49,7 +54,9 @@ public:
UBLOX = 1, UBLOX = 1,
NMEA = 5, NMEA = 5,
SBP = 6, SBP = 6,
#if AP_SIM_GPS_FILE_ENABLED
FILE = 7, FILE = 7,
#endif
NOVA = 8, NOVA = 8,
SBP2 = 9, SBP2 = 9,
}; };
@ -107,7 +114,9 @@ private:
void update_sbp(const struct gps_data *d); void update_sbp(const struct gps_data *d);
void update_sbp2(const struct gps_data *d); void update_sbp2(const struct gps_data *d);
#if AP_SIM_GPS_FILE_ENABLED
void update_file(); void update_file();
#endif
void update_nova(const struct gps_data *d); void update_nova(const struct gps_data *d);
void nova_send_message(uint8_t *header, uint8_t headerlength, uint8_t *payload, uint8_t payloadlen); void nova_send_message(uint8_t *header, uint8_t headerlength, uint8_t *payload, uint8_t payloadlen);