uavcan module cleanup

- move most orb to uORB::Publication and uORB::Subscription
 - update legacy message handling (warn to PX4_INFO, PX4_WARN, PX4_ERR)
 - add perf counters
 - sensors/mag support newer `uavcan::equipment::ahrs::MagneticFieldStrength2` message
 - sensors/gps support `uavcan::equipment::gnss::Auxiliary` for hdop and vdop
 - sensors delete obsolete ioctl and read methods
 - use PublicationMulti for actuator_outputs and esc_reports (to coexist with other output modules)
 - add GNSS parameter metadata (parameters_injected.xml)
This commit is contained in:
Daniel Agar
2019-10-28 19:57:50 -04:00
committed by GitHub
parent 47dd312b57
commit 375fc4a75c
22 changed files with 705 additions and 677 deletions
+48 -44
View File
@@ -140,12 +140,23 @@ public:
DeviceBusType_SIMULATION = 4,
};
/**
* Return the bus ID the device is connected to.
*
* @return The bus ID
/*
broken out device elements. The bitfields are used to keep
the overall value small enough to fit in a float accurately,
which makes it possible to transport over the MAVLink
parameter protocol without loss of information.
*/
uint8_t get_device_bus() const { return _device_id.devid_s.bus; }
struct DeviceStructure {
DeviceBusType bus_type : 3;
uint8_t bus: 5; // which instance of the bus type
uint8_t address; // address on the bus (eg. I2C address)
uint8_t devtype; // device class specific device type
};
union DeviceId {
struct DeviceStructure devid_s;
uint32_t devid;
};
uint32_t get_device_id() const { return _device_id.devid; }
@@ -154,7 +165,8 @@ public:
*
* @return The bus type
*/
DeviceBusType get_device_bus_type() const { return _device_id.devid_s.bus_type; }
DeviceBusType get_device_bus_type() const { return _device_id.devid_s.bus_type; }
void set_device_bus_type(DeviceBusType bus_type) { _device_id.devid_s.bus_type = bus_type; }
static const char *get_device_bus_string(DeviceBusType bus)
{
@@ -177,41 +189,29 @@ public:
}
}
/**
* Return the bus ID the device is connected to.
*
* @return The bus ID
*/
uint8_t get_device_bus() const { return _device_id.devid_s.bus; }
void set_device_bus(uint8_t bus) { _device_id.devid_s.bus = bus; }
/**
* Return the bus address of the device.
*
* @return The bus address
*/
uint8_t get_device_address() const { return _device_id.devid_s.address; }
void set_device_address(int address) { _device_id.devid_s.address = address; }
uint8_t get_device_address() const { return _device_id.devid_s.address; }
void set_device_address(int address) { _device_id.devid_s.address = address; }
/**
* Set the device type
* Return the device type
*
* @return The device type
*/
void set_device_type(uint8_t devtype) { _device_id.devid_s.devtype = devtype; }
virtual bool external() { return false; }
/*
broken out device elements. The bitfields are used to keep
the overall value small enough to fit in a float accurately,
which makes it possible to transport over the MAVLink
parameter protocol without loss of information.
*/
struct DeviceStructure {
enum DeviceBusType bus_type : 3;
uint8_t bus: 5; // which instance of the bus type
uint8_t address; // address on the bus (eg. I2C address)
uint8_t devtype; // device class specific device type
};
union DeviceId {
struct DeviceStructure devid_s;
uint32_t devid;
};
uint8_t get_device_type() const { return _device_id.devid_s.devtype; }
void set_device_type(uint8_t devtype) { _device_id.devid_s.devtype = devtype; }
/**
* Print decoded device id string to a buffer.
@@ -234,30 +234,34 @@ public:
return num_written;
}
virtual bool external() const { return false; }
protected:
union DeviceId _device_id {}; /**< device identifier information */
union DeviceId _device_id {}; /**< device identifier information */
const char *_name{nullptr}; /**< driver name */
bool _debug_enabled{false}; /**< if true, debug messages are printed */
explicit Device(const char *name) : _name(name)
{
/* setup a default device ID. When bus_type is UNKNOWN the
other fields are invalid */
_device_id.devid = 0;
_device_id.devid_s.bus_type = DeviceBusType_UNKNOWN;
_device_id.devid_s.bus = 0;
_device_id.devid_s.address = 0;
_device_id.devid_s.devtype = 0;
set_device_bus_type(DeviceBusType_UNKNOWN);
}
Device(const char *name, DeviceBusType bus_type, uint8_t bus, uint8_t address, uint8_t devtype = 0)
: _name(name)
{
set_device_bus_type(bus_type);
set_device_bus(bus);
set_device_address(address);
set_device_type(devtype);
}
Device(DeviceBusType bus_type, uint8_t bus, uint8_t address, uint8_t devtype = 0)
{
_device_id.devid = 0;
_device_id.devid_s.bus_type = bus_type;
_device_id.devid_s.bus = bus;
_device_id.devid_s.address = address;
_device_id.devid_s.devtype = devtype;
set_device_bus_type(bus_type);
set_device_bus(bus);
set_device_address(address);
set_device_type(devtype);
}
};
+2 -2
View File
@@ -65,7 +65,7 @@ public:
I2C(I2C &&) = delete;
I2C &operator=(I2C &&) = delete;
virtual int init();
virtual int init() override;
static int set_bus_clock(unsigned bus, unsigned clock_hz);
@@ -109,7 +109,7 @@ protected:
*/
int transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const unsigned recv_len);
bool external() { return px4_i2c_bus_external(_device_id.devid_s.bus); }
virtual bool external() const override { return px4_i2c_bus_external(_device_id.devid_s.bus); }
private:
uint32_t _frequency{0};
+2 -2
View File
@@ -80,7 +80,7 @@ protected:
LOCK_NONE /**< perform no locking, only safe if the bus is entirely private */
};
virtual int init();
virtual int init() override;
/**
* Check for the presence of the device on the bus.
@@ -164,7 +164,7 @@ protected:
int _transferhword(uint16_t *send, uint16_t *recv, unsigned len);
bool external() { return px4_spi_bus_external(get_device_bus()); }
virtual bool external() const override { return px4_spi_bus_external(get_device_bus()); }
};
+2 -2
View File
@@ -66,7 +66,7 @@ public:
I2C(I2C &&) = delete;
I2C &operator=(I2C &&) = delete;
virtual int init();
virtual int init() override;
protected:
/**
@@ -106,7 +106,7 @@ protected:
*/
int transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const unsigned recv_len);
bool external() { return px4_i2c_bus_external(_device_id.devid_s.bus); }
virtual bool external() const override { return px4_i2c_bus_external(_device_id.devid_s.bus); }
private:
int _fd{-1};
+2 -2
View File
@@ -95,7 +95,7 @@ protected:
LOCK_NONE /**< perform no locking, only safe if the bus is entirely private */
};
virtual int init();
virtual int init() override;
/**
* Check for the presence of the device on the bus.
@@ -179,7 +179,7 @@ protected:
int _transferhword(uint16_t *send, uint16_t *recv, unsigned len);
bool external() { return px4_spi_bus_external(get_device_bus()); }
virtual bool external() const override { return px4_spi_bus_external(get_device_bus()); }
};
+64 -2
View File
@@ -92,7 +92,7 @@
<min>0</min>
<max>4000</max>
</parameter>
<parameter default="0.0" name="mot_ls" type="FLOAT">
<parameter default="0.0" name="mot_ls" type="FLOAT">
<short_desc>READ ONLY: Motor inductance in henries.</short_desc>
<long_desc>READ ONLY: Motor inductance in henries. This is measured on start-up.</long_desc>
<unit>henries</unit>
@@ -135,4 +135,66 @@
<min>0</min>
</parameter>
</group>
</parameters>
<group name="UAVCAN GNSS" no_code_generation="true">
<parameter name="gnss.warn_dimens" default="0" type="INT32">
<short_desc>device health warning</short_desc>
<long_desc>Set the device health to Warning if the dimensionality of
the GNSS solution is less than this value. 3 for the full (3D)
solution, 2 for planar (2D) solution, 1 for time-only solution,
0 disables the feature.
</long_desc>
<min>0</min>
<max>3</max>
<values>
<value code="0">disables the feature</value>
<value code="1">time-only solution</value>
<value code="2">planar (2D) solution</value>
<value code="3">full (3D) solution</value>
</values>
</parameter>
<parameter name="gnss.warn_sats" default="0" type="INT32">
<short_desc></short_desc>
<long_desc>Set the device health to Warning if the number of satellites
used in the GNSS solution is below this threshold. Zero
disables the feature
</long_desc>
</parameter>
<parameter name="gnss.dyn_model" default="2" type="INT32">
<short_desc>GNSS dynamic model</short_desc>
<long_desc>Dynamic model used in the GNSS positioning engine. 0 –
Automotive, 1 – Sea, 2 – Airborne.
</long_desc>
<min>0</min>
<max>2</max>
<values>
<value code="0">Automotive</value>
<value code="1">Sea</value>
<value code="2">Airborne</value>
</values>
</parameter>
<parameter name="gnss.old_fix_msg" default="1" type="INT32">
<short_desc>Broadcast old GNSS fix message</short_desc>
<long_desc>Broadcast the old (deprecated) GNSS fix message
uavcan.equipment.gnss.Fix alongside the new alternative
uavcan.equipment.gnss.Fix2. It is recommended to
disable this feature to reduce the CAN bus traffic.
</long_desc>
<min>0</min>
<max>1</max>
<values>
<value code="0">Fix2</value>
<value code="1">Fix and Fix2</value>
</values>
</parameter>
<parameter name="uavcan.pubp-pres" default="0" type="INT32">
<short_desc></short_desc>
<long_desc>Set the device health to Warning if the number of satellites
used in the GNSS solution is below this threshold. Zero
disables the feature
</long_desc>
<unit>microseconds</unit>
<min>0</min>
<max>1000000</max>
</parameter>
</group>
</parameters>