mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-20 20:03:54 +08:00
cleanup uavcan_main: replace warnx with PX4_{INFO,ERR,DEBUG}
This commit is contained in:
@@ -526,7 +526,7 @@ int UavcanNode::fw_server(eServerAction action)
|
||||
int UavcanNode::start(uavcan::NodeID node_id, uint32_t bitrate)
|
||||
{
|
||||
if (_instance != nullptr) {
|
||||
warnx("Already started");
|
||||
PX4_WARN("Already started");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -560,14 +560,14 @@ int UavcanNode::start(uavcan::NodeID node_id, uint32_t bitrate)
|
||||
can = new CanInitHelper();
|
||||
|
||||
if (can == nullptr) { // We don't have exceptions so bad_alloc cannot be thrown
|
||||
warnx("Out of memory");
|
||||
PX4_ERR("Out of memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const int can_init_res = can->init(bitrate);
|
||||
|
||||
if (can_init_res < 0) {
|
||||
warnx("CAN driver init failed %i", can_init_res);
|
||||
PX4_ERR("CAN driver init failed %i", can_init_res);
|
||||
return can_init_res;
|
||||
}
|
||||
}
|
||||
@@ -578,12 +578,7 @@ int UavcanNode::start(uavcan::NodeID node_id, uint32_t bitrate)
|
||||
_instance = new UavcanNode(can->driver, uavcan_stm32::SystemClock::instance());
|
||||
|
||||
if (_instance == nullptr) {
|
||||
warnx("Out of memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_instance == nullptr) {
|
||||
warnx("Out of memory");
|
||||
PX4_ERR("Out of memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -592,7 +587,7 @@ int UavcanNode::start(uavcan::NodeID node_id, uint32_t bitrate)
|
||||
if (node_init_res < 0) {
|
||||
delete _instance;
|
||||
_instance = nullptr;
|
||||
warnx("Node init failed %i", node_init_res);
|
||||
PX4_ERR("Node init failed %i", node_init_res);
|
||||
return node_init_res;
|
||||
}
|
||||
|
||||
@@ -604,7 +599,7 @@ int UavcanNode::start(uavcan::NodeID node_id, uint32_t bitrate)
|
||||
static_cast<main_t>(run_trampoline), nullptr);
|
||||
|
||||
if (_instance->_task < 0) {
|
||||
warnx("start failed: %d", errno);
|
||||
PX4_ERR("start failed: %d", errno);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
@@ -624,7 +619,7 @@ void UavcanNode::fill_node_info()
|
||||
swver.optional_field_flags |= swver.OPTIONAL_FIELD_FLAG_VCS_COMMIT;
|
||||
|
||||
// Too verbose for normal operation
|
||||
//warnx("SW version vcs_commit: 0x%08x", unsigned(swver.vcs_commit));
|
||||
//PX4_INFO("SW version vcs_commit: 0x%08x", unsigned(swver.vcs_commit));
|
||||
|
||||
_node.setSoftwareVersion(swver);
|
||||
|
||||
@@ -678,11 +673,11 @@ int UavcanNode::init(uavcan::NodeID node_id)
|
||||
ret = br->init();
|
||||
|
||||
if (ret < 0) {
|
||||
warnx("cannot init sensor bridge '%s' (%d)", br->get_name(), ret);
|
||||
PX4_ERR("cannot init sensor bridge '%s' (%d)", br->get_name(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
warnx("sensor bridge '%s' init ok", br->get_name());
|
||||
PX4_INFO("sensor bridge '%s' init ok", br->get_name());
|
||||
br = br->getSibling();
|
||||
}
|
||||
|
||||
@@ -697,7 +692,7 @@ void UavcanNode::node_spin_once()
|
||||
const int spin_res = _node.spinOnce();
|
||||
|
||||
if (spin_res < 0) {
|
||||
warnx("node spin error %i", spin_res);
|
||||
PX4_ERR("node spin error %i", spin_res);
|
||||
}
|
||||
|
||||
|
||||
@@ -788,7 +783,7 @@ int UavcanNode::run()
|
||||
const int slave_init_res = _time_sync_slave.start();
|
||||
|
||||
if (slave_init_res < 0) {
|
||||
warnx("Failed to start time_sync_slave");
|
||||
PX4_ERR("Failed to start time_sync_slave");
|
||||
_task_should_exit = true;
|
||||
}
|
||||
|
||||
@@ -806,7 +801,7 @@ int UavcanNode::run()
|
||||
const int busevent_fd = ::open(uavcan_stm32::BusEvent::DevName, 0);
|
||||
|
||||
if (busevent_fd < 0) {
|
||||
warnx("Failed to open %s", uavcan_stm32::BusEvent::DevName);
|
||||
PX4_ERR("Failed to open %s", uavcan_stm32::BusEvent::DevName);
|
||||
_task_should_exit = true;
|
||||
}
|
||||
|
||||
@@ -999,7 +994,6 @@ int UavcanNode::run()
|
||||
(void)::close(busevent_fd);
|
||||
|
||||
teardown();
|
||||
warnx("exiting.");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@@ -1046,12 +1040,12 @@ UavcanNode::subscribe()
|
||||
// the first fd used by CAN
|
||||
for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) {
|
||||
if (sub_groups & (1 << i)) {
|
||||
warnx("subscribe to actuator_controls_%d", i);
|
||||
PX4_DEBUG("subscribe to actuator_controls_%d", i);
|
||||
_control_subs[i] = orb_subscribe(_control_topics[i]);
|
||||
}
|
||||
|
||||
if (unsub_groups & (1 << i)) {
|
||||
warnx("unsubscribe from actuator_controls_%d", i);
|
||||
PX4_DEBUG("unsubscribe from actuator_controls_%d", i);
|
||||
orb_unsubscribe(_control_subs[i]);
|
||||
_control_subs[i] = -1;
|
||||
}
|
||||
@@ -1114,7 +1108,7 @@ UavcanNode::ioctl(file *filp, int cmd, unsigned long arg)
|
||||
ret = _mixers->load_from_buf(buf, buflen);
|
||||
|
||||
if (ret != 0) {
|
||||
warnx("mixer load failed with %d", ret);
|
||||
PX4_ERR("mixer load failed with %d", ret);
|
||||
delete _mixers;
|
||||
_mixers = nullptr;
|
||||
_groups_required = 0;
|
||||
@@ -1172,10 +1166,6 @@ UavcanNode::ioctl(file *filp, int cmd, unsigned long arg)
|
||||
void
|
||||
UavcanNode::print_info()
|
||||
{
|
||||
if (!_instance) {
|
||||
warnx("not running, start first");
|
||||
}
|
||||
|
||||
(void)pthread_mutex_lock(&_node_mutex);
|
||||
|
||||
// Memory status
|
||||
@@ -1288,10 +1278,10 @@ void UavcanNode::hardpoint_controller_set(uint8_t hardpoint_id, uint16_t command
|
||||
*/
|
||||
static void print_usage()
|
||||
{
|
||||
warnx("usage: \n"
|
||||
"\tuavcan {start [fw]|status|stop [all|fw]|shrink|arm|disarm|update fw|\n"
|
||||
"\t param [set|get|list|save] <node-id> <name> <value>|reset <node-id>|\n"
|
||||
"\t hardpoint set <id> <command>}");
|
||||
PX4_INFO("usage: \n"
|
||||
"\tuavcan {start [fw]|status|stop [all|fw]|shrink|arm|disarm|update fw|\n"
|
||||
"\t param [set|get|list|save] <node-id> <name> <value>|reset <node-id>|\n"
|
||||
"\t hardpoint set <id> <command>}");
|
||||
}
|
||||
|
||||
extern "C" __EXPORT int uavcan_main(int argc, char *argv[]);
|
||||
@@ -1311,7 +1301,7 @@ int uavcan_main(int argc, char *argv[])
|
||||
int rv = UavcanNode::instance()->fw_server(UavcanNode::Start);
|
||||
|
||||
if (rv < 0) {
|
||||
warnx("Firmware Server Failed to Start %d", rv);
|
||||
PX4_ERR("Firmware Server Failed to Start %d", rv);
|
||||
::exit(rv);
|
||||
}
|
||||
|
||||
@@ -1319,7 +1309,7 @@ int uavcan_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Already running, no error
|
||||
warnx("already started");
|
||||
PX4_INFO("already started");
|
||||
::exit(0);
|
||||
}
|
||||
|
||||
@@ -1328,7 +1318,7 @@ int uavcan_main(int argc, char *argv[])
|
||||
(void)param_get(param_find("UAVCAN_NODE_ID"), &node_id);
|
||||
|
||||
if (node_id < 0 || node_id > uavcan::NodeID::Max || !uavcan::NodeID(node_id).isUnicast()) {
|
||||
warnx("Invalid Node ID %i", node_id);
|
||||
PX4_ERR("Invalid Node ID %i", node_id);
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
@@ -1337,7 +1327,7 @@ int uavcan_main(int argc, char *argv[])
|
||||
(void)param_get(param_find("UAVCAN_BITRATE"), &bitrate);
|
||||
|
||||
// Start
|
||||
warnx("Node ID %u, bitrate %u", node_id, bitrate);
|
||||
PX4_INFO("Node ID %u, bitrate %u", node_id, bitrate);
|
||||
return UavcanNode::start(node_id, bitrate);
|
||||
}
|
||||
|
||||
@@ -1467,7 +1457,7 @@ int uavcan_main(int argc, char *argv[])
|
||||
inst->shrink();
|
||||
|
||||
if (rv < 0) {
|
||||
warnx("Firmware Server Failed to Stop %d", rv);
|
||||
PX4_ERR("Firmware Server Failed to Stop %d", rv);
|
||||
::exit(rv);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user