示例#1
0
int main( int argc , char * argv[] )
{
    kb_device_config_t * dev;
    kb_register_config_t * reg;
    knet_dev_t *koala;
    int rc;
    unsigned char buf[10];
    unsigned char a,b,c,d;

    kb_set_debug_level( 2 );

    if((rc = kb_init( argc , argv )) < 0 )
        return 1;

    kb_enum_section( print_section , 0);

    /*
    dev = kb_lookup_device( "KoreBot:XScaleVCoreDAC" );

    reg = kb_lookup_register( "KoreMotor:Filter");

    printf("%X\n" , reg );

    if (dev != NULL)
      printf("dev=ok\n");
    else
      printf("dev=KO\n");
    */

    return 0;
}
示例#2
0
void main( void )
{
	errno = 0;

	intr_disable();
	intr_init();
	hw_init();

	/* print a banner */
	printf( "%s %s\n", os_name, os_version );

	memory_init();
	device_init();
	vfs_init();

	/* new line after all initialisation messages */
	printf("\n");

	kb_init();
    console_init();

    intr_enable();

	/* fire up the shell! */
	for(;;) {
		shell_start();
		printf("Respawning shell\n");
	}
}
示例#3
0
文件: main.c 项目: MTN-Software/Panda
void kmain(u32 init_stack) {
    init_esp_start = init_stack;
    init_video();
    puts_color_str("Booting Panda OS ...\n", 0x0B);

    cli();
    time_init();
    gdt_init();
    idt_init();
    kb_init();
    mm_init();
    buf_init();
    file_init();
    inode_init();
    ide_init();
    task_init();
    timer_init();
    sysc_init();

    spawn(init_user);
    sti();
    init = 0;
    while(1) {
        if(!init) {
            printk("kernel running ...\n");
            init = 1;
        }
        sti();
        sched();
    }
}
int32
main(int32 argc, char *argv[])
{
    kb_t kb;
    stat_t *st;
    cmd_ln_t *config;

    print_appl_info(argv[0]);
    cmd_ln_appl_enter(argc, argv, "default.arg", arg);

    unlimit();

    config = cmd_ln_get();
    kb_init(&kb, config);
    st = kb.stat;
    fprintf(stdout, "\n");

    if (cmd_ln_str_r(config, "-ctl")) {
        /* When -ctlfile is speicified, corpus.c will look at -ctl_lm and
           -ctl_mllr to get the corresponding LM and MLLR for the utterance */
        st->tm = ctl_process(cmd_ln_str_r(config, "-ctl"),
                             cmd_ln_str_r(config, "-ctl_lm"),
                             cmd_ln_str_r(config, "-ctl_mllr"),
                             cmd_ln_int32_r(config, "-ctloffset"),
                             cmd_ln_int32_r(config, "-ctlcount"), utt_decode, &kb);
    }
    else if (cmd_ln_str_r(config, "-utt")) {
        /* When -utt is specified, corpus.c will wait for the utterance to
           change */
        st->tm = ctl_process_utt(cmd_ln_str_r(config, "-utt"),
                                 cmd_ln_int32_r(config, "-ctlcount"),
                                 utt_decode, &kb);

    }
    else {
        /* Is error checking good enough?" */
        E_FATAL("Both -utt and -ctl are not specified.\n");

    }

    if (kb.matchsegfp)
        fclose(kb.matchsegfp);
    if (kb.matchfp)
        fclose(kb.matchfp);

    stat_report_corpus(kb.stat);

    kb_free(&kb);

#if (! WIN32)
#if defined(_SUN4)
    system("ps -el | grep sphinx3_decode");
#else
    system("ps aguxwww | grep sphinx3_decode");
#endif
#endif

    cmd_ln_free_r(config);
    exit(0);
}
示例#5
0
int main( int argc , char * argv[] )
{
  int rc,ver;

  /* Set the libkorebot debug level - Highly recommended for development. */
  kb_set_debug_level(2);

  if((rc = kb_init( argc , argv )) < 0 )
    return 1;

  signal( SIGINT , ctrlc_handler );

  printf("K-Team GPIO Test Program\r\n");
  
  /* Initialize the GPIO and the PWM modules */
  kb_pwm_init();
  
  
  /* parse commands */
  while (!quitReq) {
    printf("\n> ");

    if ( fgets( buf , sizeof(buf) , stdin ) != NULL ) {
      buf[strlen(buf)-1] = '\0';
      kb_parse_command( buf , cmds , NULL);
    }
  }

}
示例#6
0
文件: kbtree.c 项目: derekguan/deSPI
int test_int(int N, const unsigned *data)
{
	int i, ret;
	intmap_t *p, d;
	kbtree_t(uint64_t) *h;
	kbitr_t itr;
	h = kb_init(uint64_t, KB_DEFAULT_SIZE);
	for (i = 0; i < N; ++i) {
		d.key = data[i]; d.value = i;
		if (kb_getp(uint64_t, h, &d) == 0) kb_putp(uint64_t, h, &d);
		else kb_delp(uint64_t, h, &d);
		d.key = data[i], d.value = 1;
		p = kb_getp(uint64_t, h, &d); // kb_get() also works
		// IMPORTANT: put() only works if key is absent
        	if (!p) kb_putp(uint64_t, h, &d);
        	else ++p->value;
	
	}
    // ordered tree traversal
	kb_itr_first(uint64_t, h, &itr); // get an iterator pointing to the first
	for (; kb_itr_valid(&itr); kb_itr_next(uint64_t, h, &itr)) { // move on
		p = &kb_itr_key(intmap_t, &itr);
		printf("%d\t%lu\n", p->value, p->key);
	}		


	kb_destroy(int, h);
	return 0;
}
示例#7
0
文件: live2.c 项目: wdebeaum/cabot
int
ld_init(live_decoder_t *decoder, int argc, char **argv)
{
  param_t fe_param;

  if (argc == 2) {
    /*
     * lgalescu: check if args need to be processed from file
     */
    parse_args_file(argv[1]);
  } else 
    cmd_ln_parse(arg_def, argc, argv);

  unlimit();
	
  /* some decoder parameter capturing
   * !!! NOTE - HARDCODED FOR NOW.  REPLACE WITH PARSE_ARG() ASAP !!!!
   */
  memset(decoder, 0, sizeof(live_decoder_t));
  kb_init(&decoder->kb);
  decoder->max_wpf = cmd_ln_int32 ("-maxwpf");;
  decoder->max_histpf = cmd_ln_int32 ("-maxhistpf");
  decoder->max_hmmpf = cmd_ln_int32 ("-maxhmmpf");
  decoder->phones_skip = cmd_ln_int32 ("-ptranskip");
  decoder->hmm_log = cmd_ln_int32("-hmmdump") ? stderr : NULL;
	
  decoder->kbcore = decoder->kb.kbcore;
  decoder->kb.uttid = decoder->uttid;
  decoder->hypsegs = 0;
  decoder->num_hypsegs = 0;
  decoder->hypstr_len = 0;
  decoder->hypstr[0] = '\0';
  decoder->features =
    feat_array_alloc(kbcore_fcb(decoder->kbcore), LIVEBUFBLOCKSIZE);
  decoder->ld_state = LD_STATE_IDLE;
	
  /* some front-end parameter capturing
   * !!! NOTE - HARDCODED FOR NOW.  REPLACE WITH PARSE_ARG() ASAP !!!!
   */
  memset(&fe_param, 0, sizeof(param_t));
  fe_param.SAMPLING_RATE = (float32)cmd_ln_int32 ("-samprate");
  fe_param.LOWER_FILT_FREQ = cmd_ln_float32("-lowerf");
  fe_param.UPPER_FILT_FREQ = cmd_ln_float32("-upperf");
  fe_param.NUM_FILTERS = cmd_ln_int32("-nfilt");
  fe_param.FRAME_RATE = cmd_ln_int32("-frate");
  fe_param.PRE_EMPHASIS_ALPHA = cmd_ln_float32("-alpha");
  fe_param.FFT_SIZE = cmd_ln_int32("-nfft");
  fe_param.WINDOW_LENGTH = cmd_ln_float32("-wlen");
	
  decoder->fe = fe_init(&fe_param);
  if (!decoder->fe) {
    E_WARN("Front end initialization fe_init() failed\n");
    return -1;
  }
	
  return 0;
}
示例#8
0
文件: live.c 项目: wdebeaum/cabot
/* This routine initializes decoder variables for live mode decoding */
void live_initialize_decoder(char *live_args)
{
    static kb_t live_kb;
    int32   maxcepvecs, maxhyplen, samprate, ceplen;
    param_t *fe_param;
    /*char const *uttIdNotDefined = "null";*/
    
    parse_args_file(live_args);
    unlimit();
    kb_init(&live_kb);
    kb = &live_kb;
    kbcore = kb->kbcore;
    
    kb->uttid = ckd_calloc(1000,sizeof(char));
    hmmdumpfp = cmd_ln_int32("-hmmdump") ? stderr : NULL;
    maxwpf    = cmd_ln_int32 ("-maxwpf");
    maxhistpf = cmd_ln_int32 ("-maxhistpf");
    maxhmmpf  = cmd_ln_int32 ("-maxhmmpf");
    ptranskip = cmd_ln_int32 ("-ptranskip");
    
    maxhyplen = cmd_ln_int32 ("-maxhyplen");
    if (!parthyp) 
        parthyp  = (partialhyp_t *) ckd_calloc(maxhyplen, sizeof(partialhyp_t));
    parthyplen = 0;
    
    fe_param = (param_t *) ckd_calloc(1, sizeof(param_t));
    samprate = cmd_ln_int32 ("-samprate");
    if (samprate != 8000 && samprate != 16000)
        E_FATAL("Sampling rate %d not supported. Must be 8000 or 16000\n",samprate);
    
    fe_param->SAMPLING_RATE = (float32) samprate;
    fe_param->LOWER_FILT_FREQ = cmd_ln_float32("-lowerf");
    fe_param->UPPER_FILT_FREQ = cmd_ln_float32("-upperf");
    fe_param->NUM_FILTERS = cmd_ln_int32("-nfilt");
    
    /* 20040413, by ARCHAN. Clear the hardwiring.
       Hmm. Many people say no to do this, I just can't take it. 
    */
    fe_param->FRAME_RATE = cmd_ln_int32("-frate");
    
    /*    fe_param->FRAME_RATE = 100; */
    fe_param->PRE_EMPHASIS_ALPHA = cmd_ln_float32("-alpha");
    fe_param->FFT_SIZE = cmd_ln_int32("-nfft");
    fe_param->WINDOW_LENGTH = cmd_ln_float32("-wlen");
    fe_param->doublebw=OFF;
    
    fe = fe_init(fe_param);
    if (!fe)
        E_FATAL("Front end initialization fe_init() failed\n");
    
    maxcepvecs = cmd_ln_int32 ("-maxcepvecs");
    ceplen = kbcore->fcb->cepsize;
    
    dummyframe = (float32*) ckd_calloc(1 * ceplen,sizeof(float32));	/*  */
}
示例#9
0
文件: main.c 项目: alaramedfox/avian
void init(void) 
{
   exceptions_init();
   hide_cursor();
   vga_setcolor(0x07);
   pic_init();
   idt_write_table();
   kb_init();         //Init keyboard driver
   floppy_init();
   lex_init();
   printf("\nSystem booted.\n\n");
}
示例#10
0
void kmain(void)
{
	const char *str = "This is a basic kernel, it will only echo back what you type with a limited keyboard charset.";
	reset(input);
	clear_screen();
	kprint(str);
	kprint_newline();

	idt_init();
	kb_init();

	while(1);
}
示例#11
0
void kmain(void)
{
	char *str = "my first kernel with keyboard support";
	clear_screen();
	kprint(str);
	kprint_newline();
	kprint_newline();

	idt_init();
	kb_init();

	while(1);
}
void init_all() {
  DDRC |= _BV(PC5);
  PORTC |= _BV(PC5);
  _delay_ms(5000);
  PORTC &= !_BV(PC5);

	uart_init(ISR_STATE);		
	kb_init();			
	pwm_init();			
	uart_tx_str("Booted up correctly!\r\n");	
	sei();		
	
}
示例#13
0
/*! kgripper_init initializes the KoreBot library
 * This function needs to be called BEFORE any other functions.
 * 
 * \param none
 *
 * \return A value:
 *       - <0 on error 
 *       - 0 on success 
 *
 */
