Exemple #1
0
static bool init_common(int *log_level, const Settings &cmd_args, int argc, char *argv[])
{
	startup_message();
	set_default_settings(g_settings);

	// Initialize sockets
	sockets_init();
	atexit(sockets_cleanup);

	if (!read_config_file(cmd_args))
		return false;

	init_debug_streams(log_level, cmd_args);

	// Initialize random seed
	srand(time(0));
	mysrand(time(0));

	// Initialize HTTP fetcher
	httpfetch_init(g_settings->getS32("curl_parallel_limit"));

#ifdef _MSC_VER
	init_gettext((porting::path_share + DIR_DELIM + "locale").c_str(),
		g_settings->get("language"), argc, argv);
#else
	init_gettext((porting::path_share + DIR_DELIM + "locale").c_str(),
		g_settings->get("language"));
#endif

	return true;
}
Exemple #2
0
static bool init_common(const Settings &cmd_args, int argc, char *argv[])
{
    startup_message();
    set_default_settings(g_settings);

    // Initialize sockets
    sockets_init();
    atexit(sockets_cleanup);

    if (!read_config_file(cmd_args))
        return false;

    init_log_streams(cmd_args);

    // Initialize random seed
    srand(time(0));
    mysrand(time(0));

    // Initialize HTTP fetcher
    httpfetch_init(g_settings->getS32("curl_parallel_limit"));

    init_gettext(porting::path_locale.c_str(),
                 g_settings->get("language"), argc, argv);

    return true;
}
Exemple #3
0
void main()
{
	int tag;							//stores the RFID ID tag number	
	float dist;
	int ovf = 0;
	int count = 0;
	
	
	store();
		
	
	if (init())
		pm2_pstr("System Checksum Successful!\r\n");
	
	startup_message();
	
	//rfid read
	printf_fast("Present RFID Tag");
	
	pm2_pstr("Please Present Allowable RFID Tag\r\n");
	tag = check_RFID();

	pm2_pint16u(tag);
	pm2_pstr(" = ");
	print_tag(tag);								//prints the name of the tag, which is matched to the number being sent
	pm2_pstr(" RFID tag was detected\r\nNow Starting Central Operational Loop\r\n");
	lcd_home();	
	lcd_clear();
	
	
		
	
		
	

	
	gps_to_xbee(1);						//Enable GPS->Xbee
	//Central Operational loop		CCL
	while(1)
	{
				
		dist = getdist_Maxbot();
		inchtolcd(dist);
		//printf("hello\r\n");
		pm2_pint16u(dist);
		pm2_pstr("\"\r\n");
		
		
		
		if(((int)dist) < 26)
		{
			EMICinit(7, 4, 0);
			EMICspeak('S');
			EMICspeak('t');
			EMICspeak('o');
			EMICspeak('p');
			EMICnull();			
		}			
	}		
}
Exemple #4
0
int main(int argc, char **argv)
{
    time_seed = time(0);

    parse_parameters(argc, argv);

    if (getuid() == 0)
    {
        if (UID == -1)
            error("user not set");
        if (setgid(GID) != 0)
            error("Unable to drop group privileges");
        if (setuid(UID) != 0)
            error("Unable to drop user privileges");
    }

    if (BASEDIR == NULL)
        set_basedir();

    startup_message();

    int listen_socket, optval = 1;
    struct sockaddr_in server_address;

    listen_socket = create_socket();
    setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (const void *)&optval , sizeof(int));

    server_address = set_address(server_address);
    bind_to_port(listen_socket, server_address);

    if (DAEMON)
    {
        pid_t pid;

        pid = fork();
        if (pid == -1)
            error("Failed to fork");
        if (pid == 0)
            while (1) perform_connection(listen_socket);
    }
    else
        while (1) perform_connection(listen_socket);

    return 0;
}
Exemple #5
0
static bool init_common(int *log_level, const Settings &cmd_args, int argc, char *argv[])
{
	startup_message();
	set_default_settings(g_settings);

	// Initialize sockets
	sockets_init();
	atexit(sockets_cleanup);

	if (!read_config_file(cmd_args))
		return false;

	init_debug_streams(log_level, cmd_args);

	g_time_taker_enabled = g_settings->getU16("time_taker_enabled") ? g_settings->getU16("time_taker_enabled") : ((g_settings->getFloat("profiler_print_interval") || *log_level >= LMT_INFO) ? 100 : 0);

	int autoexit_ = 0;
	cmd_args.getS32NoEx("autoexit", autoexit_);
	g_profiler_enabled = g_settings->getFloat("profiler_print_interval") || autoexit_;

	// Initialize random seed
	srand(time(0));
	mysrand(time(0));

	// Initialize HTTP fetcher
	httpfetch_init(g_settings->getS32("curl_parallel_limit"));

#ifdef _MSC_VER
	init_gettext((porting::path_share + DIR_DELIM + "locale").c_str(),
		g_settings->get("language"), argc, argv);
#else
	init_gettext((porting::path_share + DIR_DELIM + "locale").c_str(),
		g_settings->get("language"));
#endif

#if defined(_WIN32)
	//Remove windows console window if settings request
	if (!g_settings->getBool("console_enabled"))
		FreeConsole();
#endif

	return true;
}
Exemple #6
0
//! You expected it: This routine is expected never to exit
void main (void)
{
    port_init();
    watchdog_init();
    timer_gpt3_init();
    adc_init();
    cursors_init();
    power_init();

    uart_init();

    /* enable interrupts. */
    EA = 1;

    get_board_id();
    startup_message();

    dump_xdata_sfr();
    gpio_check_IO_direction();
    dump_gpio();
    dump_mcs51();

tx_drain();  // oops, UART routines seem not yet clean

    print_states_ruler();
    print_states_enable = 1;
    print_states();
    print_states_enable = 0;

    save_old_states();
    states.number = 0;

    manufacturing_print_all();

    ow_init();
    timer1_init();
    battery_charging_table_init();

    LED_CHG_G_OFF();
    LED_CHG_R_OFF();
    LED_PWR_OFF();

    /* The main loop contains several state machines handling
       various subsystems on the EC.
       The idea is to have each subroutine return as quickly
       as it can (no busy wait unless for a _very_ short delay).
       Also the subroutines should be pretty much self contained.

       Unless it is noted _here_ no state machine should need
       more than xxx microseconds before returning control.
       When a state machine returns control it is expected to
       have the variables it is working on in a consistent
       state. Period (just in case it was missed:^)

       If it helps: you may want to think of the main loop
       as a round-robin cooperative scheduler without the
       overhead this usually implies. This works well if, well,
       if _all_ routines within the main loop cooperate well.
     */
    while(1)
    {
        STATES_TIMESTAMP();

        busy = handle_command();
        busy |= handle_cursors();
        handle_leds();
        handle_power();
        handle_ds2756_requests();
        handle_ds2756_readout();
        busy |= handle_battery_charging_table();

        watchdog_all_up_and_well |= WATCHDOG_MAIN_LOOP_IS_FINE;

        print_states();

        monitor();

        handle_debug();

        sleep_if_allowed();
    }
}