Ejemplo n.º 1
0
void setup(){
    uart_init(UART_BAUD_SELECT_DOUBLE_SPEED(57600, F_CPU));
    //FIXME what was the following line for?
    //DDRD |= 0x02;
    pwm_setup();
    l7seg_setup();
    r0ketbeam_setup();
    input_setup();
    led_setup();
    config_setup();
    sei();
}
Ejemplo n.º 2
0
int main(int argc,char *argv[])
{

	////////////////////////////////////////////////////////////////////////
	// Native Language Support Int
	////////////////////////////////////////////////////////////////////////
	#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	#endif
	////////////////////////////////////////////////////////////////////////
	char* fchar = (char*) argv[1];
	set_path_self(argv[0]);
	////////////////////////////////////////////////////////////////////////
	/* GTK INIT */
	////////////////////////////////////////////////////////////////////////
	gtk_init(&argc,&argv);
 	////////////////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////////////////
	/* PATH SELF SET */
	////////////////////////////////////////////////////////////////////////
	//set_path_self(g_strdup(argv[0])); 
 	////////////////////////////////////////////////////////////////////////

	
	////////////////////////////////////////////////////////////////////////
	/* CONFIG Setup */
	////////////////////////////////////////////////////////////////////////
	config_setup();
	ui_unity_init();
	
	tpad_fp_init();
	gtk_widget_show_all(GTK_WIDGET(tpad_new_ui()));	
	new_file();
    	//////////////////////////////////////////////////////////////////////// 
	// handle cl arguments
	////////////////////////////////////////////////////////////////////////
	if (argc > 2){
		int i=0;
		for (i = 2; i < argc; i += 1) new_thread_tpad ( g_strdup(argv[i]));
	}
	if(argc > 1) {
		show_file(g_strdup(fchar));
	}
	////////////////////////////////////////////////////////////////////////
	/* GTK MAIN */
	////////////////////////////////////////////////////////////////////////
    	gtk_main();
	////////////////////////////////////////////////////////////////////////
	return (0);
}
Ejemplo n.º 3
0
static int general_setup(void)
{
	int i;

	maths_setup();
	config_setup();

	screen_w = cfgnum("screen.width", 800);
	screen_h = cfgnum("screen.height", 600);
	if (cfgnum("fullscreen", 0) == 1)
		displayflags |= SDL_FULLSCREEN;

	sprite_global.opt_alpha = cfgnum("alpha", 0);

	i = SDL_Init(SDL_INITFLAGS);
	assert(i == 0);

	atexit(atexit_cleanup);

	SDL_WM_SetCaption(VERSIONSTRING, 0);

	sprite_global.display = SDL_SetVideoMode(screen_w, screen_h, 0, displayflags);
	assert(sprite_global.display);
	SDL_ShowCursor(SDL_DISABLE);

	if (cfgnum("sound", 0) == 1)
	{
		sound_setup();
		/* place the ear on the ground, in the center */
		sound_move_ear(screen_w / 2, screen_h);
	}
	sprite_setup();
	text_setup();
	console_setup();
	console_set_pos(9, 254);
	console_load_bg(path_to_data("console-bg.png"));
	sprite_types_setup();

	char bg1[255];
	char bg2[255];
	sprintf(bg1,"data/bg%d.png",screen_w);
	sprintf(bg2,"data/bgmask%d.png",screen_w);

	sprite_background_load(bg1, bg2);

	level_setup();
	winds_setup();

	return 0;
}
Ejemplo n.º 4
0
Archivo: config.c Proyecto: Remmy/hopm
/* Load configuration from filename, via flex/bison parser */
void
config_load(const char *filename)
{
  config_init();
  config_setup();  /* Setup/clear current configuration */

  log_printf("CONFIG -> Loading %s", filename);

  if ((yyin = fopen(filename, "r")) == NULL)
  {
    log_printf("CONFIG -> Error opening %s: %s", filename, strerror(errno));
    exit(EXIT_FAILURE);
  }

  yyparse();
  fclose(yyin);

  scan_init();     /* Initialize the scanners once we have the configuration */
  stats_init();    /* Initialize stats (UPTIME) */
  firedns_init();  /* Initialize adns */
}
Ejemplo n.º 5
0
int
main(int argc, char *argv[])
{
	time_t start;
	int ch, onerun, reps;
	const char *config, *home;

	config = NULL;

#ifdef _WIN32
	g.progname = "t_format.exe";
#else
	if ((g.progname = strrchr(argv[0], DIR_DELIM)) == NULL)
		g.progname = argv[0];
	else
		++g.progname;
#endif

#if 0
	/* Configure the GNU malloc for debugging. */
	(void)setenv("MALLOC_CHECK_", "2", 1);
#endif
#if 0
	/* Configure the FreeBSD malloc for debugging. */
	(void)setenv("MALLOC_OPTIONS", "AJ", 1);
#endif

	/* Track progress unless we're re-directing output to a file. */
	g.c_quiet = isatty(1) ? 0 : 1;

	/* Set values from the command line. */
	home = NULL;
	onerun = 0;
	while ((ch = __wt_getopt(
	    g.progname, argc, argv, "1C:c:H:h:Llqrt:")) != EOF)
		switch (ch) {
		case '1':			/* One run */
			onerun = 1;
			break;
		case 'C':			/* wiredtiger_open config */
			g.config_open = __wt_optarg;
			break;
		case 'c':			/* Configuration from a file */
			config = __wt_optarg;
			break;
		case 'H':
			g.helium_mount = __wt_optarg;
			break;
		case 'h':
			home = __wt_optarg;
			break;
		case 'L':			/* Re-direct output to a log */
			/*
			 * The -l option is a superset of -L, ignore -L if we
			 * have already configured logging for operations.
			 */
			if (g.logging == 0)
				g.logging = LOG_FILE;
			break;
		case 'l':			/* Turn on operation logging */
			g.logging = LOG_OPS;
			break;
		case 'q':			/* Quiet */
			g.c_quiet = 1;
			break;
		case 'r':			/* Replay a run */
			g.replay = 1;
			break;
		default:
			usage();
		}
	argc -= __wt_optind;
	argv += __wt_optind;

	/* Initialize the global RNG. */
	testutil_check(__wt_random_init_seed(NULL, &g.rnd));

	/* Set up paths. */
	path_setup(home);

	/* If it's a replay, use the home directory's CONFIG file. */
	if (g.replay) {
		if (config != NULL)
			testutil_die(EINVAL, "-c incompatible with -r");
		if (access(g.home_config, R_OK) != 0)
			testutil_die(ENOENT, "%s", g.home_config);
		config = g.home_config;
	}

	/*
	 * If we weren't given a configuration file, set values from "CONFIG",
	 * if it exists.
	 *
	 * Small hack to ignore any CONFIG file named ".", that just makes it
	 * possible to ignore any local CONFIG file, used when running checks.
	 */
	if (config == NULL && access("CONFIG", R_OK) == 0)
		config = "CONFIG";
	if (config != NULL && strcmp(config, ".") != 0)
		config_file(config);

	/*
	 * The rest of the arguments are individual configurations that modify
	 * the base configuration.
	 */
	for (; *argv != NULL; ++argv)
		config_single(*argv, 1);

	/*
	 * Multithreaded runs can be replayed: it's useful and we'll get the
	 * configuration correct.  Obviously the order of operations changes,
	 * warn the user.
	 */
	if (g.replay && !SINGLETHREADED)
		printf("Warning: replaying a threaded run\n");

	/*
	 * Single-threaded runs historically exited after a single replay, which
	 * makes sense when you're debugging, leave that semantic in place.
	 */
	if (g.replay && SINGLETHREADED)
		g.c_runs = 1;

	/*
	 * Let the command line -1 flag override runs configured from other
	 * sources.
	 */
	if (onerun)
		g.c_runs = 1;

	/*
	 * Initialize locks to single-thread named checkpoints and backups, last
	 * last-record updates, and failures.
	 */
	testutil_check(pthread_rwlock_init(&g.append_lock, NULL));
	testutil_check(pthread_rwlock_init(&g.backup_lock, NULL));
	testutil_check(pthread_rwlock_init(&g.checkpoint_lock, NULL));
	testutil_check(pthread_rwlock_init(&g.death_lock, NULL));

	printf("%s: process %" PRIdMAX "\n", g.progname, (intmax_t)getpid());
	while (++g.run_cnt <= g.c_runs || g.c_runs == 0 ) {
		startup();			/* Start a run */

		config_setup();			/* Run configuration */
		config_print(0);		/* Dump run configuration */
		key_len_setup();		/* Setup keys */

		start = time(NULL);
		track("starting up", 0ULL, NULL);

#ifdef HAVE_BERKELEY_DB
		if (SINGLETHREADED)
			bdb_open();		/* Initial file config */
#endif
		wts_open(g.home, true, &g.wts_conn);
		wts_init();

		wts_load();			/* Load initial records */
		wts_verify("post-bulk verify");	/* Verify */

		/*
		 * If we're not doing any operations, scan the bulk-load, copy
		 * the statistics and we're done. Otherwise, loop reading and
		 * operations, with a verify after each set.
		 */
		if (g.c_timer == 0 && g.c_ops == 0) {
			wts_read_scan();		/* Read scan */
			wts_stats();			/* Statistics */
		} else
			for (reps = 1; reps <= FORMAT_OPERATION_REPS; ++reps) {
				wts_read_scan();	/* Read scan */

							/* Operations */
				wts_ops(reps == FORMAT_OPERATION_REPS);

				/*
				 * Copy out the run's statistics after the last
				 * set of operations.
				 *
				 * XXX
				 * Verify closes the underlying handle and
				 * discards the statistics, read them first.
				 */
				if (reps == FORMAT_OPERATION_REPS)
					wts_stats();

							/* Verify */
				wts_verify("post-ops verify");
			}

		track("shutting down", 0ULL, NULL);
#ifdef HAVE_BERKELEY_DB
		if (SINGLETHREADED)
			bdb_close();
#endif
		wts_close();

		/*
		 * Rebalance testing.
		 */
		wts_rebalance();

		/*
		 * If single-threaded, we can dump and compare the WiredTiger
		 * and Berkeley DB data sets.
		 */
		if (SINGLETHREADED)
			wts_dump("standard", 1);

		/*
		 * Salvage testing.
		 */
		wts_salvage();

		/* Overwrite the progress line with a completion line. */
		if (!g.c_quiet)
			printf("\r%78s\r", " ");
		printf("%4d: %s, %s (%.0f seconds)\n",
		    g.run_cnt, g.c_data_source,
		    g.c_file_type, difftime(time(NULL), start));
		fflush(stdout);
	}

	/* Flush/close any logging information. */
	fclose_and_clear(&g.logfp);
	fclose_and_clear(&g.randfp);

	config_print(0);

	testutil_check(pthread_rwlock_destroy(&g.append_lock));
	testutil_check(pthread_rwlock_destroy(&g.backup_lock));
	testutil_check(pthread_rwlock_destroy(&g.checkpoint_lock));
	testutil_check(pthread_rwlock_destroy(&g.death_lock));

	config_clear();

	return (EXIT_SUCCESS);
}
Ejemplo n.º 6
0
int
main(int argc, char *argv[])
{
	int ch, reps, ret;
	const char *config, *home;

	config = NULL;

	if ((g.progname = strrchr(argv[0], '/')) == NULL)
		g.progname = argv[0];
	else
		++g.progname;

#if 0
	/* Configure the GNU malloc for debugging. */
	(void)setenv("MALLOC_CHECK_", "2", 1);
#endif
#if 0
	/* Configure the FreeBSD malloc for debugging. */
	(void)setenv("MALLOC_OPTIONS", "AJ", 1);
#endif

	/* Track progress unless we're re-directing output to a file. */
	g.track = isatty(STDOUT_FILENO) ? 1 : 0;

	/* Set values from the command line. */
	home = NULL;
	while ((ch = getopt(argc, argv, "1C:c:h:Llqrt:")) != EOF)
		switch (ch) {
		case '1':			/* One run */
			g.c_runs = 1;
			break;
		case 'C':			/* wiredtiger_open config */
			g.config_open = optarg;
			break;
		case 'c':			/* Configuration from a file */
			config = optarg;
			break;
		case 'h':
			home = optarg;
			break;
		case 'L':			/* Re-direct output to a log */
			/*
			 * The -l option is a superset of -L, ignore -L if we
			 * have already configured logging for operations.
			 */
			if (g.logging == 0)
				g.logging = LOG_FILE;
			break;
		case 'l':			/* Turn on operation logging */
			g.logging = LOG_OPS;
			break;
		case 'q':			/* Quiet */
			g.track = 0;
			break;
		case 'r':			/* Replay a run */
			g.replay = 1;
			break;
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	/*
	 * If we weren't given a configuration file, set values from "CONFIG",
	 * if it exists.
	 *
	 * Small hack to ignore any CONFIG file named ".", that just makes it
	 * possible to ignore any local CONFIG file, used when running checks.
	 */
	if (config == NULL && access("CONFIG", R_OK) == 0)
		config = "CONFIG";
	if (config != NULL && strcmp(config, ".") != 0)
		config_file(config);

	/*
	 * The rest of the arguments are individual configurations that modify
	 * the base configuration.
	 */
	for (; *argv != NULL; ++argv)
		config_single(*argv, 1);

	/*
	 * Multithreaded runs can be replayed: it's useful and we'll get the
	 * configuration correct.  Obviously the order of operations changes,
	 * warn the user.
	 */
	if (g.replay && !SINGLETHREADED)
		printf("Warning: replaying a threaded run\n");

	/*
	 * Single-threaded runs historically exited after a single replay, which
	 * makes sense when you're debugging, leave that semantic in place.
	 */
	if (g.replay && SINGLETHREADED)
		g.c_runs = 1;

	/* Use line buffering on stdout so status updates aren't buffered. */
	(void)setvbuf(stdout, NULL, _IOLBF, 0);

	/*
	 * Initialize locks to single-thread named checkpoints and hot backups
	 * and to single-thread last-record updates.
	 */
	if ((ret = pthread_rwlock_init(&g.append_lock, NULL)) != 0)
		die(ret, "pthread_rwlock_init: append lock");
	if ((ret = pthread_rwlock_init(&g.backup_lock, NULL)) != 0)
		die(ret, "pthread_rwlock_init: hot-backup lock");

	/* Clean up on signal. */
	(void)signal(SIGINT, onint);

	/* Seed the random number generator. */
	srand((u_int)(0xdeadbeef ^ (u_int)time(NULL)));

	/* Set up paths. */
	path_setup(home);

	printf("%s: process %" PRIdMAX "\n", g.progname, (intmax_t)getpid());
	while (++g.run_cnt <= g.c_runs || g.c_runs == 0 ) {
		startup();			/* Start a run */

		config_setup();			/* Run configuration */
		config_print(0);		/* Dump run configuration */
		key_len_setup();		/* Setup keys */

		track("starting up", 0ULL, NULL);
		if (SINGLETHREADED)
			bdb_open();		/* Initial file config */
		wts_open(g.home, 1, &g.wts_conn);
		wts_create();

		wts_load();			/* Load initial records */
		wts_verify("post-bulk verify");	/* Verify */

						/* Loop reading & operations */
		for (reps = 0; reps < 3; ++reps) {
			wts_read_scan();	/* Read scan */

			if (g.c_ops != 0)	/* Random operations */
				wts_ops();

			/*
			 * Statistics.
			 *
			 * XXX
			 * Verify closes the underlying handle and discards the
			 * statistics, read them first.
			 */
			if (g.c_ops == 0 || reps == 2)
				wts_stats();

						/* Verify */
			wts_verify("post-ops verify");

			/*
			 * If no operations scheduled, quit after a single
			 * read pass.
			 */
			if (g.c_ops == 0)
				break;
		}

		track("shutting down", 0ULL, NULL);
		if (SINGLETHREADED)
			bdb_close();
		wts_close();

		/*
		 * If single-threaded, we can dump and compare the WiredTiger
		 * and Berkeley DB data sets.
		 */
		if (SINGLETHREADED)
			wts_dump("standard", 1);

		/*
		 * If no records are deleted, we can salvage the file and test
		 * the result.  (The problem with deleting records is salvage
		 * restores deleted records if a page splits leaving a deleted
		 * record on one side of the split.)
		 *
		 * Salvage, verify the salvaged files, then dump (comparing
		 * against the Berkeley DB data set again, if possible).
		 */
		if (g.c_delete_pct == 0) {
			wts_open(g.home, 1, &g.wts_conn);
			wts_salvage();
			wts_verify("post-salvage verify");
			wts_close();

			wts_dump("salvage", SINGLETHREADED);
		}

		/* Overwrite the progress line with a completion line. */
		if (g.track)
			printf("\r%78s\r", " ");
		printf("%4d: %s, %s\n",
		    g.run_cnt, g.c_data_source, g.c_file_type);
	}

	/* Flush/close any logging information. */
	if (g.logfp != NULL)
		(void)fclose(g.logfp);
	if (g.rand_log != NULL)
		(void)fclose(g.rand_log);

	config_print(0);

	if ((ret = pthread_rwlock_destroy(&g.append_lock)) != 0)
		die(ret, "pthread_rwlock_destroy: append lock");
	if ((ret = pthread_rwlock_destroy(&g.backup_lock)) != 0)
		die(ret, "pthread_rwlock_destroy: hot-backup lock");

	config_clear();

	return (EXIT_SUCCESS);
}
Ejemplo n.º 7
0
// handle_serial_paket()
// verarbeitet "paket" mit len optionalen Daten (Header NICHT mitgerechnet).
__inline void handle_pc_paket(int len) {
  answer.head.len = 0;			// no answer.
  last_pc_activity = Get_system_register(AVR32_COUNT);
  switch (rxdatapacket.head.cmd) {	// Kommando-Byte
  case RPTR_GET_STATUS:
    if (len==1) {			// request
      update_status();
      answer.data[PKT_PARAM_IDX+0] = status_control;
      answer.data[PKT_PARAM_IDX+1] = status_state;
      answer.data[PKT_PARAM_IDX+2] = rptr_tx_state;
      answer.data[PKT_PARAM_IDX+3] = VoiceRxBufSize;
      answer.data[PKT_PARAM_IDX+4] = VoiceTxBufSize;
      answer.data[PKT_PARAM_IDX+5] = rptr_get_unsend();	// unsend frames left (incl. gaps)
      answer.head.len = 7;
    } else if (len==2) {		// enable/disable
      U8 new_control = (status_control & 0xF0) | (rxdatapacket.data[PKT_PARAM_IDX] & 0x0F);
      if ((new_control^status_control) & STA_RXENABLE_MASK) {
	if (new_control & STA_RXENABLE_MASK) {
	  trx_receive();			// set receiving
	  rptr_receive();			// enable receiving
	} else {
	  idle_timer_start();			// disable receiving
	}
      } // fi sw RX
      if ( (new_control^status_control) & STA_TXENABLE_MASK) {
        // Enable / Disable selected output of modulation DAC
        dac_power_ctrl(new_control&STA_TXENABLE_MASK);
	// Enable / Disable Reference-DAC MAX5820
        set_dac_power_mode((new_control&STA_TXENABLE_MASK)?TWI_DAC_POWERUP:TWI_DAC_POWERDOWN);
      } // fi sw TX
      status_control = new_control;
      pc_send_byte(ACK);
    } else {				// invalid - more than one parameter byte
      pc_send_byte(NAK);
    }
    break;
  case RPTR_GET_VERSION:
    answer.data[PKT_PARAM_IDX+0] = FIRMWAREVERSION & 0xFF;
    answer.data[PKT_PARAM_IDX+1] = FIRMWAREVERSION >> 8;
    memcpy(answer.data+PKT_PARAM_IDX+2, VERSION_IDENT, sizeof(VERSION_IDENT));
    answer.head.len = sizeof(VERSION_IDENT)+3-1;	// cut String-Terminator /0
    break;
  case RPTR_GET_SERIAL:
    memcpy(answer.data+PKT_PARAM_IDX, (void *)SERIALNUMBER_ADDRESS, 4);
    answer.head.len = 5;
    break;
  case RPTR_GET_CONFIG:
    if (len==1) {			// request all config
      char *nextblock = cfg_read_c0(answer.data+PKT_PARAM_IDX);
      nextblock = cfg_read_c1(nextblock);
      //...
      answer.head.len = nextblock - answer.data - 3;
    } else if (len==2) {		// request a single block
      switch(rxdatapacket.data[PKT_PARAM_IDX]) {
      case 0xC0:
	cfg_read_c0(answer.data+PKT_PARAM_IDX);
	answer.head.len = sizeof(CONFIG_C0)+3;
	break;
      case 0xC1:
	cfg_read_c1(answer.data+PKT_PARAM_IDX);
 	answer.head.len = CONFIG_C1_SIZE+3;
 	break;
     default:
	pc_send_byte(NAK);
	break;
      }
    } else {
      pc_send_byte(NAK);
    }
    break;
  case RPTR_SET_CONFIG:
    if (config_setup(rxdatapacket.data+PKT_PARAM_IDX, len-1)) {
      pc_send_byte(ACK);
    } else {
      pc_send_byte(NAK);
    }
    break;
  case RPTR_START:		// early Turn-On xmitter, if configured a long TXD
    if ((status_control & STA_TXENABLE_MASK) && (len==3)) {
      if (rxdatapacket.data[PKT_PARAM_IDX] != current_txid) {
	rptr_transmit_preamble(); // PTTon, wait for a header to start TX
	if (rptr_tx_state <= RPTRTX_preamble)	// starts w/o interrupting a running transmission
	  current_txid = rxdatapacket.data[PKT_PARAM_IDX];
      }
    } else
      pc_send_byte(NAK);
    break;
  case RPTR_HEADER:		// start transmitting TXDelay-Preamble-Start-Header
    if (rptr_tx_state != RPTRTX_header)	// update only, if not transmitting just this moment
      rptr_init_header((tds_header *)&rxdatapacket.data[PKT_PARAM_IDX+4]);
    if (status_control & STA_TXENABLE_MASK) {
      if ((rptr_tx_state <= RPTRTX_preamble) || (rxdatapacket.data[PKT_PARAM_IDX] != current_txid)) {
        rptr_transmit();		// Turn on Xmitter
        current_txid = rxdatapacket.data[PKT_PARAM_IDX];
      } // fi
      // -> ignore a HEADER msg with same TXID while sending
      add_icom_voice_reset();
    } else
      pc_send_byte(NAK);
    // keep 2 bytes for future use, keep layout identical to RX
    break;
  case RPTR_RXSYNC:		// start transmitting TXDelay-Preamble-Start-Header
    if (rptr_tx_state != RPTRTX_header)	// update only, if not transmitting just this moment
      rptr_replacement_header();
    if (status_control & STA_TXENABLE_MASK) {
      if ((rptr_tx_state <= RPTRTX_preamble) || (rxdatapacket.data[PKT_PARAM_IDX] != current_txid)) {
	rptr_transmit();	// Turn on Xmitter only if PTT off
	current_txid = rxdatapacket.data[PKT_PARAM_IDX];
      } // if idle
      // (transmission use last header)
      add_icom_voice_reset();
    } else
      pc_send_byte(NAK);
    break;
  case RPTR_DATA:		// transmit data (voice and slowdata or sync)
    if (rxdatapacket.data[PKT_PARAM_IDX] == current_txid)
      add_icom_voice_2_rptr(rxdatapacket.data[PKT_PARAM_IDX+1], &rxdatapacket.data[PKT_PARAM_IDX+4]);
      //add_multi_voice_2_rptr(len);
    break;
  case RPTR_EOT:		// end transmission with EOT tail
    if (len == 3) {
      if (rxdatapacket.data[PKT_PARAM_IDX] == current_txid)
        rptr_endtransmit(rxdatapacket.data[PKT_PARAM_IDX+1]);
    } else
      rptr_endtransmit(0xFF);	// stop after buffer is empty
    break;
  case RPTR_SET_SPECIALFUNCT:
    handle_special_func_cmd(len);
    break;
  default:
    pc_send_byte(NAK);
    break;
  } // hctiws
  if ((answer.head.len > 0)&&(answer.head.len<(PAKETBUFFERSIZE-4))) {
    U32 anslen = answer.head.len+5;
    answer.head.id  = FRAMESTARTID;
    answer.head.cmd = 0x80|rxdatapacket.head.cmd;
    answer.head.len = swap16(answer.head.len);
    append_crc_ccitt(answer.data, anslen);
    data_transmit(answer.data, anslen);
  } // fi send
}