int kgripper_init( void )
{
 int rc;

 /* First of all this function initializes the korebot library */
 
 if((rc = kb_init( 0 , NULL )) < 0 )
 {
 	/* Unable to initialize the korebot library */
	KB_ERROR("kb_kh3_init",KB_ERROR_KH3KBINIT);
	return KH3_ERROR_KBINIT;
 }
}
/* This routine initializes decoder variables for live mode decoding */
void live_initialize_decoder(char *live_args)
{
    static kb_t live_kb;
    int32   maxcepvecs, maxhyplen, samprate, ceplen;
    param_t *fe_param;
    char const *uttIdNotDefined = "null";

    parse_args_file(live_args);
    unlimit();
    kb_init(&live_kb);
    kb = &live_kb;
    kbcore = kb->kbcore;

    kb->uttid = ckd_salloc(uttIdNotDefined);
    hmmdumpfp = cmd_ln_int32("-hmmdump") ? stderr : NULL;
    maxwpf    = cmd_ln_int32 ("-maxwpf");
    maxhistpf = cmd_ln_int32 ("-maxhistpf");
    maxhmmpf  = cmd_ln_int32 ("-maxhmmpf");
    ptranskip = cmd_ln_int32 ("-ptranskip");

    maxhyplen = cmd_ln_int32 ("-maxhyplen");
    if (!parthyp) 
        parthyp  = (partialhyp_t *) ckd_calloc(maxhyplen, sizeof(partialhyp_t));

    fe_param = (param_t *) ckd_calloc(1, sizeof(param_t));
    samprate = cmd_ln_int32 ("-samprate");
    if (samprate != 8000 && samprate != 16000)
	E_FATAL("Sampling rate %s not supported. Must be 8000 or 16000\n",samprate);

    fe_param->SAMPLING_RATE = (float32) samprate;
    fe_param->LOWER_FILT_FREQ = cmd_ln_float32("-lowerf");
    fe_param->UPPER_FILT_FREQ = cmd_ln_float32("-upperf");
    fe_param->NUM_FILTERS = cmd_ln_int32("-nfilt");
    fe_param->FRAME_RATE = 100; /* HARD CODED TO 100 FRAMES PER SECOND */
    fe_param->PRE_EMPHASIS_ALPHA = (float32) 0.97;
    fe = fe_init(fe_param);
    if (!fe)
	E_FATAL("Front end initialization fe_init() failed\n");

    maxcepvecs = cmd_ln_int32 ("-maxcepvecs");
    ceplen = kbcore->fcb->cepsize;

    dummyframe = (float32*) ckd_calloc(1 * ceplen,sizeof(float32));	/*  */

#if defined(THRD)
    score_barrier = thread_barrier_init(NUM_THREADS);
    if (!score_barrier)
      E_FATAL("Cannot initialize score_barrier\n");
#endif
}
示例#15
0
void init(void) {
	PORTD |= _BV(SELECT);
	PORTD |= _BV(CYCLE);
	PORTD |= _BV(MENU);

	//LED used for debugging
	DDRB = 1 << PB0; // PB0 as output

	kb_init();
	usbInit();
	lcd_init(LCD_DISP_ON);
	lcd_puts("..");
	_delay_ms(20);

}
示例#16
0
文件: sf_test.c 项目: turingo/stm32ss
/*! SPI FLASH test !*/
void sf_test(void)
{
    uint8_t datas[6502];
    int kd;
    int flag;
    int i;

    kb_init();
    sp_init();
    sp_puts("SPI FLASH Test\r\n");
    sf_init();

    for(i = 0; i < 6502; i++) datas[i] = i;

    for(;;)
    {
		kb_scan();
        kd = kb_get(KB_DOWN);

        if(kd & KEY_0)
        {
            sp_puts("SPI FLASH write datas ... ");
            sf_write(0x8051, datas, 6502);
            sp_puts("OK\r\n");
        }

        if(kd & KEY_1)
        {
            for(i = 0; i < 6502; i++) datas[i] = 0;
            sp_puts("SPI FLASH read datas ... ");
            sf_read(0x8051, datas, 6502);
            sp_puts("OK\r\n");

            sp_puts("SPI FLASH verify datas ... ");
            flag = 0;
            for(i = 0; i < 6502; i++)
            {
                if(datas[i] != i)
                {
                    flag = 1;
                    break;
                }
            }
            if(flag == 0)   sp_puts("SUCCESS\r\n");
            else sp_puts("FAILED\r\n");                
        }
    }
}
示例#17
0
void main(void)
{
	lcd_init();

    kb_init();

	kb_cmd(0xED);
	kb_cmd(0x07);

	lcd_char(kb_getdata());

	kb_cmd(0xED);
	kb_cmd(0x03);

	while(1)
	{
		lcd_char(kb_getdata());
	}
}
示例#18
0
int main( int argc , char * argv[] )
{
  int rc,ver;

  /* Set the libkorebot debug level - Highly recommended for development. */
  kb_set_debug_level(2);

  if((rc = kb_init( argc , argv )) < 0 )
    return 1;

  signal( SIGINT , ctrlc_handler );

  printf("K-Team KoreIO Test Program\r\n");
  
  koreio = knet_open( "KoreIOLE:Board", KNET_BUS_ANY, 0 , NULL );
  if(!koreio)
  {
    printf("Cannot open KoreIO device trying alternate address\r\n");
    koreio = knet_open( "KoreIOLE:AltBoard", KNET_BUS_ANY, 0 , NULL );
    if(!koreio)
    {
      printf("Cannot open KoreIO device\r\n");
      return 1;
    }
  }

  /* Get and display the koreio firmware version */
  kio_GetFWVersion(koreio,&ver);

  printf("KoreIO firmware %d.%d\r\n", (ver&0x000000F0)>>4, (ver&0x0000000F));

  /* parse commands */
  while (!quitReq) {
    printf("\n> ");

    if ( fgets( buf , sizeof(buf) , stdin ) != NULL ) {
      buf[strlen(buf)-1] = '\0';
      kb_parse_command( buf , cmds , NULL);
    }
  }

  knet_close( koreio );
}
示例#19
0
/**
 * Initialize the templ theme
 * @param hue [0..360] hue value from HSV color space to define the theme's base color
 * @param font pointer to a font (NULL to use the default)
 * @return pointer to the initialized theme
 */
lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t *font)
{
    if(font == NULL) font = LV_FONT_DEFAULT;

    _hue = hue;
    _font = font;

    /*For backward compatibility initialize all theme elements with a default style */
    uint16_t i;
    lv_style_t **style_p = (lv_style_t**) &theme;
    for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
        *style_p = &def;
        style_p++;
    }

    basic_init();
    cont_init();
    btn_init();
    label_init();
    img_init();
    line_init();
    led_init();
    bar_init();
    slider_init();
    sw_init();
    lmeter_init();
    gauge_init();
    chart_init();
    cb_init();
    btnm_init();
    kb_init();
    mbox_init();
    page_init();
    ta_init();
    list_init();
    ddlist_init();
    roller_init();
    tabview_init();
    win_init();

    return &theme;
}
int main()
{
  kb_init(&keyboard);
  stb_fake_model_init(&model);

  gl_view_init(&view);

  ctrl_init(&ctrl);
  ctrl_set_view(&view);
  ctrl_set_model(&model);

  kb_set_callback(ctrl.handler);

  view.start();

  ctrl.start();
  keyboard.start();
	model.deinit();
	puts("finish");
}
示例#21
0
int main()
{
//Start video driver (must always be before loading message)
    mm_init();
    pg_init();
    real_init();
    video_init();
    video_setdriver(video_vgatext_getdriver(),0);

//Put loading message
    cli_puts("ArcaneOS Loading...\n");

//Setup kernel
    gdt_init();
    idt_init();
    isr_init();
    irq_init();
    timer_init();
    kb_init();
    ui_init();
    cpuid_init();
    cmos_init();
    rtc_init();
    acpi_init();
    power_init();
    mt_init();
    syscall_init();
    floppy_init();

    __asm__ __volatile__ ("sti");

//Enable ACPI
    acpi_enable();

//Create thread for ui
    mt_create_thread(mt_kernel_process,test,2);

//Endless loop to prevent bugs when all threads are sleeping
    for(;;)
        __asm__ __volatile__ ("hlt");
}
示例#22
0
文件: init.c 项目: RharryR/KiteOS
// Starts system
void 
init_system(multiboot_info_t* bi)
{
	// Start display
	vga_init();
	printk(" KiteOS V1.0 --- Initializing \n");
	// PIT-less wait to show user boot
	for(int i=0;i<64821125;i++);
	vga_color(0x3, 0x0);
	printk("-- STARTING LOWLEVEL KERNEL --\n");
	vga_color(0x5, 0x0);
	printk("!* Initiating GDT\n");
	gdt_init();
	printk("!* Initiating IDT\n");
	idt_init();
	printk("!* Installing Exceptions\n");
	isr_init();
	vga_color(0x4, 0x0);
	printk("*** ENTERTED PROTECTED MODE ***\n");
	vga_color(0x5, 0x0);
	printk("!* Initiating IRQ\n");
	irq_init();
	printk("!* Starting PIT\n");
	pit_init();
	printk("!* Starting RTC\n");
	rtc_init();
	printk("!* Restoring Interrupts\n");
	__asm__ __volatile__ ("sti");
	vga_color(0x3, 0x0);	
	printk("-- STARTING LOWLEVEL DRIVERS --\n");
	vga_color(0x5, 0x0);
	printk("!* Starting physical memory manager\n");
	kalloc_init((void*)bi->mmap_addr, (unsigned long)bi->mmap_length);
	printk("!* Starting keyboard driver\n");
	kb_init();
	printk("!* Starting IDE driver\n");
	ide_init(0x1F0, 0x3F6, 0x170, 0x366);
	vga_color(0x4, 0x0);
	printk("*** Initialized system successfully ***\n");
}
示例#23
0
文件: console.c 项目: Jimx-/lyos
/**
 * Initialize the console of a certain tty.
 * 
 * @param tty  Whose console is to be initialized.
 *****************************************************************************/
