Skip to content

Commit

Permalink
AP_GPS: fix build and working with single GPS Receiver config
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator authored and peterbarker committed Sep 30, 2021
1 parent a7686de commit ae65f2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
9 changes: 6 additions & 3 deletions libraries/AP_GPS/AP_GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,33 +347,36 @@ 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.
// @ReadOnly: True
// @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
};
Expand Down
13 changes: 11 additions & 2 deletions libraries/AP_GPS/AP_GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -559,7 +568,7 @@ class AP_GPS
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
Expand Down

0 comments on commit ae65f2e

Please sign in to comment.