Skip to content

Commit

Permalink
AP_GPS: allow external libraries to detect CAN instance
Browse files Browse the repository at this point in the history
  • Loading branch information
magicrub authored and tridge committed Mar 1, 2023
1 parent 7e214b2 commit fe37282
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libraries/AP_GPS/AP_GPS_UAVCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,4 +889,16 @@ void AP_GPS_UAVCAN::handle_param_save_response(AP_UAVCAN* ap_uavcan, const uint8
ap_uavcan->send_reboot_request(node_id);
}

#if AP_DRONECAN_SEND_GPS
bool AP_GPS_UAVCAN::instance_exists(const AP_UAVCAN* ap_uavcan)
{
for (uint8_t i=0; i<ARRAY_SIZE(_detected_modules); i++) {
if (ap_uavcan == _detected_modules[i].ap_uavcan) {
return true;
}
}
return false;
}
#endif // AP_DRONECAN_SEND_GPS

#endif // HAL_ENABLE_LIBUAVCAN_DRIVERS
4 changes: 4 additions & 0 deletions libraries/AP_GPS/AP_GPS_UAVCAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class AP_GPS_UAVCAN : public AP_GPS_Backend {
void clear_RTCMV3() override;
#endif

#if AP_DRONECAN_SEND_GPS
static bool instance_exists(const AP_UAVCAN* ap_uavcan);
#endif

private:

bool param_configured = true;
Expand Down

0 comments on commit fe37282

Please sign in to comment.