PUBLIC void init_screen(TTY* tty)
{
	int nr_tty = tty - tty_table;
	CONSOLE * con = console_table + nr_tty;
	con->con_tty = tty;
	tty->tty_devwrite = cons_write;
	tty->tty_echo = out_char;
	kb_init(tty);
	/* 
	 * NOTE:
	 *   variables related to `position' and `size' below are
	 *   in WORDs, but not in BYTEs.
	 */
	int v_mem_size = V_MEM_SIZE >> 1; /* size of Video Memory */
	int size_per_con = v_mem_size / NR_CONSOLES;
	con->orig = nr_tty * size_per_con;
	con->con_size = size_per_con / SCR_WIDTH * SCR_WIDTH;
	con->cursor = con->crtc_start = con->orig;
	con->is_full = 0;

	tty->tty_dev = con;
	if (nr_tty == 0) {
		((CONSOLE *)tty->tty_dev)->cursor = disp_pos / 2;
		disp_pos = 0;
	}
	/*else {*/
		/* 
		 * `?' in this string will be replaced with 0, 1, 2, ...
		 */
	/*	const char prompt[] = "[tty #?]\n";

		const char * p = prompt;
		for (; *p; p++)
			out_char(tty, *p == '?' ? nr_tty + '0' : *p);
	}*/

	set_cursor(((CONSOLE *)tty->tty_dev)->cursor);
}
示例#24
0
/*! 
 * This function open and initializes the default sound devices
 *
 * \param snd pointer to a snd_t structure 
 * \return an error code
 *        - 1 error
 *        - 0 no error
 */
