AP_GPS: fix build and working with single GPS Receiver config

This commit is contained in:
bugobliterator 2021-09-30 10:46:55 +05:30 committed by Peter Barker
parent a7686de92b
commit ae65f2e6ab
2 changed files with 17 additions and 5 deletions

View File

@ -347,7 +347,7 @@ const AP_Param::GroupInfo AP_GPS::var_info[] = {
AP_GROUPINFO("_PRIMARY", 27, AP_GPS, _primary, 0),
#endif
#if GPS_MAX_RECEIVERS > 1 && HAL_ENABLE_LIBUAVCAN_DRIVERS
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
// @Param: _CAN_NODEID1
// @DisplayName: GPS Node ID 1
// @Description: GPS Node id for discovered first.
@ -355,25 +355,28 @@ const AP_Param::GroupInfo AP_GPS::var_info[] = {
// @User: Advanced
AP_GROUPINFO("_CAN_NODEID1", 28, AP_GPS, _node_id[0], 0),
#if GPS_MAX_RECEIVERS > 1
// @Param: _CAN_NODEID2
// @DisplayName: GPS Node ID 2
// @Description: GPS Node id for discovered second.
// @ReadOnly: True
// @User: Advanced
AP_GROUPINFO("_CAN_NODEID2", 29, AP_GPS, _node_id[1], 0),
#endif // GPS_MAX_RECEIVERS > 1
// @Param: 1_CAN_OVRIDE
// @DisplayName: First UAVCAN GPS NODE ID
// @Description: GPS Node id for first GPS. If 0 the gps will be automatically selected on first come basis.
// @User: Advanced
AP_GROUPINFO("1_CAN_OVRIDE", 30, AP_GPS, _override_node_id[0], 0),
#if GPS_MAX_RECEIVERS > 1
// @Param: 2_CAN_OVRIDE
// @DisplayName: Second UAVCAN GPS NODE ID
// @Description: GPS Node id for second GPS. If 0 the gps will be automatically selected on first come basis.
// @User: Advanced
AP_GROUPINFO("2_CAN_OVRIDE", 31, AP_GPS, _override_node_id[1], 0),
#endif
#endif // GPS_MAX_RECEIVERS > 1
#endif // HAL_ENABLE_LIBUAVCAN_DRIVERS
AP_GROUPEND
};

View File

@ -31,9 +31,18 @@
#ifndef GPS_MAX_RECEIVERS
#define GPS_MAX_RECEIVERS 2 // maximum number of physical GPS sensors allowed - does not include virtual GPS created by blending receiver data
#endif
#ifndef GPS_MAX_INSTANCES
#if !defined(GPS_MAX_INSTANCES)
#if GPS_MAX_RECEIVERS > 1
#define GPS_MAX_INSTANCES (GPS_MAX_RECEIVERS + 1) // maximum number of GPS instances including the 'virtual' GPS created by blending receiver data
#else
#define GPS_MAX_INSTANCES 1
#endif // GPS_MAX_RECEIVERS > 1
#endif // GPS_MAX_INSTANCES
#if GPS_MAX_RECEIVERS <= 1 && GPS_MAX_INSTANCES > 1
#error "GPS_MAX_INSTANCES should be 1 for GPS_MAX_RECEIVERS <= 1"
#endif
#if GPS_MAX_INSTANCES > GPS_MAX_RECEIVERS
#define GPS_BLENDED_INSTANCE GPS_MAX_RECEIVERS // the virtual blended GPS is always the highest instance (2)
#endif
@ -559,7 +568,7 @@ protected:
AP_Float _blend_tc;
AP_Int16 _driver_options;
AP_Int8 _primary;
#if GPS_MAX_RECEIVERS > 1 && HAL_ENABLE_LIBUAVCAN_DRIVERS
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
AP_Int32 _node_id[GPS_MAX_RECEIVERS];
AP_Int32 _override_node_id[GPS_MAX_RECEIVERS];
#endif