int uavcannode_main(bool start_not_stop) { if (start_not_stop) { if (UavcanNode::instance()) { PX4_ERR("already started"); return 1; } return uavcannode_start(); } /* commands below require the app to be started */ UavcanNode *const inst = UavcanNode::instance(); if (!inst) { PX4_ERR( "application not running"); return 1; } if (!start_not_stop) { inst->stop(); return 0; } print_usage(); return 1; }
int uavcannode_main(int argc, char *argv[]) { if (argc < 2) { print_usage(); ::exit(1); } if (!std::strcmp(argv[1], "start")) { if (UavcanNode::instance()) { errx(1, "already started"); } return uavcannode_start(argc, argv); } /* commands below require the app to be started */ UavcanNode *const inst = UavcanNode::instance(); if (!inst) { errx(1, "application not running"); } if (!std::strcmp(argv[1], "status") || !std::strcmp(argv[1], "info")) { inst->print_info(); ::exit(0); } if (!std::strcmp(argv[1], "stop")) { delete inst; ::exit(0); } print_usage(); ::exit(1); }