int kb_snd_openDevices( snd_t *snd )
{
  int rc;
  
  /* Initialize the korebot library return with 1 if any issue */
  if((rc= kb_init( 0, NULL )) < 0 )
    return 1;  
    
  KB_DEBUG( "kb_openDevices", 0, "kb_init Ok");
  
  /* Initialize the korebot sound devices */
  kb_snd_init( snd , "/dev/sound/dsp" , "/dev/sound/mixer" );
  
  /* open the sound device return with 1 if any issue */
  if (kb_snd_open(snd) < 0 ) {
    fprintf(stderr , "unable to open sound device\n");
    return (1);
  }
    
  KB_DEBUG( "kb_openDevices", 0, "kb_snd_init Ok");
  /* return with success */
  return 0;
}
示例#25
0
int
s3_decode_init(s3_decode_t * _decode, cmd_ln_t *_config)
{
    if (_decode == NULL)
        return S3_DECODE_ERROR_NULL_POINTER;

    /* capture decoder parameters */
    kb_init(&_decode->kb, _config);

    /* initialize decoder variables */
    _decode->kbcore = _decode->kb.kbcore;
    _decode->hyp_frame_num = -1;
    _decode->uttid = NULL;
    _decode->state = S3_DECODE_STATE_IDLE;
    _decode->hyp_str = NULL;
    _decode->hyp_segs = NULL;

    _decode->swap =
            strcmp(cmd_ln_str_r(_config,"-machine_endian"),
                   cmd_ln_str_r(_config,"-input_endian"));

    if (_decode->swap)
        E_INFO("Input data WILL be byte swapped\n");
    else
        E_INFO("Input data will NOT be byte swapped\n");

    _decode->phypdump = (cmd_ln_int32_r(_config, "-phypdump"));

    if (_decode->phypdump)
        E_INFO("Partial hypothesis WILL be dumped\n");
    else
        E_INFO("Partial hypothesis will NOT be dumped\n");

    _decode->rawext = (cmd_ln_str_r(_config, "-rawext"));

    return S3_DECODE_SUCCESS;
}
示例#26
0
int main( int argc , char * argv[] )
{
  int rc,ver,io,ad,pw = 0, freq;
  char newpage = 12, state;
  uint16_t val;
  uint32_t time;
  

  /* Set the libkorebot debug level - Highly recommended for development. */
  kb_set_debug_level(2);

  if((rc = kb_init( argc , argv )) < 0 )
    return 1;

  signal( SIGINT , ctrlc_handler );

  printf("K-Team KoreIO Test Program\r\n");
  
  koreio = knet_open( "KoreIOLE:Board", KNET_BUS_ANY, 0 , NULL );
  if(!koreio)
  {
    printf("Cannot open KoreIOLE device trying alternate address\r\n");
    koreio = knet_open( "KoreIOLE:AltBoard", KNET_BUS_ANY, 0 , NULL );
    if(!koreio)
    {
      printf("Cannot open KoreIOLE device\r\n");
      return 1;
    }
  }

  /* Get and display the koreio firmware version */
  kio_GetFWVersion(koreio,&ver);

  printf("KoreIOLE firmware %d.%d\r\n", (ver&0x000000F0)>>4, (ver&0x0000000F));

	/* config all the IO as a output */
  io = 0;
	while(io < 16)
	while(io < 16)
	{
	  kio_ConfigIO(koreio,io,1);
	  io++;
		usleep(1000);
	}
  	/* set one of two Output */
    io = 0;
	while(io < 16)
	{
	  kio_SetIO(koreio,io);
	  io+= 2;
	}	
	  /* clear one of two Output */
    io = 1;
	while(io < 16)
	{
	  kio_ClearIO(koreio,io);
	  io+= 2;
	}	
	
	
  
  /* parse commands */
  while (!quitReq) {
    printf("\n> ");
	  

 /* read all the analog input value */
  ad = 0;
  while(ad < 12)
  {	
  	kio_ReadAnalog(koreio,ad,&val,&time);
  	printf("read ad %d: %u at %lu mS\r\n",ad,val,time);	  
	ad++;
  }

		/* blink the output */
  io = 0;
	while(io < 16)
	{
	  kio_ChangeIO(koreio,io);
	  io++;
	}	



  /* blink the power output */
  kio_ClearPW(koreio,pw);
  if(++pw > 5)
	  pw = 0;
  kio_SetPW(koreio,pw);

  
	  
	  

    /*if ( fgets( buf , sizeof(buf) , stdin ) != NULL ) {
      buf[strlen(buf)-1] = '\0';
      kb_parse_command( buf , cmds , NULL);
    }*/
  /* clear the current page */
      usleep(200000);
	  printf("%c", newpage);

  }

  knet_close( koreio );
}
示例#27
0
void init_hw() {
  kb_init();
  usb_init();
  while (!usb_configured());
}
示例#28
0
int main( int argc , char * argv[] )
{
  ksock_t server;
  int rc;
  unsigned char buf[16];
  unsigned char a,b,c,d;
  int clntSocket;
  char echoBuffer[RCVBUFSIZE];        /* Buffer for echo string */
  int recvMsgSize;                    /* Size of received message */
  int port;                           /* The server port to open */
  
  pthread_t sensor_task;
  pthread_t sound_task;

  if(argc > 1)
    port = atoi(argv[1]);
  else
    port = 344;

  /* Various initialization */
  /* Set the libkorebot debug level - Highly recommended for development. */
  kb_set_debug_level( 2 );

  /* Global libkorebot init */
  if((rc = kb_init( argc , argv )) < 0 )
    return 1;
  
  /* Korebot socket module init */
  if((rc = ksock_init('\n')) < 0 )
    return 1;

  /* Open the motor devices */
  motor1 = knet_open( "KoreMotor:PriMotor1", KNET_BUS_ANY, 0 , NULL );
  if(!motor1)
  {
    printf("Cannot open motor 0\r\n");
    return 1;
  }
  motor0 = knet_open( "KoreMotor:PriMotor2", KNET_BUS_ANY, 0 , NULL );
  if(!motor0)
  {
    printf("Cannot open motor 1\r\n");
    return 1;
  }
  motor3 = knet_open( "KoreMotor:PriMotor3", KNET_BUS_ANY, 0 , NULL );
  if(!motor3)
  {
    printf("Cannot open motor 2\r\n");
    return 1;
  }
  motor2 = knet_open( "KoreMotor:PriMotor4", KNET_BUS_ANY, 0 , NULL );
  if(!motor2)
  {
    printf("Cannot open motor 3\r\n");
    return 1;
  }

  
  /* KoreMotor Comm test */
  kmot_GetFWVersion( motor1, &rc);
  printf("Motor 1 Firmware v%u.%u\n" , KMOT_VERSION(rc) , KMOT_REVISION(rc));

  /* Intialize motor controller */
  InitMotor(motor0);
  InitMotor(motor1);
  InitMotor(motor2);
  InitMotor(motor3);
  kmot_SearchLimits(motor0, 10, 3, &minpos0, &maxpos0,100000);
  printf("motor0: min:%ld max:%ld\n\r",minpos0, maxpos0);
  kmot_SearchLimits(motor1, 10, 3, &minpos1, &maxpos1,100000);
  printf("motor1: min:%ld max:%ld\n\r",minpos1, maxpos1);
  kmot_SearchLimits(motor2, 10, 3, &minpos2, &maxpos2,100000);
  printf("motor2: min:%ld max:%ld\n\r",minpos2, maxpos2);
  kmot_SearchLimits(motor3, 10, 3, &minpos3, &maxpos3,100000);
  printf("motor3: min:%ld max:%ld\n\r",minpos3, maxpos3);
  kmot_SetBlockedTime(motor0,5);
  kmot_SetBlockedTime(motor2,5);

  /* Network setup - Create a ksock server */
  ksock_server_open(&server, port);
  
  ksock_add_command("movecamera",2,2,koa_net_camera);
  ksock_add_command("movecamera2",2,2,koa_net_camera2);
  ksock_add_command("moveboth",2,2,koa_net_bothcam);
  ksock_add_command("initcamera",0,0,koa_net_init);
  list_command();

  /* Network connection handling */
  clntSocket = ksock_next_connection(&server);
  for(;;)
  {
    rc = ksock_get_command(clntSocket, echoBuffer, RCVBUFSIZE);

    if(rc>0)
    {
      ksock_exec_command(echoBuffer);
      /* Echo message back to client */
      if (send(clntSocket, echoBuffer, rc, 0) != rc)
	DieWithError("send() failed");
    } 
    else 
      switch(rc)
      {
	case 0 :
	  break;
	case -3 :
	  printf("Client disconnected\r\n");
	  clntSocket = ksock_next_connection(&server);
	  break;
	default :
	  printf("Socket error: %d\r\n",rc);
	  clntSocket = ksock_next_connection(&server);
	  break;
      }
  }

  close(clntSocket);    /* Close client socket */

  return 0;
}
示例#29
0
/*
 * main()
 */
