mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-24 01:28:29 -04:00
AP_CANSensor: create a separate register driver method
This commit is contained in:
parent
f472da8e90
commit
6e61867e7f
@ -30,20 +30,26 @@ extern const AP_HAL::HAL& hal;
|
|||||||
#define debug_can(level_debug, fmt, args...)
|
#define debug_can(level_debug, fmt, args...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CANSensor::CANSensor(const char *driver_name, AP_CANManager::Driver_Type dtype, uint16_t stack_size) :
|
CANSensor::CANSensor(const char *driver_name, uint16_t stack_size) :
|
||||||
_driver_name(driver_name),
|
_driver_name(driver_name),
|
||||||
_stack_size(stack_size)
|
_stack_size(stack_size)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
void CANSensor::register_driver(AP_CANManager::Driver_Type dtype)
|
||||||
{
|
{
|
||||||
#if HAL_CANMANAGER_ENABLED
|
#if HAL_CANMANAGER_ENABLED
|
||||||
if (!AP::can().register_driver(dtype, this)) {
|
if (!AP::can().register_driver(dtype, this)) {
|
||||||
debug_can(AP_CANManager::LOG_ERROR, "Failed to register CANSensor %s", driver_name);
|
debug_can(AP_CANManager::LOG_ERROR, "Failed to register CANSensor %s", _driver_name);
|
||||||
} else {
|
} else {
|
||||||
debug_can(AP_CANManager::LOG_INFO, "%s: constructed", driver_name);
|
debug_can(AP_CANManager::LOG_INFO, "%s: constructed", _driver_name);
|
||||||
}
|
}
|
||||||
#elif defined(HAL_BUILD_AP_PERIPH)
|
#elif defined(HAL_BUILD_AP_PERIPH)
|
||||||
register_driver_periph(dtype);
|
register_driver_periph(dtype);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAL_BUILD_AP_PERIPH
|
#ifdef HAL_BUILD_AP_PERIPH
|
||||||
CANSensor::CANSensor_Periph CANSensor::_periph[HAL_NUM_CAN_IFACES];
|
CANSensor::CANSensor_Periph CANSensor::_periph[HAL_NUM_CAN_IFACES];
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
class CANSensor : public AP_CANDriver {
|
class CANSensor : public AP_CANDriver {
|
||||||
public:
|
public:
|
||||||
CANSensor(const char *driver_name, AP_CANManager::Driver_Type dtype, uint16_t stack_size=2048);
|
CANSensor(const char *driver_name, uint16_t stack_size=2048);
|
||||||
|
|
||||||
/* Do not allow copies */
|
/* Do not allow copies */
|
||||||
CANSensor(const CANSensor &other) = delete;
|
CANSensor(const CANSensor &other) = delete;
|
||||||
CANSensor &operator=(const CANSensor&) = delete;
|
CANSensor &operator=(const CANSensor&) = delete;
|
||||||
@ -48,6 +48,9 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void register_driver(AP_CANManager::Driver_Type dtype);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user