BamHeader PrepareHeader(const OptionParser& parser, int argc, char** argv, const vector<string>& files) { using boost::algorithm::join; ProgramInfo program(parser.prog() + "-" + CCS_VERSION); program.Name(parser.prog()) .CommandLine(parser.prog() + " " + join(vector<string>(argv + 1, argv + argc), " ")) .Description(DESCRIPTION) .Version(CCS_VERSION); BamHeader header; header.PacBioBamVersion("3.0.1").SortOrder("unknown").Version("1.5").AddProgram(program); for (const auto& file : files) { BamFile bam(file); for (const auto& rg : bam.Header().ReadGroups()) { if (rg.ReadType() != "SUBREAD") parser.error("invalid input file, READTYPE must be SUBREAD"); ReadGroupInfo readGroup(rg.MovieName(), "CCS"); readGroup.BindingKit(rg.BindingKit()) .SequencingKit(rg.SequencingKit()) .BasecallerVersion(rg.BasecallerVersion()) .FrameRateHz(rg.FrameRateHz()); header.AddReadGroup(readGroup); } } return header; }
int main(int argc, char** argv) { OptionParser options; options.executable("lucb") .program(DUNE_SHORT_NAME) .copyright(DUNE_COPYRIGHT) .email(DUNE_CONTACT) .version(getFullVersion()) .date(getCompileDate()) .arch(DUNE_SYSTEM_NAME) .description("Utility to update firmware of LUCL based devices.") .add("-d", "--sys-device", "System device", "DEVICE") .add("-b", "--baud-rate", "Baud rate", "BAUD") .add("-i", "--i2c-address", "I2C slave address", "I2C_ADDR") .add("-f", "--file", "iHEX file", "IHEX_FILE"); // Parse command line arguments. if (!options.parse(argc, argv)) { if (options.bad()) std::cerr << "ERROR: " << options.error() << std::endl; options.usage(); return 1; } // Get iHEX file. std::string ihex = options.value("--file"); if (ihex.empty()) { std::cerr << "ERROR: you must specify one iHEX file." << std::endl; return 1; } // Get system device. std::string sys_dev = options.value("--sys-device"); if (sys_dev.empty()) { std::cerr << "ERROR: you must specify one system device." << std::endl; return 1; } // Get specified baud rate. int baud = 0; castLexical(options.value("--baud-rate"), baud); // Get I2C address (if any). bool is_i2c = false; uint8_t i2c_addr = 0; if (castLexical(options.value("--i2c-address"), i2c_addr)) { if ((i2c_addr < 0x03) || (i2c_addr > 0x77)) { std::cerr << "ERROR: I2C device address is out of range (0x03 - 0x77)" << std::endl; return 1; } is_i2c = true; } LUCL::Protocol proto; if (is_i2c) proto.setI2C(sys_dev, i2c_addr); else proto.setUART(sys_dev); try { LUCL::BootLoader boot(proto, true, baud); boot.flash(ihex); } catch (std::exception& e) { std::cerr << "ERROR: " << e.what() << std::endl; } return 0; }
int main(int argc, char** argv) { OptionParser options; options.executable(argv[0]) .program(DUNE_SHORT_NAME) .copyright(DUNE_COPYRIGHT) .email("Renato Caldas <*****@*****.**>") .version(getFullVersion()) .date(getCompileDate()) .arch(DUNE_SYSTEM_NAME) .description("Utility to update firmware of LUCL based devices.") .add("-d", "--sys-device", "System device", "DEVICE") .add("-i", "--i2c-address", "I2C slave address", "I2C_ADDR") .add("-c", "--command", "LUCL command", "CMD") .add("-p", "--data-payload", "LUCL data", "DATA0[,DATA1 ...]"); // Parse command line arguments. if (!options.parse(argc, argv)) { if (options.bad()) std::cerr << "ERROR: " << options.error() << std::endl; options.usage(); return 1; } // Get system device. std::string sys_dev = options.value("--sys-device"); if (sys_dev.empty()) { std::cerr << "ERROR: you must specify one system device." << std::endl; return 1; } // Get I2C address (if any). bool is_i2c = false; uint8_t i2c_addr = 0; if (castLexical(options.value("--i2c-address"), i2c_addr)) { if ((i2c_addr < 0x03) || (i2c_addr > 0x77)) { std::cerr << "ERROR: I2C device address is out of range (0x03 - 0x77)" << std::endl; return 1; } is_i2c = true; } // Open the device LUCL::Protocol proto; if (is_i2c) proto.setI2C(sys_dev, i2c_addr); else proto.setUART(sys_dev); try { proto.open(); } catch (std::exception& e) { std::cerr << "ERROR: " << e.what() << std::endl; return 1; } // Check for the command token std::string command = options.value("--command"); if (command.empty()) { std::cerr << "ERROR: reading from stdio not supported yet." << std::endl; return 1; } // Get the data payload std::string data_str = options.value("--data-payload"); std::vector<uint8_t> data_lst; if (!castLexical(data_str, data_lst)) { std::cerr << "ERROR: failed to parse the data payload argument." << std::endl; return 1; } // Build and send the packet if (command.compare("Info") == 0) { std::cerr << "Requesting device information" << std::endl; try { proto.requestVersion(); } catch (std::exception& e) { std::cerr << "ERROR: " << e.what() << std::endl; return 1; } } else if (command.compare("Reset") == 0) { std::cerr << "Requesting reset" << std::endl; try { proto.requestReset(); } catch (std::exception& e) { std::cerr << "ERROR: " << e.what() << std::endl; return 1; } } else { // Command string not recognized, attempt to interpret it as an integer int cmd; if (!castLexical(command, cmd)) { std::cerr << "ERROR: bad command \"" << command << "\"" << std::endl; return 1; } // Print the command and the data in a parseable format std::cout << "Sending packet CMD " << cmd << " DATA"; for (unsigned i = 0; i < data_lst.size(); i++) { std::cout << " 0x" << std::hex << (int)data_lst[i]; } std::cout << std::endl; try { proto.sendCommand(cmd, (uint8_t*)(&data_lst[0]), (int)data_lst.size()); } catch (std::exception& e) { std::cerr << "ERROR: " << e.what() << std::endl; return 1; } } // Handle the results handleReply(proto); return 0; }
int main(int argc, char** argv) { OptionParser options; options.executable("dune-test-tail") .program(DUNE_SHORT_NAME) .copyright(DUNE_COPYRIGHT) .email(DUNE_CONTACT) .version(getFullVersion()) .date(getCompileDate()) .arch(DUNE_SYSTEM_NAME) .add("-i", "--address", "Vehicle's IP address", "ADDRESS") .add("-w", "--wait", "Wait DELAY seconds before starting test", "DELAY") .add("-d", "--duration", "Test duration in seconds", "DURATION") .add("-s", "--speed", "Speed in percentage", "SPEED") .add("-t", "--angle", "Angle in degrees", "ANGLE"); // Parse command line arguments. if (!options.parse(argc, argv)) { if (options.bad()) std::cerr << "ERROR: " << options.error() << std::endl; options.usage(); return 1; } // Set destination address. if (options.value("--address") == "") g_addr = "127.0.0.1"; else g_addr = options.value("--address").c_str(); // Set start delay. double sdelay = 0; if (options.value("--wait") == "") sdelay = 0; else sdelay = castLexical<double>(options.value("--wait")); // Set duration. double duration = 0; if (options.value("--duration") == "") duration = 0; else duration = castLexical<double>(options.value("--duration")); // Set speed. double speed = 0; if (options.value("--speed") == "") speed = 0; else { speed = castLexical<double>(options.value("--speed")); speed /= 100.0; } // Set Angle double angle = 0; if (options.value("--angle") == "") angle = 0; else angle = castLexical<double>(options.value("--angle")); // POSIX implementation. #if defined(DUNE_SYS_HAS_SIGACTION) struct sigaction actions; std::memset(&actions, 0, sizeof(actions)); sigemptyset(&actions.sa_mask); actions.sa_flags = 0; actions.sa_handler = handleTerminate; sigaction(SIGALRM, &actions, 0); sigaction(SIGHUP, &actions, 0); sigaction(SIGINT, &actions, 0); sigaction(SIGQUIT, &actions, 0); sigaction(SIGTERM, &actions, 0); sigaction(SIGCHLD, &actions, 0); sigaction(SIGCONT, &actions, 0); #endif setThrust(0); Delay::wait(sdelay); setLog("mcrt_endurance"); Delay::wait(2.0); double deadline = Clock::get() + duration; setThrust(speed); while ((Clock::get() < deadline) && !g_stop) { setFin(0, -angle); setFin(1, -angle); setFin(2, -angle); setFin(3, -angle); if (!g_stop) Delay::wait(1.0); if (!g_stop) Delay::wait(1.0); if (!g_stop) Delay::wait(1.0); if (!g_stop) Delay::wait(1.0); setFin(0, angle); setFin(1, angle); setFin(2, angle); setFin(3, angle); if (!g_stop) Delay::wait(1.0); if (!g_stop) Delay::wait(1.0); if (!g_stop) Delay::wait(1.0); if (!g_stop) Delay::wait(1.0); } // Change log. Delay::wait(2.0); setLog("idle"); onTerminate(); return 0; }
int main(int argc, char** argv) { Tasks::Context context; I18N::setLanguage(context.dir_i18n); Scheduler::set(Scheduler::POLICY_RR); OptionParser options; options.executable("dune") .program(DUNE_SHORT_NAME) .copyright(DUNE_COPYRIGHT) .email(DUNE_CONTACT) .version(getFullVersion()) .date(getCompileDate()) .arch(DUNE_SYSTEM_NAME) .add("-d", "--config-dir", "Configuration directory", "DIR") .add("-w", "--www-dir", "HTTP server base directory", "DIR") .add("-c", "--config-file", "Load configuration file CONFIG", "CONFIG") .add("-m", "--lock-memory", "Lock memory") .add("-p", "--profiles", "Execution Profiles", "PROFILES") .add("-V", "--vehicle", "Vehicle name override", "VEHICLE") .add("-X", "--dump-params-xml", "Dump parameters XML to folder DIR", "DIR"); // Parse command line arguments. if (!options.parse(argc, argv)) { if (options.bad()) std::cerr << "ERROR: " << options.error() << std::endl; options.usage(); return 1; } // If requested, lock memory. if (!options.value("--lock-memory").empty()) { #if defined(DUNE_USING_TLSF) && defined(DUNE_CLIB_GNU) Resources::lockMemory(c_memory, c_memory_size); #else Resources::lockMemory(); #endif } // If requested, set alternate configuration directory. if (options.value("--config-dir") != "") { context.dir_cfg = options.value("--config-dir"); } // If requested, set alternate HTTP server directory. if (options.value("--www-dir") != "") { context.dir_www = options.value("--www-dir"); } DUNE::Tasks::Factory::registerDynamicTasks(context.dir_lib.c_str()); registerStaticTasks(); // Retrieve configuration file and try parsing it. if (options.value("--config-file") == "") { std::cerr << String::str(DTR("ERROR: no configuration file was given, " "see options --config-list and --config-file\n")) << std::endl; return 1; } Path cfg_file = context.dir_cfg / options.value("--config-file") + ".ini"; try { context.config.parseFile(cfg_file.c_str()); } catch (std::runtime_error& e) { try { cfg_file = context.dir_usr_cfg / options.value("--config-file") + ".ini"; context.config.parseFile(cfg_file.c_str()); context.dir_cfg = context.dir_usr_cfg; } catch (std::runtime_error& e2) { std::cerr << String::str("ERROR: %s\n", e.what()) << std::endl; std::cerr << String::str("ERROR: %s\n", e2.what()) << std::endl; return 1; } } if (!options.value("--vehicle").empty()) context.config.set("General", "Vehicle", options.value("--vehicle")); try { DUNE::Daemon daemon(context, options.value("--profiles")); // Parameters XML. if (options.value("--dump-params-xml") != "") { std::string lang = I18N::getLanguage(); std::string file = String::str("%s.%s.xml", daemon.getSystemName(), lang.c_str()); Path path = Path(options.value("--dump-params-xml")) / file; std::ofstream ofs(path.c_str()); if (!ofs.is_open()) { std::cerr << "ERROR: failed to create file '" << path << "'" << std::endl; return 1; } daemon.writeParamsXML(ofs); return 0; } return runDaemon(daemon); } catch (std::exception& e) { std::cerr << "ERROR: " << e.what() << std::endl; } }
int main(int argc, char** argv) { OptionParser options; options.executable(argv[0]) .program("DUNE UCTK Flash Programmer") .copyright(DUNE_COPYRIGHT) .email("Ricardo Martins <*****@*****.**>") .version(getFullVersion()) .date(getCompileDate()) .arch(DUNE_SYSTEM_NAME) .description("Utility to update the firmware of UCTK based devices.") .add("-d", "--dev", "System device", "DEVICE") .add("-t", "--dev-type", "System device type", "TYPE") .add("-f", "--file", "iHEX file", "IHEX_FILE"); // Parse command line arguments. if (!options.parse(argc, argv)) { if (options.bad()) std::cerr << "ERROR: " << options.error() << std::endl; options.usage(); return 1; } // Get iHEX file. std::string ihex = options.value("--file"); if (ihex.empty()) { std::cerr << "ERROR: you must specify one iHEX file." << std::endl; return 1; } if (Path(ihex).type() != Path::PT_FILE) { std::cerr << "ERROR: no such file: '" << ihex << "'" << std::endl; return 1; } // Get system device. std::string sys_dev = options.value("--dev"); if (sys_dev.empty()) { std::cerr << "ERROR: you must specify one system device." << std::endl; return 1; } // Get device type. IO::Handle* handle = NULL; std::string dev_type = options.value("--dev-type"); if (dev_type == "escc") handle = new ESCC(sys_dev); else handle = new SerialPort(sys_dev, c_baud_rate); UCTK::Interface itf(handle); UCTK::Bootloader* boot = new UCTK::Bootloader(&itf, true); boot->program(ihex); delete boot; delete handle; return 0; }