int main(void) {
	kb_init();  // does controller initialization too

	kb_led_state_power_on();

	usb_init();
	while (!usb_configured());
	kb_led_delay_usb_init();  // give the OS time to load drivers, etc.

	kb_led_state_ready();

	for (;;) {
		// swap `main_kb_is_pressed` and `main_kb_was_pressed`, then update
		bool (*temp)[KB_ROWS][KB_COLUMNS] = main_kb_was_pressed;
		main_kb_was_pressed = main_kb_is_pressed;
		main_kb_is_pressed = temp;

		kb_update_matrix(*main_kb_is_pressed);

		// this loop is responsible to
		// - "execute" keys when they change state
		// - keep track of which layers the keys were on when they were pressed
		//   (so they can be released using the function from that layer)
		//
		// note
		// - everything else is the key function's responsibility
		//   - see the keyboard layout file ("keyboard/ergodox/layout/*.c") for
		//     which key is assigned which function (per layer)
		//   - see "lib/key-functions/public/*.c" for the function definitions
		#define row          main_loop_row
		#define col          main_loop_col
		#define layer        main_arg_layer
		#define is_pressed   main_arg_is_pressed
		#define was_pressed  main_arg_was_pressed
		for (row=0; row<KB_ROWS; row++) {
			for (col=0; col<KB_COLUMNS; col++) {
				is_pressed = (*main_kb_is_pressed)[row][col];
				was_pressed = (*main_kb_was_pressed)[row][col];

				if (is_pressed != was_pressed) {
					if (is_pressed) {
						layer = main_layers_peek(0);
						main_layers_pressed[row][col] = layer;
						main_arg_trans_key_pressed = false;
					} else {
						layer = main_layers_pressed[row][col];
						main_arg_trans_key_pressed = main_kb_was_transparent[row][col];
					}

					// set remaining vars, and "execute" key
					main_arg_row          = row;
					main_arg_col          = col;
					main_arg_layer_offset = 0;
					main_exec_key();
					main_kb_was_transparent[row][col] = main_arg_trans_key_pressed;
				}
			}
		}
		#undef row
		#undef col
		#undef layer
		#undef is_pressed
		#undef was_pressed

		// send the USB report (even if nothing's changed)
		usb_keyboard_send();
		usb_extra_consumer_send();
		_delay_ms(MAKEFILE_DEBOUNCE_TIME);

		// update LEDs
		/*if (keyboard_leds & (1<<0)) { kb_led_num_on(); }*/
		/*else { kb_led_num_off(); }*/
		if (keyboard_leds & (1<<1)) { kb_led_caps_on(); }
		else { kb_led_caps_off(); }
		if (keyboard_leds & (1<<2)) { kb_led_scroll_on(); }
		else { kb_led_scroll_off(); }
		if (keyboard_leds & (1<<3)) { kb_led_compose_on(); }
		else { kb_led_compose_off(); }
		if (keyboard_leds & (1<<4)) { kb_led_kana_on(); }
		else { kb_led_kana_off(); }
		if (layers_head != 0) { kb_led_num_on(); }
		else { kb_led_num_off(); }
	}

	return 0;
}
示例#30
0
int main( int argc , char * argv[] )
{
  unsigned int ver;
  int rc;
  char * name;
  int32_t position,speed,current;
  knet_dev_t *motor0, *motor1;
  int32_t minpos0,maxpos0,minpos1,maxpos1;
  int32_t tgtmin0,tgtmax0,tgtmax1,tgtmin1;
  unsigned char status0,erreur0,status1,erreur1;
  int32_t pos0,pos1;
  unsigned counter = 10, addr0, addr1;
  
  /*! \todo check args should be rewriten using libpopt */
  if(argc < 3)
  {
    //printf("Usage: pantilt [-a] motor0 motor1 [nb cycle]\r\n");
    printf("Usage: pantilt motor0 motor1 [nb cycle]\r\n");
    //printf("\t-a to use alternate address (unsuported)\r\n");
    printf("\tmotor number is 1,2,3 or 4\r\n");
    printf("\tnb cycle is 10 by default\r\n");
    return 0;
  }

  if(argc > 3)
    counter = atoi(argv[3]);
  else
    counter = 10;

  /* Set the libkorebot debug level - Highly recommended for development. */
  kb_set_debug_level(2);

  if((rc = kb_init( argc , argv )) < 0 )
    return 1;

  printf("K-Team Pantilt Test Program\r\n");

  /* Open the motor devices */
  motor0 = PantiltOpen(atoi(argv[1]));
  if(!motor0)
  {
    printf("Cannot open motor %d\r\n",atoi(argv[1]));
    return 1;
  }

  motor1 = PantiltOpen(atoi(argv[2]));
  if(!motor1)
  {
    printf("Cannot open motor %d\r\n",atoi(argv[2]));
    return 1;
  }

  /* read controller software version */
  kmot_GetFWVersion( motor1, &ver );
  printf("Motor 1 Firmware v%u.%u\n" , KMOT_VERSION(ver) , KMOT_REVISION(ver));

  /* Intialize motor controller */
  InitMotor(motor0);
  InitMotor(motor1);
  kmot_SearchLimits(motor0, 5, 3, &minpos0, &maxpos0,100000);
  tgtmin0 = minpos0 + TGT_MARGIN;
  tgtmax0 = maxpos0 - TGT_MARGIN;
  printf("motor0: min:%ld max:%ld\n\r",minpos0, maxpos0);

  kmot_SearchLimits(motor1, 5, 3, &minpos1, &maxpos1,100000);
  tgtmin1 = minpos1 + TGT_MARGIN;
  tgtmax1 = maxpos1 - TGT_MARGIN;
  printf("motor1: min:%ld max:%ld\n\r",minpos1, maxpos1);

  printf("%d: set pos: %ld,%ld\n\r",counter,tgtmin0,tgtmin1);
#if 0
  kmot_SetPoint(motor0, kMotRegPosProfile, tgtmin0);
  kmot_SetPoint(motor1, kMotRegPosProfile, tgtmin1);
#else
  kmot_SetPoint(motor0, kMotRegPos, tgtmin0);
  kmot_SetPoint(motor1, kMotRegPos, tgtmin1);
#endif
  
  while(counter)
  {
    usleep(100000);
    printf("%d: set pos: %ld,%ld\n\r",counter,tgtmin0,tgtmin1);
#if 0
    kmot_SetPoint(motor0, kMotRegPosProfile, tgtmin0);
    kmot_SetPoint(motor1, kMotRegPosProfile, tgtmin1);
#else
    kmot_SetPoint(motor0, kMotRegPos, tgtmin0);
    kmot_SetPoint(motor1, kMotRegPos, tgtmin1);
#endif

#if 0
    kmot_GetStatus(motor0,&status0,&erreur0);
    kmot_GetStatus(motor1,&status1,&erreur1);
    while( ! ((status0 & 0x8) && (status1 & 0x8)))
    {
      kmot_GetStatus(motor0,&status0,&erreur0);
      kmot_GetStatus(motor1,&status1,&erreur1);
    }
#else
    pos0 = kmot_GetMeasure(motor0,kMotMesPos);
    pos1 = kmot_GetMeasure(motor1,kMotMesPos);
    while( abs(pos0 - tgtmin0) > MARGIN || abs(pos1 - tgtmin1) > MARGIN)
    {
      pos0 = kmot_GetMeasure(motor0,kMotMesPos);
      pos1 = kmot_GetMeasure(motor1,kMotMesPos);
    }
#endif
    kmot_SetMode(motor0,2);
    kmot_SetMode(motor1,2);

    usleep(100000);
    printf("%d: set pos: %ld,%ld\n\r",counter, tgtmax0,tgtmax1);
#if 0
    kmot_SetPoint(motor0, kMotRegPosProfile, tgtmax0);
    kmot_SetPoint(motor1, kMotRegPosProfile, tgtmax1);
#else
    kmot_SetPoint(motor0, kMotRegPos, tgtmax0);
    kmot_SetPoint(motor1, kMotRegPos, tgtmax1);
#endif

#if 0
    kmot_GetStatus(motor0,&status0,&erreur0);
    kmot_GetStatus(motor1,&status1,&erreur1);
    while( ! ((status0 & 0x8) && (status1 & 0x8)))
    {
      kmot_GetStatus(motor0,&status0,&erreur0);
      kmot_GetStatus(motor1,&status1,&erreur1);
    }
#else
    pos0 = kmot_GetMeasure(motor0,kMotMesPos);
    pos1 = kmot_GetMeasure(motor1,kMotMesPos);
    while( abs(pos0 - tgtmax0) > MARGIN || abs(pos1 - tgtmax1) > MARGIN)
    {
      pos0 = kmot_GetMeasure(motor0,kMotMesPos);
      pos1 = kmot_GetMeasure(motor1,kMotMesPos);
    }
#endif

    kmot_SetMode(motor0,2);
    kmot_SetMode(motor1,2);

    counter--;
  }

}