void gluonscript_init() { gluonscript_data.current_codeline = 0; gluonscript_data.last_code = 0; gluonscript_data.tick = 0; gluonscript_load(); navigation_init(); }
void navigation_task() { bool logging_enabled = false; navigation_init(); #ifdef FLASH_ENABLED if (flash_init() == 0) { logging_enabled = true; } if (logging_enabled) { if (!log_init()) { serial_printf(cli_stdout, "log_init failed\n"); log_reset(); } } //We look if we have mavlink mission item logged, in case we just suffered a crash uint32_t time = 0; char name[4]; //Name is a 3 characters long string mission_item_list_t item_list; if(log_read_mavlink_item_list(&item_list, &time, &name, &pos_counter)) navigation_restore_mission_items(item_list); #endif unsigned int loops_since_stop = 0; while(1){ // navigation_update_target(); navigation_update_current_target(); navigation_update_position(); navigation_update_state(); navigation_arm_disarm(); navigation_move(); if(navigation_rover_moving() || loops_since_stop < 62) // trasmit messages after stop for a duration such that //at least one msg with speed zero is tx'd via LoRa { comm_mavlink_broadcast(navigation_pack_mavlink_hud()); comm_mavlink_broadcast(navigation_pack_rc_channels_scaled()); } if(!navigation_rover_moving()) loops_since_stop++; else loops_since_stop = 0; Task_sleep(500); } }
int main (int argc, const char **argv) { #ifdef WIN32 { // set the console to accept escape sequences (Win10+) HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); if (console != INVALID_HANDLE_VALUE) { DWORD consoleMode = 0; GetConsoleMode(console, &consoleMode); consoleMode |= 4; // ENABLE_VIRTUAL_TERMINAL_PROCESSING; but that isn't available in our current SDK target SetConsoleMode(console, consoleMode); } } #endif int exit_code = EXIT_SUCCESS; try { // Experiment with floating point masks. // #ifdef FE_NOMASK_ENV // feenableexcept(FE_INVALID); // feenableexcept(FE_DIVBYZERO | FE_INVALID); // #endif bgl = new BackgroundLoader(); size_t winid = gfx_init(cb); debug_drawer = new BulletDebugDrawer(ogre_sm); // FIXME: hack #ifdef WIN32 mouse = new MouseDirectInput8(winid); bool use_dinput = getenv("GRIT_DINPUT")!=NULL; keyboard = use_dinput ? (Keyboard *)new KeyboardDirectInput8(winid) : (Keyboard *)new KeyboardWinAPI(winid); #else mouse = new MouseX11(winid); keyboard = new KeyboardX11(winid); #endif clipboard_init(); physics_init(); net_init(); core_option_init(); streamer_init(); navigation_init(); // audio_init(getenv("GRIT_AUDIO_DEV")); audio_init(NULL); std::vector<std::string> args; for (int i=0 ; i<argc ; i++) { args.push_back(argv[i]); } try { const char *init_file = getenv("GRIT_INIT"); if (init_file == nullptr) init_file = "/system/init.lua"; init_lua(init_file, args, core_L); } catch (Exception &e) { CERR << "Fatal error: " << e << std::endl; exit_code = EXIT_FAILURE; } // Lua returns - we quit. CVERB << "Shutting down Lua net subsystem..." << std::endl; net_shutdown(core_L); navigation_shutdown(); object_all_del(core_L); // Will remove all demands from background loader. CVERB << "Shutting down Lua graphics subsystem..." << std::endl; gfx_shutdown_lua(core_L); CVERB << "Shutting down Background Loader..." << std::endl; bgl->shutdown(); CVERB << "Shutting down Mouse & Keyboard..." << std::endl; if (mouse) delete mouse; if (keyboard) delete keyboard; CVERB << "Shutting down clipboard..." << std::endl; clipboard_shutdown(); CVERB << "Shutting down Lua VM..." << std::endl; if (core_L) shutdown_lua(core_L); CVERB << "Shutting down audio subsystem..." << std::endl; audio_shutdown(); //close AL device CVERB << "Shutting down physics subsystem..." << std::endl; physics_shutdown(); CVERB << "Shutting down the physics debug drawer..." << std::endl; if (debug_drawer) delete debug_drawer; CVERB << "Shutting down the Graphics subsystem..." << std::endl; gfx_shutdown(); delete bgl; } catch (Exception &e) { std::cerr << "TOP LEVEL ERROR: " << e << std::endl; return EXIT_FAILURE; } return exit_code; }
int main_real(int argc, char * const* argv) { xmlerror *error = NULL; char *config_file = NULL, *command=NULL, *startup_file=NULL; int opt; char *cp; struct attr navit, conf; GList *list = NULL, *li; main_argc=argc; main_argv=argv; #ifdef HAVE_GLIB event_glib_init(); #else _g_slice_thread_init_nomessage(); #endif atom_init(); main_init(argv[0]); navit_nls_main_init(); debug_init(argv[0]); cp = getenv("NAVIT_LOGFILE"); if (cp) { debug_set_logfile(cp); } #ifdef HAVE_API_WIN32_CE else { debug_set_logfile("/Storage Card/navit.log"); } #endif file_init(); #ifndef USE_PLUGINS builtin_init(); #endif route_init(); navigation_init(); tracking_init(); search_init(); linguistics_init(); geom_init(); config_file=NULL; #ifdef HAVE_GETOPT_H opterr=0; //don't bomb out on errors. #endif /* _MSC_VER */ /* ingore iphone command line argument */ if (argc == 2 && !strcmp(argv[1],"-RegisterForSystemEvents")) argc=1; if (argc > 1) { /* Don't forget to update the manpage if you modify theses options */ while((opt = getopt(argc, argv, ":hvc:d:e:s:")) != -1) { switch(opt) { case 'h': print_usage(); exit(0); break; case 'v': printf("%s %s\n", "navit", version); exit(0); break; case 'c': printf("config file n is set to `%s'\n", optarg); config_file = optarg; break; case 'd': debug_set_global_level(atoi(optarg), 1); break; case 'e': command=optarg; break; case 's': startup_file=optarg; break; #ifdef HAVE_GETOPT_H case ':': fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt); print_usage(); exit(2); break; case '?': fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt); print_usage(); exit(3); #endif } } // use 1st cmd line option that is left for the config file if (optind < argc) config_file = argv[optind]; } // if config file is explicitely given only look for it, otherwise try std paths if (config_file) { list = g_list_append(list,g_strdup(config_file)); } else { list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_USER_DATADIR"), "/navit.xml" , NULL)); list = g_list_append(list,g_strdup("navit.xml.local")); list = g_list_append(list,g_strdup("navit.xml")); #ifdef HAVE_API_ANDROID // new preferred location (the new one should have priority over the legacy!) list = g_list_append(list,g_strdup("/sdcard/navit/navit.xml")); // legacy location, still supported list = g_list_append(list,g_strdup("/sdcard/navit.xml")); #endif list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml.local" , NULL)); list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml" , NULL)); #ifndef _WIN32 list = g_list_append(list,g_strdup("/etc/navit/navit.xml")); #endif } li = list; for (;;) { if (li == NULL) { // We have not found an existing config file from all possibilities dbg(0, "%s", _("No config file navit.xml, navit.xml.local found\n")); return 4; } // Try the next config file possibility from the list config_file = li->data; dbg(1,"trying %s\n",config_file); if (file_exists(config_file)) { break; } g_free(config_file); li = g_list_next(li); } dbg(0,"Loading %s\n",config_file); if (!config_load(config_file, &error)) { dbg(0, _("Error parsing config file '%s': %s\n"), config_file, error ? error->message : ""); } else { dbg(0, _("Using config file '%s'\n"), config_file); } while (li) { g_free(li->data); li = g_list_next(li); } g_list_free(list); if (! config_get_attr(config, attr_navit, &navit, NULL) && !config_empty_ok) { dbg(0, "%s", _("Internal initialization failed, exiting. Check previous error messages.\n")); exit(5); } conf.type=attr_config; conf.u.config=config; if (startup_file) { FILE *f=fopen(startup_file,"r"); if (f) { char buffer[4096]; while(fgets(buffer, sizeof(buffer), f)) { command_evaluate(&conf, buffer); } } } if (command) { command_evaluate(&conf, command); } event_main_loop_run(); /* TODO: Android actually has no event loop, so we can't free all allocated resources here. Have to find better place to * free all allocations on program exit. And don't forget to free all the stuff allocated in the code above. */ #ifndef HAVE_API_ANDROID linguistics_free(); debug_finished(); #endif return 0; }
int main_real(int argc, char **argv) { dbg(0, "in main loop 001 ##########################\n"); xmlerror *error = NULL; char *config_file = NULL; int opt; char *cp; struct attr navit; GList *list = NULL, *li; main_argc = argc; main_argv = argv; //dbg(0, "in main loop 002 ##########################\n"); #ifdef HAVE_GLIB event_glib_init(); //dbg(0,"in main loop 003 ##########################\n"); #else _g_slice_thread_init_nomessage(); //dbg(0, "in main loop 004 ##########################\n"); #endif atom_init(); main_init(argv[0]); main_init_nls(); debug_init(argv[0]); // ?? cp = getenv("NAVIT_LOGFILE"); if (cp) { debug_set_logfile(cp); } #ifdef HAVE_API_WIN32_CE else { debug_set_logfile("/Storage Card/navit.log"); } #endif //dbg(0, "in main loop 005 ##########################\n"); file_init(); //dbg(0, "in main loop 006 ##########################\n"); #ifndef USE_PLUGINS //dbg(0, "in main loop 007 ##########################\n"); builtin_init(); #endif //dbg(0, "in main loop 008 ##########################\n"); route_init(); //dbg(0, "in main loop 008.1 ##########################\n"); navigation_init(); //dbg(0, "in main loop 008.2 ##########################\n"); tracking_init(); //dbg(0, "in main loop 008.3 ##########################\n"); search_init(); //dbg(0, "in main loop 008.4 ##########################\n"); linguistics_init(); //dbg(0, "in main loop 0014 ##########################\n"); config_file = NULL; #ifdef HAVE_GETOPT_H opterr=0; //don't bomb out on errors. #endif /* _MSC_VER */ if (argc > 1) { /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */ while ((opt = getopt(argc, argv, ":hvc:d:")) != -1) { switch (opt) { case 'h': print_usage(); exit(0); break; case 'v': printf("%s %s\n", "navit", version); exit(0); break; case 'c': printf("config file n is set to `%s'\n", optarg); config_file = optarg; break; case 'd': printf("TODO Verbose option is set to `%s'\n", optarg); break; #ifdef HAVE_GETOPT_H case ':': fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt); print_usage(); exit(1); break; case '?': fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt); print_usage(); exit(1); #endif } } // use 1st cmd line option that is left for the config file if (optind < argc) config_file = argv[optind]; } // if config file is explicitely given only look for it, otherwise try std paths //if (config_file) //{ // list = g_list_append(list, g_strdup(config_file)); //} //else //{ dbg(0, "navit_share_dir=%s\n", navit_share_dir); list = g_list_append(list, g_strjoin(NULL, navit_share_dir, "/navit.xml", NULL)); //list = g_list_append(list, g_strdup("navit.xml")); #ifdef HAVE_API_ANDROID // **disabled** // new preferred location (the new one should have priority over the legacy!) // **disabled** // list = g_list_append(list,g_strdup("/sdcard/zanavi/navit.xml")); #endif //list = g_list_append(list, g_strjoin(NULL, getenv("NAVIT_SHAREDIR"), "/navit.xml", NULL)); #ifndef _WIN32 //list = g_list_append(list, g_strdup("/etc/navit/navit.xml")); #endif //} li = list; for (;;) { if (li == NULL) { // We have not found an existing config file from all possibilities dbg(0, "No config file navit.xml, navit.xml.local found\n"); return 1; } // Try the next config file possibility from the list config_file = li->data; if (file_exists(config_file)) { break; } else { g_free(config_file); } li = g_list_next(li); } // ############### load XML config file, and call all the init/new functions ################ // ############### load XML config file, and call all the init/new functions ################ // ############### load XML config file, and call all the init/new functions ################ clock_t s_ = debug_measure_start(); if (!config_load(config_file, &error)) { } debug_mrp("load and init xmlconfig:", debug_measure_end(s_)); // ############### load XML config file, and call all the init/new functions ################ // ############### load XML config file, and call all the init/new functions ################ // ############### load XML config file, and call all the init/new functions ################ while (li) { g_free(li->data); li = g_list_next(li); } g_list_free(list); if (!config_get_attr(config, attr_navit, &navit, NULL) && !config_empty_ok) { dbg(0, "No instance has been created, exiting\n"); exit(1); } dbg(0, "in main loop 026 ##########################\n"); event_main_loop_run(); dbg(0, "after main loop ##########################"); #ifndef HAVE_API_ANDROID debug_finished(); #endif return 0; }
int main_real(int argc, char **argv) { xmlerror *error = NULL; char *config_file = NULL; int opt; char *cp; struct attr navit; GList *list = NULL, *li; main_argc=argc; main_argv=argv; #ifdef HAVE_GLIB event_glib_init(); #else _g_slice_thread_init_nomessage(); #endif atom_init(); main_init(argv[0]); main_init_nls(); debug_init(argv[0]); cp = getenv("NAVIT_LOGFILE"); if (cp) debug_set_logfile(cp); #ifdef HAVE_API_WIN32_CE else debug_set_logfile("/Storage Card/navit.log"); #endif file_init(); #ifndef USE_PLUGINS extern void builtin_init(void); builtin_init(); #endif route_init(); navigation_init(); tracking_init(); search_init(); linguistics_init(); config_file=NULL; opterr=0; //don't bomb out on errors. if (argc > 1) { /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */ while((opt = getopt(argc, argv, ":hvc:d:")) != -1) { switch(opt) { case 'h': print_usage(); exit(0); break; case 'v': printf("%s %s\n", "navit", version); exit(0); break; case 'c': printf("config file n is set to `%s'\n", optarg); config_file = optarg; break; case 'd': printf("TODO Verbose option is set to `%s'\n", optarg); break; case ':': fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt); print_usage(); exit(1); break; case '?': fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt); print_usage(); exit(1); } } } // use 1st cmd line option that is left for the config file if (optind < argc) config_file = argv[optind]; // if config file is explicitely given only look for it, otherwise try std paths if (config_file) list = g_list_append(list,g_strdup(config_file)); else { list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_USER_DATADIR"), "/navit.xml" , NULL)); list = g_list_append(list,g_strdup("navit.xml.local")); list = g_list_append(list,g_strdup("navit.xml")); #ifdef HAVE_API_ANDROID list = g_list_append(list,g_strdup("/sdcard/navit.xml")); #endif list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml.local" , NULL)); list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml" , NULL)); #ifndef _WIN32 list = g_list_append(list,g_strdup("/etc/navit/navit.xml")); #endif } li = list; for (;;) { if (li == NULL) { // We have not found an existing config file from all possibilities dbg(0,_("No config file navit.xml, navit.xml.local found\n")); return 1; } // Try the next config file possibility from the list config_file = li->data; if (file_exists(config_file)) break; else g_free(config_file); li = g_list_next(li); } if (!config_load(config_file, &error)) { dbg(0, _("Error parsing '%s': %s\n"), config_file, error ? error->message : ""); } else { dbg(0, _("Using '%s'\n"), config_file); } while (li) { g_free(li->data); li = g_list_next(li); } g_list_free(list); if (! config_get_attr(config, attr_navit, &navit, NULL) && !config_empty_ok) { dbg(0, _("No instance has been created, exiting\n")); exit(1); } event_main_loop_run(); #ifndef HAVE_API_ANDROID debug_finished(); #endif return 0; }
int main(int argc, char **argv) { GError *error = NULL; char *config_file = NULL; char *s; int l; #ifndef _WIN32 signal(SIGCHLD, sigchld); #endif setenv("LC_NUMERIC","C",1); setlocale(LC_ALL,""); setlocale(LC_NUMERIC,"C"); if (file_exists("navit.c") || file_exists("navit.o")) { char buffer[PATH_MAX]; printf(_("Running from source directory\n")); getcwd(buffer, PATH_MAX); setenv("NAVIT_PREFIX", buffer, 0); setenv("NAVIT_LIBDIR", buffer, 0); setenv("NAVIT_SHAREDIR", buffer, 0); setenv("NAVIT_LIBPREFIX", "*/.libs/", 0); s=g_strdup_printf("%s/../locale", buffer); setenv("NAVIT_LOCALEDIR", s, 0); g_free(s); } else { if (!getenv("NAVIT_PREFIX")) { l=strlen(argv[0]); if (l > 10 && !strcmp(argv[0]+l-10,"/bin/navit")) { s=g_strdup(argv[0]); s[l-10]='\0'; if (strcmp(s, PREFIX)) printf(_("setting '%s' to '%s'\n"), "NAVIT_PREFIX", s); setenv("NAVIT_PREFIX", s, 0); g_free(s); } else setenv("NAVIT_PREFIX", PREFIX, 0); } #ifdef _WIN32 s=g_strdup_printf("locale"); #else s=g_strdup_printf("%s/share/locale", getenv("NAVIT_PREFIX")); #endif setenv("NAVIT_LOCALEDIR", s, 0); g_free(s); #ifdef _WIN32 s=g_strdup_printf("."); #else s=g_strdup_printf("%s/share/navit", getenv("NAVIT_PREFIX")); #endif setenv("NAVIT_SHAREDIR", s, 0); g_free(s); s=g_strdup_printf("%s/lib/navit", getenv("NAVIT_PREFIX")); setenv("NAVIT_LIBDIR", s, 0); g_free(s); } bindtextdomain(PACKAGE, getenv("NAVIT_LOCALEDIR")); bind_textdomain_codeset (PACKAGE, "UTF-8"); textdomain(PACKAGE); debug_init(); #ifndef USE_PLUGINS extern void builtin_init(void); builtin_init(); #endif #if 0 /* handled in gui/gtk */ gtk_set_locale(); gtk_init(&argc, &argv); gdk_rgb_init(); #endif s = getenv("NAVIT_WID"); if (s) { setenv("SDL_WINDOWID", s, 0); } route_init(); navigation_init(); config_file=NULL; if (argc > 1) config_file=argv[1]; if (! config_file) { config_file=g_strjoin(NULL,get_home_directory(), "/.navit/navit.xml" , NULL); if (!file_exists(config_file)) { g_free(config_file); config_file=NULL; } } if (! config_file) { if (file_exists("navit.xml.local")) config_file="navit.xml.local"; } if (! config_file) { if (file_exists("navit.xml")) config_file="navit.xml"; } if (! config_file) { config_file=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml.local" , NULL); if (!file_exists(config_file)) { g_free(config_file); config_file=NULL; } } if (! config_file) { config_file=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml" , NULL); if (!file_exists(config_file)) { g_free(config_file); config_file=NULL; } } if (!config_file) { printf(_("No config file navit.xml, navit.xml.local found\n")); exit(1); } if (!config_load(config_file, &error)) { printf(_("Error parsing '%s': %s\n"), config_file, error->message); exit(1); } else { printf(_("Using '%s'\n"), config_file); } if (! navit) { printf(_("No instance has been created, exiting\n")); exit(1); } if (main_loop_gui) { gui_run_main_loop(main_loop_gui); } else { #ifdef USE_GTK_MAIN_LOOP gtk_main(); #else loop = g_main_loop_new (NULL, TRUE); if (g_main_loop_is_running (loop)) { g_main_loop_run (loop); } #endif } return 0; }