Compare commits

...

3 Commits

Author SHA1 Message Date
Daniel Agar cd1939a14e platforms/common/i2c.cpp: px4_i2c_bus_external check bus validity 2022-10-09 15:05:23 -04:00
Daniel Agar ce609144b0 simulation/gz_bridge: fix implicit floating-point conversions 2022-10-09 14:11:19 -04:00
Daniel Agar 9010029e0d lib/drivers/device: Device.hpp fully init devid
- constructor use available setters
2022-10-09 13:49:39 -04:00
3 changed files with 11 additions and 9 deletions
+5 -3
View File
@@ -40,9 +40,11 @@
#ifndef BOARD_OVERRIDE_I2C_BUS_EXTERNAL
bool px4_i2c_bus_external(int bus)
{
for (int i = 0; i < I2C_BUS_MAX_BUS_ITEMS; ++i) {
if (px4_i2c_buses[i].bus == bus) {
return px4_i2c_buses[i].is_external;
if (px4_i2c_buses) {
for (int i = 0; i < I2C_BUS_MAX_BUS_ITEMS; ++i) {
if ((px4_i2c_buses[i].bus != -1) && (px4_i2c_buses[i].bus == bus)) {
return px4_i2c_buses[i].is_external;
}
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2012-2017 PX4 Development Team. All rights reserved.
* Copyright (c) 2012-2022 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -169,7 +169,7 @@ public:
union DeviceId {
struct DeviceStructure devid_s;
uint32_t devid;
uint32_t devid{0};
};
uint32_t get_device_id() const { return _device_id.devid; }
@@ -268,8 +268,8 @@ protected:
Device(uint8_t devtype, const char *name, DeviceBusType bus_type, uint8_t bus, uint8_t address) : _name(name)
{
set_device_type(devtype);
_device_id.devid_s.bus_type = bus_type;
_device_id.devid_s.bus = bus;
set_device_bus_type(bus_type);
set_device_bus(bus);
set_device_address(address);
}
@@ -80,14 +80,14 @@ int GZBridge::init()
if (!_model_pose.empty()) {
PX4_INFO("Requested Model Position: %s", _model_pose.c_str());
std::vector<float> model_pose_v;
std::vector<double> model_pose_v;
std::stringstream ss(_model_pose);
while (ss.good()) {
std::string substr;
std::getline(ss, substr, ',');
model_pose_v.push_back(std::stof(substr));
model_pose_v.push_back(std::stod(substr));
}
while (model_pose_v.size() < 6) {