Lines Matching refs:args
162 static bool ValidateArgs(std::unique_ptr<ParsedArgs>& args, const char *name) { in ValidateArgs() argument
163 if (!args->sensors.size() in ValidateArgs()
164 && (args->command == NanotoolCommand::Disable in ValidateArgs()
165 || args->command == NanotoolCommand::Calibrate in ValidateArgs()
166 || args->command == NanotoolCommand::Test in ValidateArgs()
167 || args->command == NanotoolCommand::Poll)) { in ValidateArgs()
174 if (args->command == NanotoolCommand::Flash in ValidateArgs()
175 && args->filename.empty()) { in ValidateArgs()
182 if (args->command == NanotoolCommand::Poll) { in ValidateArgs()
183 for (unsigned int i = 0; i < args->sensors.size(); i++) { in ValidateArgs()
184 if (args->sensors[i].special_rate == SensorSpecialRate::None in ValidateArgs()
185 && args->sensors[i].rate_hz < 0) { in ValidateArgs()
189 args->sensors[i].sensor_type).c_str()); in ValidateArgs()
195 if (args->command == NanotoolCommand::Calibrate) { in ValidateArgs()
196 for (unsigned int i = 0; i < args->sensors.size(); i++) { in ValidateArgs()
197 if (!args->sensors[i].have_cal_ref in ValidateArgs()
198 && (args->sensors[i].sensor_type == SensorType::Barometer in ValidateArgs()
199 || args->sensors[i].sensor_type == in ValidateArgs()
204 args->sensors[i].sensor_type).c_str()); in ValidateArgs()
308 auto args = std::unique_ptr<ParsedArgs>(new ParsedArgs()); in ParseArgs() local
318 args->command = StrToCommand(optarg); in ParseArgs()
319 if (args->command == NanotoolCommand::Invalid) { in ParseArgs()
326 if (!ParseSensorArg(args->sensors, optarg, argv[0])) { in ParseArgs()
332 args->count = atoi(optarg); in ParseArgs()
333 if (args->count < 0) { in ParseArgs()
335 argv[0], args->count); in ParseArgs()
349 args->logging_enabled = true; in ParseArgs()
354 args->filename = std::string(optarg); in ParseArgs()
362 args->device_index = atoi(optarg); in ParseArgs()
363 if (args->device_index < 0) { in ParseArgs()
365 args->device_index); in ParseArgs()
375 if (!ValidateArgs(args, argv[0])) { in ParseArgs()
378 return args; in ParseArgs()
381 static std::unique_ptr<ContextHub> GetContextHub(std::unique_ptr<ParsedArgs>& args) { in GetContextHub() argument
383 (void) args; in GetContextHub()
386 return std::unique_ptr<UsbContextHub>(new UsbContextHub(args->device_index)); in GetContextHub()
422 std::unique_ptr<ParsedArgs> args = ParseArgs(argc, argv); in main() local
423 if (!args) { in main()
432 std::unique_ptr<ContextHub> hub = GetContextHub(args); in main()
438 hub->SetLoggingEnabled(args->logging_enabled); in main()
441 switch (args->command) { in main()
443 success = hub->DisableSensors(args->sensors); in main()
449 if (!args->sensors.size()) { in main()
450 hub->PrintAllEvents(args->count); in main()
452 hub->PrintSensorEvents(args->sensors, args->count); in main()
457 success = hub->EnableSensors(args->sensors); in main()
459 hub->PrintSensorEvents(args->sensors, args->count); in main()
464 hub->DisableSensors(args->sensors); in main()
465 success = hub->CalibrateSensors(args->sensors); in main()
469 hub->DisableSensors(args->sensors); in main()
476 success = hub->TestSensors(args->sensors); in main()
484 success = hub->Flash(args->filename); in main()
499 } else if (args->command != NanotoolCommand::Read in main()
500 && args->command != NanotoolCommand::Poll) { in main()