Example #1
0
void scanArgs(int argc, char **argv)
{
	int x;

	memset(backcolor,0,32);
	memset(ledcolor,0,32);
	memset(display,0,32);
	memset(position,0,32);
	strncpy(ledcolor,LEDCOLOR,32);
	strncpy(backcolor,BACKCOLOR,32);
	strcpy(display,"");
	strcpy(position,"");
	wmaker=ushape=astep=0;
	btnstate=rpttimer=0;
	dragging=count=0;

	for(x=1;x<argc;x++)
	{
		if(argv[x][0]!='-') show_params();
		else switch(argv[x][1])
		{
			case 'w':
				wmaker=1;
				break;
			case 's':
				ushape=1;
				break;
			case 'a':
				astep=1;
				break;
			case 'l':
				strncpy(ledcolor,argv[x+1],32);
				x++;
				break;
			case 'b':
				strncpy(backcolor,argv[x+1],32);
				x++;
				break;
			case 'p':
				strncpy(position,argv[x+1],32);
				x++;
				break;
			case 'd':
				strncpy(display,argv[x+1],32);
				x++;
				break;
			default:
				show_params();
				break;
		}
	}
	return;
}
Example #2
0
static int init(t_hydra_console *con, t_tokenline_parsed *p)
{
	mode_config_proto_t* proto = &con->mode->proto;
	bsp_status_t bsp_status;
	int tokens_used;

	/* Defaults */
	init_proto_default(con);

	/* Process cmdline arguments, skipping "can". */
	tokens_used = 1 + exec(con, p, 1);

	bsp_status = bsp_can_init(proto->dev_num, proto);
	if( bsp_status != BSP_OK) {
		cprintf(con, str_bsp_init_err, bsp_status);
	}

	/* By default, get all packets */
	if (proto->config.can.filter_id_low != 0 || proto->config.can.filter_id_high != 0) {
		bsp_status = bsp_can_set_filter(proto->dev_num, proto,
						proto->config.can.filter_id_low,
						proto->config.can.filter_id_high);
	} else {
		bsp_status = bsp_can_init_filter(proto->dev_num, proto);
	}
	if( bsp_status != BSP_OK) {
		cprintf(con, "bsp_can_init_filter() error %d\r\n", bsp_status);
	}

	show_params(con);

	return tokens_used;
}
Example #3
0
/*
 * Test of set_param:
 * - name = test parameter name
 * - value = test value
 * - k = expected returned value
 * - error = expected error code (if k < 0)
 */
static void test_set_param(param_t *params, const char *name, const char *value, int32_t k, int32_t error) {
  int32_t code;
  error_code_t ecode;

  printf("Testing set_param %s := %s: ", name, value);
  fflush(stdout);
  code = yices_set_param(params, name, value);
  if (code >= 0) {
    printf("ok\n");
    show_params(params);
  } else {
    printf("error\n");
    yices_print_error(stdout);
  }

  if (code != k) {
    printf("TEST FAILED\n");
    printf("--> Yices function returned %"PRId32"; %"PRId32" was expected\n", code, k);
    fflush(stdout);
    exit(1);
  } else if (k < 0) {
    ecode = yices_error_code();
    if (ecode != error) {
      printf("TEST FAILED\n");
      printf("--> Found error code %"PRId32"; %"PRId32" was expected\n", ecode, error);
      fflush(stdout);
      exit(1);
    }
  }

  printf("\n");
  fflush(stdout);
}
Example #4
0
int main(void) {
  param_t *p1, *p2;

  yices_init();
  p1 = yices_new_param_record();
  printf("Allocated param record %p\n", p1);
  show_params(p1);

  p2 = yices_new_param_record();
  printf("Allocated param record %p\n", p2);
  show_params(p2);

  test_set_params(p2);

  yices_free_param_record(p2);
  yices_free_param_record(p1);

  yices_exit();

  return 0;
}
Example #5
0
static int show(t_hydra_console *con, t_tokenline_parsed *p)
{
	int tokens_used;

	tokens_used = 0;
	if (p->tokens[1] == T_PINS) {
		tokens_used++;
		cprint(con, str_pins_i2c1, strlen(str_pins_i2c1));
	} else {
		show_params(con);
	}

	return tokens_used;
}
static int show(t_hydra_console *con, t_tokenline_parsed *p)
{
	mode_config_proto_t* proto = &con->mode->proto;
	int tokens_used;

	tokens_used = 0;
	if (p->tokens[1] == T_PINS) {
		tokens_used++;
		cprintf(con, "%s", str_pins_uart[proto->dev_num]);
	} else {
		show_params(con);
	}

	return tokens_used;
}
Example #7
0
static int init(t_hydra_console *con, t_tokenline_parsed *p)
{
	mode_config_proto_t* proto = &con->mode->proto;
	int tokens_used;

	init_proto_default(con);

	/* Process cmdline arguments, skipping "spi". */
	tokens_used = 1 + exec(con, p, 1);

	bsp_spi_init(proto->dev_num, proto);

	show_params(con);

	return tokens_used;
}
Example #8
0
static int show(t_hydra_console *con, t_tokenline_parsed *p)
{
	mode_config_proto_t* proto = &con->mode->proto;
	int tokens_used;

	tokens_used = 0;
	if (p->tokens[1] == T_PINS) {
		tokens_used++;
		if (proto->dev_num == 0)
			cprint(con, str_pins_spi1, strlen(str_pins_spi1));
		else
			cprint(con, str_pins_spi2, strlen(str_pins_spi2));
	} else {
		show_params(con);
	}

	return tokens_used;
}
Example #9
0
static int show(t_hydra_console *con, t_tokenline_parsed *p)
{
	mode_config_proto_t* proto = &con->mode->proto;
	int tokens_used;

	tokens_used = 0;
	switch (p->tokens[1]) {
	case T_PINS:
		tokens_used++;
		cprintf(con, "%s", str_pins_can[proto->dev_num]);
		break;
	case T_FILTER:
		tokens_used++;
		cprintf(con, "Low : 0x%02X\r\nHigh: 0x%02X\r\n",
			proto->config.can.filter_id_low,
			proto->config.can.filter_id_high);
		break;
	default:
		show_params(con);
		break;
	}

	return tokens_used;
}
Example #10
0
int main(int argc, char **argv){
  int n, i;
  char c[4], bp[1024], area[2048], print=FALSE;
  struct termio line;
  
  if (argc < 2) {
    my_str("Usage: ./select <file(s)>\n");
    return 1;
  }

  init_tty();
  fill_elems(argc, argv);
  signal(SIGWINCH, show_params);
  term_vi();
  term_init(bp, area);
  ioctl(0, TCGETA, &line);
  gl_env.line = line;
  line.c_lflag &= ~(ECHO | ISIG | ICANON);
  line.c_cc[VMIN] = 3;
  line.c_cc[VTIME] = VTI;
  ioctl(0, TCSETA, &line);
  show_params();

  while(1){
    n = read(0, c, 3);
    c[n] = '\0';

    /*my_str("\n");
    for(i=0;i<n;i++){
      my_int(c[i]);
      my_char('\n');
    }
    my_str("\n");*/
    if (my_strcmp(c, gl_env.esc) == 0) {
      // esc
      break;
    } else if (my_strcmp(c, "\n") == 0) {
      // enter
      print = TRUE;
      break;
    } else if (my_strcmp(c, " ") == 0) {
      // space
      gl_env.elems[gl_env.current].mode = 1 - gl_env.elems[gl_env.current].mode;
      if (gl_env.elems[gl_env.current].mode) {
	gl_env.current = gl_env.current + 1;
	if (gl_env.current >= gl_env.nbelems)
	  gl_env.current = 0;
      }
      show_params();
    } else if (my_strcmp(c, KU) == 0) {
      // up
      gl_env.current -= 1;
      if (gl_env.current < 0)
	gl_env.current = gl_env.nbelems - 1;
      show_params();
    } else if (my_strcmp(c, KD) == 0) {
      // down
      gl_env.current += 1;
      if (gl_env.current >= gl_env.nbelems)
	gl_env.current = 0;
      show_params();
    } else if (my_strcmp(c, KL) == 0) {
      // left
      gl_env.current -= gl_env.win.ws_row;
      if (gl_env.current < 0)
	gl_env.current = 0;
      show_params();
    } else if (my_strcmp(c, KR) == 0) {
      //right
      gl_env.current += gl_env.win.ws_row;
      if (gl_env.current >= gl_env.nbelems)
	gl_env.current = gl_env.nbelems-1;
      show_params();
    }
  }
  term_clear();
  ioctl(0, TCSETA, &(gl_env.line));
  term_ve();
  restore_tty();
  
  if (print) {
    //term_clear();
    //term_pos(0, 0);
    for (i=0;i<gl_env.nbelems;i++){
      if (gl_env.elems[i].mode) {
	my_str(gl_env.elems[i].elem);
	my_char(' ');
      }
    }
  }

  return 0;
}