Esempio n. 1
0
static int help_getdata(struct _select_def *conf, int pos, int len)
{
    int i;
    int mode = *((int *)conf->arg);

    for (i=0; i<help_num; i++) {
        if (s_help[i].content) free(s_help[i].content);
    }
    bzero(s_help, sizeof(struct helps)*BBS_PAGESIZE);

// if( conf->item_count - conf->page_pos < BBS_PAGESIZE)
    conf->item_count = count_help(mode);

    i=get_help(s_help, mode , conf->page_pos -1, BBS_PAGESIZE);

    if (i<=0) {
        conf->pos = 1;
        conf->page_pos = 1;
        help_search[0]=0;

        conf->item_count = count_help(mode);
        i=get_help(s_help, mode, 0, BBS_PAGESIZE);

        if (i<= 0)
            return SHOW_QUIT;
    }

    help_num = i;
    return SHOW_CONTINUE;
}
int
main(int argc, char* argv[])
{
	int res;
	
	while ((res = getopt(argc,argv,"l:o:m:vdh")) != -1){
		switch (res) {
		case 'o': 
			csvfile = optarg;
			break;
		case 'm':
			monitor = optarg;
			break;
		case 'v': 
			printf("VERBOSE MOD!\n");
			is_verbose = 1; 
			break;
		case 'd': 
			printf("DEBUG MOD!\n");
			is_debug = 1; 
			break;
		case 'h': 
			get_help(); 
		default: 
			printf("Error found !\n");
			exit(0);
        	};
	};
	argc -= optind;
	argv += optind;

	if (monitor == NULL) {
		warning("You need specify sites for monitoring\n");
		get_help();
		exit(1);
	}
	
	if (is_verbose) {
		if (csvfile)
			printf("Output CSV file: %s\n", csvfile);
		else
			printf("Output: STDOUT\n");
		printf("Monitor sites: %s\n", monitor);
	}

	process_args(argc, argv);

	return 0;
}
Esempio n. 3
0
main(int argc, char ** argv)
{
    check_help();

    extern char *poptarg;
    extern char *poparr[];
    int c;
    const char *param_string = "";

    while ((c = pgetopt(argc, argv, param_string,
		    "$Revision: 1.5 $", _SRC_)) != -1)
	switch(c) {
            case '?':	params_to_usage(cerr, argv[0], param_string);
	    		get_help();
	    		exit(1);
        }            

    dyn *b;
    real prev_time = -VERY_LARGE_NUMBER;
    cerr.precision(HIGH_PRECISION);

    while (b = get_dyn()) {

	real time = b->get_system_time();

	if (prev_time > -VERY_LARGE_NUMBER) {
	    real dt = time - prev_time;
	    PRC(time); PRL(dt);
	} else
	    PRL(time);
	prev_time = time;

	rmtree(b);
    }
}
Esempio n. 4
0
int conf_string(struct menu *menu)
{
	struct symbol *sym = menu->sym;
	const char *def;

	while (1) {
		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
		printf("(%s) ", sym->name);
		def = sym_get_string_value(sym);
		if (sym_get_string_value(sym))
			printf("[%s] ", def);
		if (!conf_askvalue(sym, def))
			return 0;
		switch (line[0]) {
		case '\n':
			break;
		case '?':
			/* print help */
			if (line[1] == '\n') {
				printf("\n%s\n", get_help(menu));
				def = NULL;
				break;
			}
		default:
			line[strlen(line)-1] = 0;
			def = line;
		}
		if (def && sym_set_string_value(sym, def))
			return 0;
	}
}
Esempio n. 5
0
void uart_rx_process(void)
{
    switch (g_uart_rx_buff[0]) {
    case 'r':
        get_stat();
        break;
    case 'u':
        get_transmitter_uptime();
        break;
    case 's':
        x_start();
        break;
    case 'q':
        if (g_uart_rx_buff[1] == 'd') {
            x_get_page();
        } else {
            x_get_status();
        }
        break;
    case '?':
        get_help();
        break;
    default:
        uart_printf("invalid command, send ? to get help" UART_EOL);
        uart_tx_flush();
    }
}
Esempio n. 6
0
void
Program_Options::check_options()
{
    bool loop = true;

    int verify = main_options();
    if(verify != 0) {
        while(loop) {
            if (command == "help") {
                for (auto c : *command_container) {
                    if ( subcommand == c.first) { 
                        cout << get_help(c.first, c.second).str();
                        loop = false;
                    }
                }
                if(loop){
                    cout << get_main_help() << endl ;
                    loop = false;
                }
            }
            else if (check_command() == true && loop == true) {
                loop = false;
            }

            if(loop){
                cout << get_main_help() << endl ;
                loop = false;
            }
        }
    }
}
Esempio n. 7
0
int main(int argc, char ** argv)
{
    int  n = 1;
    real m = 1.0;

    check_help();

    extern char *poptarg;
    int c;
    const char *param_string = "m:n:";

    while ((c = pgetopt(argc, argv, param_string,
		    "$Revision: 1.9 $", _SRC_)) != -1)
	switch(c) {

	    case 'm': m = atof(poptarg);
		      break;
	    case 'n': n = atoi(poptarg);
		      break;
            case '?': params_to_usage(cerr, argv[0], param_string);
	    	      get_help();
		      exit(1);
	}

    if (m <= 0) err_exit("mknodes: M > 0 required!");
    if (n <= 0) err_exit("mknodes: N > 0 required!");

    node * root = mknode_mass(n, m);

    root->log_history(argc, argv);

    put_node(root);
    rmtree(root);
    return 0;
}
Esempio n. 8
0
/*********************************************************************
 *
 * 0 - Help printed
 * 1 - Command
 *
 *********************************************************************/
int gethelp(char *str) {
	char *list;
	char *p;
	static char helpstr[] = "help [command]\nquit/exit";
	static char help[] = "help";

	if (strncmp(str, help, 4) == 0) {
		/* Skip word "help" */
		p = str + 4;
		while (isspace((int)*p))
			p++;

		if ((*p != '\0') && (list = get_help(p))) {
			if (write(1, list, strlen(list)) == -1)
				printf("Failed write to stdout.\n");
			free(list);
			return 0;
		} else {
			if ((list = get_list_of_cmd()) == NULL) {
				if (debug)
					syslog(LOG_DEBUG, "NULL cmdlist");
				if (write(1, helpstr, strlen(helpstr)) == -1)
					printf("Failed write to stdout.\n");
				return 0;
			}
			printf("%s%s", list, helpstr);
			free(list);
			return 0;
		}
	}
	return 1;
}
Esempio n. 9
0
int main(int argc, char *argv[])
{
    int opt;
    struct option longopts[] = {
        {"initialize", 0, NULL, 'i'},
        {"help", 0, NULL, 'h'},
        {"list", 0, NULL, 'l'},
        {"restart", 0, NULL, 'r'},
        {0,0,0,0}
    };
#if 0
    while((opt = getopt(argc, argv, ":if:lr:h")) != -1) {
        switch(opt) {
        case 'i':
        case 'h':
        case 'r':
            printf("option: %c\n", opt);
            break;
        case 'f':
            printf("filename: %s\n", optarg);
            break;
        case ':':
            printf("option needs a value\n");
            break;
        case '?':
            printf("unknown option: %c\n", optopt);
            break;
        }
    }
    for(; optind < argc; optind++)
        printf("argument: %s\n", argv[optind]);

#endif
    do {
        get_help();
        switch(opt)
        {
        case 1:
            init_server();
            break;
        case 2:
            init_sla_support();
            break;
        case 3:
            init_client();
            break;
        default:
            printf("Oops you might pressed '%d' ", opt );

        }

    } while(opt != 0);

    while(1)
    {
        sleep(1000);
    }

}
Esempio n. 10
0
/***************************************************************************//**
 * @brief main
*******************************************************************************/
int main(void)
{
	Xil_ICacheEnable();
	Xil_DCacheEnable();

	gpio_init(GPIO_DEVICE_ID);
	gpio_direction(54 + 46, 1);
	spi_init(SPI_DEVICE_ID, 1, 0);

	adc_init();
	dac_init(DATA_SEL_DDS);

	ad9361_phy = ad9361_init(&default_init_param);

	ad9361_set_tx_fir_config(ad9361_phy, tx_fir_config);
	ad9361_set_rx_fir_config(ad9361_phy, rx_fir_config);

#ifdef DAC_DMA
	dac_init(DATA_SEL_DMA);
#else
	dac_init(DATA_SEL_DDS);
#endif

#ifdef CAPTURE_SCRIPT
	adc_capture(16384, ADC_DDR_BASEADDR);
	while(1);
#endif
	get_help(NULL, 0);

	while(1)
	{
		console_get_command(received_cmd);
		invalid_cmd = 0;
		for(cmd = 0; cmd < cmd_no; cmd++)
		{
			param_no = 0;
			cmd_type = console_check_commands(received_cmd, cmd_list[cmd].name,
											  param, &param_no);
			if(cmd_type == UNKNOWN_CMD)
			{
				invalid_cmd++;
			}
			else
			{
				cmd_list[cmd].function(param, param_no);
			}
		}
		if(invalid_cmd == cmd_no)
		{
			console_print("Invalid command!\n");
		}
	}

	Xil_DCacheDisable();
	Xil_ICacheDisable();

	return 0;
}
Esempio n. 11
0
int main()
{
    int sock;
    struct sockaddr_in server;

    char buffer[MAXBUF];
    //Создание сокета
    sock = socket(AF_INET , SOCK_STREAM , 0);
    if (sock == -1)
    {
        printf("Could not create socket");
    }
    puts("Socket created\n");

    server.sin_addr.s_addr = inet_addr("127.0.0.1");
    server.sin_family = AF_INET;
    server.sin_port = htons( 1234 );

    //Connect to remote server
    if (connect(sock , (struct sockaddr *)&server , sizeof(server)) < 0)
    {
        perror("connect failed. Error");
        return 1;
    }

        bzero(buffer, MAXBUF);
        recv(sock , buffer , MAXBUF , 0); // прием слова
        puts(buffer);
        printf("Для получения справки введите команду help\n");
        while(1){
            bzero(buffer, MAXBUF);
            printf("Cmd: ");
            scanf("%s" , buffer);
            // команды
             if(strcmp(buffer, "view") == 0)
                    view_dir(buffer, sock, MAXBUF);
             else if(strcmp(buffer, "view_dir") == 0)
                    view_dir(buffer, sock, MAXBUF);
             else if(strcmp(buffer, "help") == 0)
                     get_help();
             else if(strcmp(buffer, "get_dir") == 0)
                    get_dir(buffer, sock, MAXBUF);
             else if(strcmp(buffer, "ch_dir") == 0)
                    ch_dir(buffer, sock, MAXBUF);
             else if(strcmp(buffer, "upload") == 0)
                    upload(buffer, MAXBUF, sock);
             else if(strcmp(buffer, "mk_dir") == 0)
                    mk_dir(buffer, MAXBUF, sock);
             else if(strcmp(buffer, "rm_dir") == 0)
                    rm_dir(buffer, MAXBUF, sock);
             else
                    printf("unknown comand\n");
             printf("Для получения справки введите команду help\n");
         }

         close(sock);
         return 0;
}
Esempio n. 12
0
void Terminal::parse_line(String line) {
  int spacer = line.indexOf(" ");
  String command = line.substring(0,spacer);
  if(command == "pid") {
    if(line.length() > (spacer + 1)) {
      String rest = line.substring(spacer+1);
      manage_pid(rest);
    } else { get_help(); }
  }
  else if(command == "online") {
    int cur_time = (millis() - global_info.start_time) / 1000;
    Serial1.print("Time from start : ");
    Serial1.println(cur_time);
  }
  else {
    get_help();
  }
}
Esempio n. 13
0
void Terminal::manage_pid(String opts) {
  int spacer = opts.indexOf(" ");
  String action = opts.substring(0, spacer);
  if(action == "current") {
    get_PID_settings();
  } else if (action == "set") {
    if(opts.length() > (spacer + 1)) {
      String rest = opts.substring(spacer+1);
      set_PID_settings(rest);
    } else { get_help(); }
  }
}
Esempio n. 14
0
void do_neededhelpfiles(CHAR_DATA *ch, char *argument)
{
    HELP_DATA *pHelp;
    bool bIsHelp = TRUE;
    char *agg;
    sh_int col = 0;
    int star = 0;
    int cmd;
    int nLimit = 0;
    bool bChanged = FALSE;
    bool foundstar = FALSE;
    char buf[MAX_INPUT_LENGTH];

    if ( argument[0] == '\0' ) return stcf(ch,"Syntax: neededhelpfiles <max amount of help files>\n\r");
    nLimit = atoi(argument);
    for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
    {
        foundstar = TRUE;
        agg = cmd_table[cmd].name;
        if ( (pHelp = get_help( ch, agg )) == NULL )
        {
            bIsHelp = FALSE;
            star++;
            col++;
            if ( star >= nLimit ) break;
            bChanged = TRUE;
        }
        else
            bIsHelp = TRUE;
        sprintf( buf, "%-15s#n",cmd_table[cmd].name );
        if ( bIsHelp == FALSE )
            send_to_char( buf, ch );
        if ( col % 5 == 0 && bChanged == TRUE)
            send_to_char( "\n\r", ch );
        bChanged = FALSE;
    }
    if (col % 5 != 0 && foundstar)
        send_to_char("\n\r", ch);

    if (foundstar && star != 0)
    {
        sprintf(buf, "\n%d command%s found.\n\r", star,
            (star > 1) ? "s" : "");
        stc(buf, ch);
    }

    if (!foundstar)
    {
        stc("No commands found.\n\r", ch);
    }
    return;
}
Esempio n. 15
0
// fixme: move to task.c
int exec(int argc, char *argv[])
{
	int ret;
	const struct command *exe;
	struct task *current;
	int (*main)(int, char *[]);

	// fixme
	for (exe = build_in_cmd; exe < build_in_cmd + ARRAY_ELEM_NUM(build_in_cmd); exe++) {
		if (!strncmp(exe->name, argv[0], MAX_ARG_LEN)) {
			goto L1;
		}
	}

	for (exe = g_exe_begin; exe < g_exe_end; exe++) {
		if (!strncmp(exe->name, argv[0], MAX_ARG_LEN)) {
			goto L1;
		}
	}

	printf("  command \"%s\" not found!\n"
		   "  Please use \"help\" to get g-bios command list.\n", argv[0]);
	return -ENOEXEC;

L1:
	main = exe->main;
	if (!main)
		return -EINVAL;

	current = malloc(sizeof(*current));
	if (!current)
		return -ENOMEM;

	current->argc = argc;
	current->argv = argv;
	current->exe  = exe;
	current->help = get_help(argv[0]); // fixme
	set_current_task(current);

	getopt_init();
	ret = main(argc, argv);

	set_current_task(NULL);
	free(current);

	return ret;
}
Esempio n. 16
0
/*-----------------------------------------------------------------------------
 *  main  --  driver to create directly a single node
 *-----------------------------------------------------------------------------
 */
main(int argc, char ** argv)
{
    bool  c_flag = FALSE;
    bool  i_flag = FALSE;
    real m = 1;               // default mass: unity
    char  *comment;

    check_help();

    extern char *poptarg;
    int  c;
    const char *param_string = "c:im:";

    while ((c = pgetopt(argc, argv, param_string,
		    "$Revision: 1.7 $", _SRC_)) != -1)
	switch(c) {
	    case 'c': c_flag = TRUE;
		      comment = poptarg;
		      break;
	    case 'i': i_flag = TRUE;
		      break;
	    case 'm': m = atof(poptarg);
		      break;
            case '?': params_to_usage(cerr, argv[0], param_string);
		      get_help();
		      exit(1);
	}            
    
    node * root;

    root = new node();
    root->set_root(root);
    root->set_mass(m);

    if (c_flag == TRUE)
        root->log_comment(comment);
    root->log_history(argc, argv);

    if (i_flag)
        root->set_label(1);

    put_node(root);
    rmtree(root);
}
Esempio n. 17
0
static sint read_matrix(char *title,MatMenu menu, char *matnam, sint matn, short *mat, short *xref)
{       static char userfile[FILENAMELEN+1];
	int i;

        while(TRUE)
        {
                fprintf(stdout,"\n\n\n");
                fprintf(stdout," ********* %s WEIGHT MATRIX MENU *********\n",title);
                fprintf(stdout,"\n\n");

		for(i=0;i<menu.noptions;i++)
                	fprintf(stdout,"     %d. %s\n",i+1,menu.opt[i].title);
                fprintf(stdout,"     H. HELP\n\n");
                fprintf(stdout,
"     -- Current matrix is the %s ",menu.opt[matn-1].title);
                if(matn == menu.noptions) fprintf(stdout,"(file = %s)",userfile);
                fprintf(stdout,"--\n");


                getstr("\n\nEnter number (or [RETURN] to exit)",lin2);
                if(*lin2 == EOS) return(matn);

                i=toupper(*lin2)-'0';
		if(i>0 && i<menu.noptions) {
                        strcpy(matnam,menu.opt[i-1].string);
                        matn=i;
		} else if (i==menu.noptions) {
                        if(user_mat(userfile, mat, xref)) {
                              strcpy(matnam,userfile);
                              matn=i;
                        }
		}
		else
                switch(toupper(*lin2))  {
                        case '?':
                        case 'H':
                                get_help('8');
                                break;
                        default:
                                fprintf(stdout,"\n\nUnrecognised Command\n\n");
                                break;
                }
        }
}
Esempio n. 18
0
int help(int argc, const char** argv) {
    shell_func func;

    //Check if they are trying to find help for a particular command
    if (argc > 1) {
        func = get_help(argv[1]);

        if (func == NULL) {
            putstr("Sorry no help exists for the command '");
            putstr(argv[1]);
            putstr("'\n");
        } else {
            func(argc, (const char **)argv);
        }
    } else {
        //List all possible commands
        putstr("Available commands:");
        putoptions(get_commands(""));
        putch('\n');
    }
    return 0;
}
Esempio n. 19
0
static sint secstroutput_options(void)
{

        while(TRUE)
        {
                fprintf(stdout,"\n\n\n");
                fprintf(stdout," ********* Secondary Structure Output Menu *********\n");
                fprintf(stdout,"\n\n");


                fprintf(stdout,"     1. %s\n",secstroutput_txt[0]);
                fprintf(stdout,"     2. %s\n",secstroutput_txt[1]);
                fprintf(stdout,"     3. %s\n",secstroutput_txt[2]);
                fprintf(stdout,"     4. %s\n",secstroutput_txt[3]);
                fprintf(stdout,"     H. HELP\n\n");
                fprintf(stdout,
"     -- Current output is %s ",secstroutput_txt[output_struct_penalties]);
                fprintf(stdout,"--\n");


                getstr("\n\nEnter number (or [RETURN] to exit)",lin2);
                if(*lin2 == EOS) return(output_struct_penalties);

        	switch(toupper(*lin2))
        	{
       	 		case '1': return(0);
        		case '2': return(1);
      			case '3': return(2);
        		case '4': return(3);
			case '?': 
        		case 'H': get_help('C');
            		case 'Q':
        		case 'X': return(0);

        		default: fprintf(stdout,"\n\nUnrecognised Command\n\n");
            		break;
        	}
        }
}
Esempio n. 20
0
main(int argc, char **argv)
{
    dyn *root;
    int  e_flag = 0;
    real eps = 0;

    check_help();

    extern char *poptarg;
    int c;
    const char *param_string = "e:";

    while ((c = pgetopt(argc, argv, param_string,
		    "$Revision: 1.6 $", _SRC_)) != -1)
	switch(c) {
	    case 'e': e_flag = 1;
                      eps = atof(poptarg);
	              break;
            case '?': params_to_usage(cerr, argv[0], param_string);
	              get_help();
                      exit(1);
	}

    // Loop over input until no more data remain.

    while ( (root = get_dyn()) != NULL) {

	real kinetic_energy, potential_energy;
	get_top_level_energies(root, eps*eps, potential_energy, kinetic_energy);

	cout << "Top-level energies (T, U, E):  "
	     << kinetic_energy << "  "
	     << potential_energy << "  "
	     << kinetic_energy + potential_energy 
	     << endl;
    }
}
Esempio n. 21
0
static int conf_choice(struct menu *menu)
{
	struct symbol *sym, *def_sym;
	struct menu *child;
	int type;
	bool is_new;

	sym = menu->sym;
	type = sym_get_type(sym);
	is_new = !sym_has_value(sym);
	if (sym_is_changable(sym)) {
		conf_sym(menu);
		sym_calc_value(sym);
		switch (sym_get_tristate_value(sym)) {
		case no:
			return 1;
		case mod:
			return 0;
		case yes:
			break;
		}
	} else {
		switch (sym_get_tristate_value(sym)) {
		case no:
			return 1;
		case mod:
			printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
			return 0;
		case yes:
			break;
		}
	}

	while (1) {
		int cnt, def;

		printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
		def_sym = sym_get_choice_value(sym);
		cnt = def = 0;
		line[0] = 0;
		for (child = menu->list; child; child = child->next) {
			if (!menu_is_visible(child))
				continue;
			if (!child->sym) {
				printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
				continue;
			}
			cnt++;
			if (child->sym == def_sym) {
				def = cnt;
				printf("%*c", indent, '>');
			} else
				printf("%*c", indent, ' ');
			printf(" %d. %s", cnt, _(menu_get_prompt(child)));
			if (child->sym->name)
				printf(" (%s)", child->sym->name);
			if (!sym_has_value(child->sym))
				printf(_(" (NEW)"));
			printf("\n");
		}
		printf(_("%*schoice"), indent - 1, "");
		if (cnt == 1) {
			printf("[1]: 1\n");
			goto conf_childs;
		}
		printf("[1-%d", cnt);
		if (menu_has_help(menu))
			printf("?");
		printf("]: ");
		switch (input_mode) {
		case ask_new:
		case ask_silent:
			if (!is_new) {
				cnt = def;
				printf("%d\n", cnt);
				break;
			}
			check_stdin();
		case ask_all:
			fflush(stdout);
			fgets(line, 128, stdin);
			strip(line);
			if (line[0] == '?') {
				printf("\n%s\n", get_help(menu));
				continue;
			}
			if (!line[0])
				cnt = def;
			else if (isdigit(line[0]))
				cnt = atoi(line);
			else
				continue;
			break;
		default:
			break;
		}

	conf_childs:
		for (child = menu->list; child; child = child->next) {
			if (!child->sym || !menu_is_visible(child))
				continue;
			if (!--cnt)
				break;
		}
		if (!child)
			continue;
		if (line[strlen(line) - 1] == '?') {
			printf("\n%s\n", get_help(child));
			continue;
		}
		sym_set_choice_value(sym, child->sym);
		for (child = child->list; child; child = child->next) {
			indent += 2;
			conf(child);
			indent -= 2;
		}
		return 1;
	}
}
Esempio n. 22
0
static int conf_sym(struct menu *menu)
{
	struct symbol *sym = menu->sym;
	int type;
	tristate oldval, newval;

	while (1) {
		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
		if (sym->name)
			printf("(%s) ", sym->name);
		type = sym_get_type(sym);
		putchar('[');
		oldval = sym_get_tristate_value(sym);
		switch (oldval) {
		case no:
			putchar('N');
			break;
		case mod:
			putchar('M');
			break;
		case yes:
			putchar('Y');
			break;
		}
		if (oldval != no && sym_tristate_within_range(sym, no))
			printf("/n");
		if (oldval != mod && sym_tristate_within_range(sym, mod))
			printf("/m");
		if (oldval != yes && sym_tristate_within_range(sym, yes))
			printf("/y");
		if (menu_has_help(menu))
			printf("/?");
		printf("] ");
		if (!conf_askvalue(sym, sym_get_string_value(sym)))
			return 0;
		strip(line);

		switch (line[0]) {
		case 'n':
		case 'N':
			newval = no;
			if (!line[1] || !strcmp(&line[1], "o"))
				break;
			continue;
		case 'm':
		case 'M':
			newval = mod;
			if (!line[1])
				break;
			continue;
		case 'y':
		case 'Y':
			newval = yes;
			if (!line[1] || !strcmp(&line[1], "es"))
				break;
			continue;
		case 0:
			newval = oldval;
			break;
		case '?':
			goto help;
		default:
			continue;
		}
		if (sym_set_tristate_value(sym, newval))
			return 0;
help:
		printf("\n%s\n", get_help(menu));
	}
}
Esempio n. 23
0
main(int argc, char ** argv)
{
    char  *comment;
    bool  c_flag = FALSE;	// if TRUE, a comment given on command line

    real  t_extract;
    bool  t_flag = FALSE;	// if TRUE, a time was specified

    bool  v_flag = FALSE;	// if TRUE, print snap times as read

    int   n = 1;
    bool  n_flag = false;	// if TRUE, a number was specified

    check_help();

    extern char *poptarg;
    int c;
    const char *param_string = "c:n:t:v";

    while ((c = pgetopt(argc, argv, param_string,
		    "$Revision: 1.8 $", _SRC_)) != -1)
	switch(c) {
	    case 'c': c_flag = TRUE;
	    	      comment = poptarg;
		      break;
	    case 't': t_flag = TRUE;
		      t_extract = atof(poptarg);
		      break;
	    case 'n': n_flag = TRUE;
		      n = atoi(poptarg);
		      break;
	    case 'v': v_flag = TRUE;
		      break;
	    case '?': params_to_usage(cerr, argv[0], param_string);
	              get_help();
		      exit(1);
	}            

    if (n < 0) err_exit("n < 0 specified.");
    if (n > 1 && !t_flag) {
	warning("n > 1 but no time specified -- 0 assumed.");
	t_extract = 0;
	t_flag = true;
    }

    node *b = NULL, *bp = NULL;
    int i = 0;

    // Need to ensure that the data are not changed by this function.
    // Currently, get_dyn() ends by calling check_and_correct_node(),
    // which may change pos and vel to force the system to the center
    // of mass frame.  Can fix (1) by suppressing this call in this
    // case, (2) setting a tolerance to avoid forcing if the system is
    // already "close" to the CM frame, or (3) use nodes here, which
    // will never interpret pos or vel and hence will not change them.
    // The only number we really need below is sytsem_time.  Options
    // (1) and (2) are awkward, because this function is a member
    // function and changing its arguments would propagate through the
    // other classes.  However, we could add a static local option to
    // the dyn instance of the function.  Option (3) seems cleanest.
    // To revert, change node to dyn and use b->get_system_time() to
    // determine time.
    //						(Steve, 7/04)

    while (b = get_node()) {

	real time;
	if (find_qmatch(b->get_dyn_story(), "real_system_time"))
	    time = getrq(b->get_dyn_story(), "real_system_time");
	else
	    time = getrq(b->get_dyn_story(), "system_time");

	// real time = b->get_system_time();

	i++;

	if (v_flag) cerr << "Snap time #" << i << " = " << time << endl;

	if (t_flag && time >= t_extract) {

	    if (n > 0) {

		if (c_flag == TRUE)
		    b->log_comment(comment);

		b->log_history(argc, argv);
		put_node(b);
	    }

	    if (--n <= 0) exit(0);
	}

	if (bp) rmtree(bp);
	bp = b;
    }

    if (n > 0 && !t_flag) {
	bp->log_history(argc, argv);
	put_node(bp);
    }

}
Esempio n. 24
0
main(int argc, char ** argv)
{
    bool renumber = true;
    check_help();

    extern char *poptarg;
    extern char *poparr[];
    int c;
    const char *param_string = "n";

    // Parse the argument list:

    while ((c = pgetopt(argc, argv, param_string,
		    "$Revision: 1.8 $", _SRC_)) != -1) {
	switch (c) {
	    case 'n':	renumber = false;
			break;

	    default:
	    case '?':	params_to_usage(cerr, argv[0], param_string);
			get_help();
			return false;
	}
    }

    dyn *b, *root = new dyn;
    if (!root) err_exit("merge_snaps: can't create root node.");
    int count = 0;
    root->log_history(argc, argv);

    while (b = get_dyn()) {

	b->offset_com();		// add root pos/vel to daughters

	// Attach top-level nodes of b to root.

	dyn *last = root->get_oldest_daughter();
	while (last && last->get_younger_sister())
	    last = last->get_younger_sister();

	for_all_daughters(dyn, b, bb) {

	    // First node is a special case.

	    if (!last)
		root->set_oldest_daughter(bb);
	    else
		last->set_younger_sister(bb);

	    bb->set_elder_sister(last);
	    bb->set_parent(root);
	    last = bb;
	}

	// Merge the root log stories, with a prefix indicating which
	// initial snapshot this was.  This code is not completely general,
	// but should be sufficient for simple (typical) stories.

	story *sr = root->get_log_story();
	story *s = b->get_log_story();
	for (story * d = s->get_first_daughter_node(); d != NULL;
	     d = d->get_next_story_node())
	    if (!d->get_chapter_flag()) {
		char tmp[1024];
		sprintf(tmp, "  +%4.4d:  ", count);
		strncat(tmp, d->get_text(), 1013);
		tmp[1023] = '\0';
		add_story_line(sr, tmp);
	    }

	count++;
	delete b;
    }

    // Recompute the total mass and force the center of mass to 0.
    // Better renumber too, unless specifically suppressed..

    real mass = 0;
    int index = 0;
    for_all_daughters(dyn, root, bb) {
	mass += bb->get_mass();
	if (renumber) bb->set_index(++index);
    }
Esempio n. 25
0
static void multi_menu(void)
{
        int catchint;

        catchint = signal(SIGINT, SIG_IGN) != SIG_IGN;
        if (catchint) {
                if (setjmp(jmpbuf) != 0)
                        fprintf(stdout,"\n.. Interrupt\n");
#ifdef UNIX
                if (signal(SIGINT,jumper) == BADSIG)
                        fprintf(stdout,"Error: signal\n");
#else
                if (signal(SIGINT,SIG_DFL) == (void*)BADSIG)
                        fprintf(stdout,"Error: signal\n");
#endif
        }


	if(dnaflag) {
		gap_open   = dna_gap_open;
		gap_extend = dna_gap_extend;
	}
	else {
		gap_open   = prot_gap_open;
		gap_extend = prot_gap_extend;
	}

	while(TRUE) {

		fprintf(stdout,"\n\n\n");
		fprintf(stdout," ********* MULTIPLE ALIGNMENT PARAMETERS *********\n");
		fprintf(stdout,"\n\n");
		
		fprintf(stdout,"     1. Gap Opening Penalty              :%4.2f\n",gap_open);
		fprintf(stdout,"     2. Gap Extension Penalty            :%4.2f\n",gap_extend);

		fprintf(stdout,"     3. Delay divergent sequences        :%d %%\n\n",(pint)divergence_cutoff);

                fprintf(stdout,"     4. DNA Transitions Weight           :%1.2f\n\n",transition_weight);
                fprintf(stdout,"     5. Protein weight matrix            :%s\n"
                                        	,matrix_menu.opt[matnum-1].title);
                fprintf(stdout,"     6. DNA weight matrix                :%s\n"
                                        	,dnamatrix_menu.opt[dnamatnum-1].title);
		fprintf(stdout,"     7. Use negative matrix              :%s\n\n",(!neg_matrix) ? "OFF" : "ON");
                fprintf(stdout,"     8. Protein Gap Parameters\n\n");
		fprintf(stdout,"     H. HELP\n\n\n");		

		getstr("Enter number (or [RETURN] to exit)",lin2);

		if(*lin2 == EOS) {
			if(dnaflag) {
				dna_gap_open    = gap_open;
				dna_gap_extend  = gap_extend;
			}
			else {
				prot_gap_open   = gap_open;
				prot_gap_extend = gap_extend;
			}
			return;
		}
		
		switch(toupper(*lin2)) {
			case '1':
			fprintf(stdout,"Gap Opening Penalty Currently: %4.2f\n",gap_open);
				gap_open=(float)getreal("Enter number",(double)0.0,(double)100.0,(double)gap_open);
				break;
			case '2':
				fprintf(stdout,"Gap Extension Penalty Currently: %4.2f\n",gap_extend);
				gap_extend=(float)getreal("Enter number",(double)0.0,(double)10.0,(double)gap_extend);
				break;
			case '3':
				fprintf(stdout,"Min Identity Currently: %d\n",(pint)divergence_cutoff);
				divergence_cutoff=getint("Enter number",0,100,divergence_cutoff);
				break;
			case '4':
				fprintf(stdout,"Transition Weight Currently: %1.2f\n",(pint)transition_weight);
				transition_weight=(float)getreal("Enter number",(double)0.0,(double)1.0,(double)transition_weight);
				break;
			case '5':
                                matnum = read_matrix("PROTEIN",matrix_menu,mtrxname,matnum,usermat,aa_xref);
				break;
			case '6':
                                dnamatnum = read_matrix("DNA",dnamatrix_menu,dnamtrxname,dnamatnum,userdnamat,dna_xref);
				break;
			case '7':
				neg_matrix ^= TRUE;
				break;
			case '8':
                                gap_penalties_menu();
				break;
			case '?':
			case 'H':
				get_help('4');
				break;
			default:
				fprintf(stdout,"\n\nUnrecognised Command\n\n");
				break;
		}
	}
}
Esempio n. 26
0
int main(int argc, char ** argv)
{
    real lower = 1.0, upper = 1.0;
    real emax = 1;
    int function_select = 3;
    int option = 1;
    int random_seed = 0;
    char seedlog[64];

    check_help();

    extern char *poptarg;
    int c;
    const char *param_string = "f:l:s:o:u:e:";

    while ((c = pgetopt(argc, argv, param_string,
		    "$Revision: 1.9 $", _SRC_)) != -1)
	switch(c) {

	    case 'f': function_select = atoi(poptarg);
		      break;
	    case 'l': lower = atof(poptarg);
		      break;
	    case 'o': option= atoi(poptarg);
		      break;
	    case 'e': emax = atof(poptarg);
		      break;
	    case 's': random_seed = atoi(poptarg);
		      break;
	    case 'u': upper = atof(poptarg);
		      break;
            case '?': params_to_usage(cerr, argv[0], param_string);
	    	      get_help();
		      exit(1);
	}

    if (lower <= 0 || upper <= 0 || lower > upper)
	err_exit("makebinary: Illegal limits");

    dyn* b;
    b = get_dyn();

    b->log_history(argc, argv);

    int actual_seed = srandinter(random_seed);

    sprintf(seedlog, "       random number generator seed = %d",
	    actual_seed);
    b->log_comment(seedlog);

    // Look in the dyn story to see if a total system energy is known.
    // If it is, scale lower and upper accordingly.

    // Thus, in case function_select = 3, if the energy is known,
    // lower and upper are specified in "kT" units.  If the energy
    // is not known, lower and upper are absolute limits on the
    // binary kinetic energy.

    const char* energy_string = "initial_total_energy";

    if (function_select == 1) {
	if (b->get_starbase()->get_stellar_evolution_scaling()) {
	    real scale = sqrt(b->get_starbase()->conv_m_star_to_dyn(1)
			      * b->get_starbase()->conv_r_star_to_dyn(1));
	    lower *= scale;
	    upper *= scale;
	}
	else
	    cerr << "makebinary: Using unscaled angular-momentum limits.\n";
    }
    else if (function_select == 2) {
	if (b->get_starbase()->conv_r_star_to_dyn(1)>0) {
	    lower = b->get_starbase()->conv_r_star_to_dyn(lower);
	    upper = b->get_starbase()->conv_r_star_to_dyn(upper);
	}
	else
	    cerr << "makebinary: Using unscaled semi-major axis limits.\n";
    }
    else if (function_select == 3) {
	if (find_qmatch(b->get_log_story(), energy_string))
	    scale_limits(lower, upper, option,
			 b->n_daughters(), b->get_mass(),
			 getrq(b->get_log_story(), energy_string));
	else
	    cerr << "makebinary: Using unscaled energy limits.\n";
    }

    makebinary(b, lower, upper, function_select, option, emax);

    put_dyn(b);
    rmtree(b);
    return 0;
}
Esempio n. 27
0
int _tmain(int argc, _TCHAR *argv[])
{
	int result;

	initialize_arguments();

	if(parse_arguments(argv) != ARGS_OK || arguments.error) 
	{
		_tprintf(_T("%s"), get_help());
		quit();
	}

	if(arguments.debug) 
	{
		_ftprintf(arguments.logFile, _T("Debug log is enabled.\n"));
	}

	if(arguments.version == TRUE) 
	{
		_tprintf(_T("%s"), get_version());
		_tprintf(_T("%s"), get_copyright());
		quit();
	}

	if(arguments.service == TRUE) 
	{
		result = servicize();
		if(result != 0) 
		{
			_ftprintf(arguments.logFile, _T("Unable to install as service.\n"));
		}
		quit();
	}

	if(arguments.persistent == TRUE) 
	{
		result = persist();
		if(result != 0) 
		{
			_ftprintf(arguments.logFail, _T("An occurred when running persistent.\n"));
		}
		quit();
	}

	if(arguments.mode == RM_BASIC) 
	{
		run_basic_scan();
	} 
	else if(arguments.mode == RM_STANDARD) 
	{
		run_standard_scan();
	} 
	else if(arguments.mode == RM_FULL) 
	{
		run_full_scan();
	}

	close_log(arguments.log);

	return 0;
}
Esempio n. 28
0
/***************************************************************************//**
 * @brief main
*******************************************************************************/
int main(void)
{
#ifdef XILINX_PLATFORM
	Xil_ICacheEnable();
	Xil_DCacheEnable();
#endif

#ifdef ALTERA_PLATFORM
	if (altera_bridge_init()) {
		printf("Altera Bridge Init Error!\n");
		return -1;
	}
#endif

	// NOTE: The user has to choose the GPIO numbers according to desired
	// carrier board.
	default_init_param.gpio_resetb = GPIO_RESET_PIN;
#ifdef FMCOMMS5
	default_init_param.gpio_sync = GPIO_SYNC_PIN;
	default_init_param.gpio_cal_sw1 = GPIO_CAL_SW1_PIN;
	default_init_param.gpio_cal_sw2 = GPIO_CAL_SW2_PIN;
	default_init_param.rx1rx2_phase_inversion_en = 1;
#else
	default_init_param.gpio_sync = -1;
	default_init_param.gpio_cal_sw1 = -1;
	default_init_param.gpio_cal_sw2 = -1;
#endif

#ifdef LINUX_PLATFORM
	gpio_init(default_init_param.gpio_resetb);
#else
	gpio_init(GPIO_DEVICE_ID);
#endif
	gpio_direction(default_init_param.gpio_resetb, 1);

	spi_init(SPI_DEVICE_ID, 1, 0);

	if (AD9364_DEVICE)
		default_init_param.dev_sel = ID_AD9364;
	if (AD9363A_DEVICE)
		default_init_param.dev_sel = ID_AD9363A;

#if defined FMCOMMS5 || defined PICOZED_SDR || defined PICOZED_SDR_CMOS
	default_init_param.xo_disable_use_ext_refclk_enable = 1;
#endif

#ifdef PICOZED_SDR_CMOS
	default_init_param.swap_ports_enable = 1;
	default_init_param.lvds_mode_enable = 0;
	default_init_param.lvds_rx_onchip_termination_enable = 0;
	default_init_param.full_port_enable = 1;
	default_init_param.digital_interface_tune_fir_disable = 1;
#endif

	ad9361_init(&ad9361_phy, &default_init_param);

	ad9361_set_tx_fir_config(ad9361_phy, tx_fir_config);
	ad9361_set_rx_fir_config(ad9361_phy, rx_fir_config);

#ifdef FMCOMMS5
#ifdef LINUX_PLATFORM
	gpio_init(default_init_param.gpio_sync);
#endif
	gpio_direction(default_init_param.gpio_sync, 1);
	default_init_param.id_no = 1;
	default_init_param.gpio_resetb = GPIO_RESET_PIN_2;
#ifdef LINUX_PLATFORM
	gpio_init(default_init_param.gpio_resetb);
#endif
	default_init_param.gpio_sync = -1;
	default_init_param.gpio_cal_sw1 = -1;
	default_init_param.gpio_cal_sw2 = -1;
	default_init_param.rx_synthesizer_frequency_hz = 2300000000UL;
	default_init_param.tx_synthesizer_frequency_hz = 2300000000UL;
	gpio_direction(default_init_param.gpio_resetb, 1);
	ad9361_init(&ad9361_phy_b, &default_init_param);

	ad9361_set_tx_fir_config(ad9361_phy_b, tx_fir_config);
	ad9361_set_rx_fir_config(ad9361_phy_b, rx_fir_config);
#endif

#ifndef AXI_ADC_NOT_PRESENT
#if defined XILINX_PLATFORM || defined LINUX_PLATFORM
#ifdef DAC_DMA
#ifdef FMCOMMS5
	dac_init(ad9361_phy_b, DATA_SEL_DMA, 0);
#endif
	dac_init(ad9361_phy, DATA_SEL_DMA, 1);
#else
#ifdef FMCOMMS5
	dac_init(ad9361_phy_b, DATA_SEL_DDS, 0);
#endif
	dac_init(ad9361_phy, DATA_SEL_DDS, 1);
#endif
#endif
#endif

#ifdef FMCOMMS5
	ad9361_do_mcs(ad9361_phy, ad9361_phy_b);
#endif

#ifndef AXI_ADC_NOT_PRESENT
#if defined XILINX_PLATFORM && defined CAPTURE_SCRIPT
    // NOTE: To prevent unwanted data loss, it's recommended to invalidate
    // cache after each adc_capture() call, keeping in mind that the
    // size of the capture and the start address must be alinged to the size
    // of the cache line.
	mdelay(1000);
    adc_capture(16384, ADC_DDR_BASEADDR);
    Xil_DCacheInvalidateRange(ADC_DDR_BASEADDR, 16384);
#endif
#endif

#ifdef CONSOLE_COMMANDS
	get_help(NULL, 0);

	while(1)
	{
		console_get_command(received_cmd);
		invalid_cmd = 0;
		for(cmd = 0; cmd < cmd_no; cmd++)
		{
			param_no = 0;
			cmd_type = console_check_commands(received_cmd, cmd_list[cmd].name,
											  param, &param_no);
			if(cmd_type == UNKNOWN_CMD)
			{
				invalid_cmd++;
			}
			else
			{
				cmd_list[cmd].function(param, param_no);
			}
		}
		if(invalid_cmd == cmd_no)
		{
			console_print("Invalid command!\n");
		}
	}
#endif

	printf("Done.\n");

#ifdef TDD_SWITCH_STATE_EXAMPLE
	uint32_t ensm_mode;
	if (!ad9361_phy->pdata->fdd) {
		if (ad9361_phy->pdata->ensm_pin_ctrl) {
			gpio_direction(GPIO_ENABLE_PIN, 1);
			gpio_direction(GPIO_TXNRX_PIN, 1);
			gpio_set_value(GPIO_ENABLE_PIN, 0);
			gpio_set_value(GPIO_TXNRX_PIN, 0);
			udelay(10);
			ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
			printf("TXNRX control - Alert: %s\n",
					ensm_mode == ENSM_MODE_ALERT ? "OK" : "Error");
			mdelay(1000);

			if (ad9361_phy->pdata->ensm_pin_pulse_mode) {
				while(1) {
					gpio_set_value(GPIO_TXNRX_PIN, 0);
					udelay(10);
					gpio_set_value(GPIO_ENABLE_PIN, 1);
					udelay(10);
					gpio_set_value(GPIO_ENABLE_PIN, 0);
					ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
					printf("TXNRX Pulse control - RX: %s\n",
							ensm_mode == ENSM_MODE_RX ? "OK" : "Error");
					mdelay(1000);

					gpio_set_value(GPIO_ENABLE_PIN, 1);
					udelay(10);
					gpio_set_value(GPIO_ENABLE_PIN, 0);
					ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
					printf("TXNRX Pulse control - Alert: %s\n",
							ensm_mode == ENSM_MODE_ALERT ? "OK" : "Error");
					mdelay(1000);

					gpio_set_value(GPIO_TXNRX_PIN, 1);
					udelay(10);
					gpio_set_value(GPIO_ENABLE_PIN, 1);
					udelay(10);
					gpio_set_value(GPIO_ENABLE_PIN, 0);
					ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
					printf("TXNRX Pulse control - TX: %s\n",
							ensm_mode == ENSM_MODE_TX ? "OK" : "Error");
					mdelay(1000);

					gpio_set_value(GPIO_ENABLE_PIN, 1);
					udelay(10);
					gpio_set_value(GPIO_ENABLE_PIN, 0);
					ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
					printf("TXNRX Pulse control - Alert: %s\n",
							ensm_mode == ENSM_MODE_ALERT ? "OK" : "Error");
					mdelay(1000);
				}
			} else {
				while(1) {
					gpio_set_value(GPIO_TXNRX_PIN, 0);
					udelay(10);
					gpio_set_value(GPIO_ENABLE_PIN, 1);
					udelay(10);
					ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
					printf("TXNRX control - RX: %s\n",
							ensm_mode == ENSM_MODE_RX ? "OK" : "Error");
					mdelay(1000);

					gpio_set_value(GPIO_ENABLE_PIN, 0);
					udelay(10);
					ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
					printf("TXNRX control - Alert: %s\n",
							ensm_mode == ENSM_MODE_ALERT ? "OK" : "Error");
					mdelay(1000);

					gpio_set_value(GPIO_TXNRX_PIN, 1);
					udelay(10);
					gpio_set_value(GPIO_ENABLE_PIN, 1);
					udelay(10);
					ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
					printf("TXNRX control - TX: %s\n",
							ensm_mode == ENSM_MODE_TX ? "OK" : "Error");
					mdelay(1000);

					gpio_set_value(GPIO_ENABLE_PIN, 0);
					udelay(10);
					ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
					printf("TXNRX control - Alert: %s\n",
							ensm_mode == ENSM_MODE_ALERT ? "OK" : "Error");
					mdelay(1000);
				}
			}
		} else {
			while(1) {
				ad9361_set_en_state_machine_mode(ad9361_phy, ENSM_MODE_RX);
				ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
				printf("SPI control - RX: %s\n",
						ensm_mode == ENSM_MODE_RX ? "OK" : "Error");
				mdelay(1000);

				ad9361_set_en_state_machine_mode(ad9361_phy, ENSM_MODE_ALERT);
				ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
				printf("SPI control - Alert: %s\n",
						ensm_mode == ENSM_MODE_ALERT ? "OK" : "Error");
				mdelay(1000);

				ad9361_set_en_state_machine_mode(ad9361_phy, ENSM_MODE_TX);
				ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
				printf("SPI control - TX: %s\n",
						ensm_mode == ENSM_MODE_TX ? "OK" : "Error");
				mdelay(1000);

				ad9361_set_en_state_machine_mode(ad9361_phy, ENSM_MODE_ALERT);
				ad9361_get_en_state_machine_mode(ad9361_phy, &ensm_mode);
				printf("SPI control - Alert: %s\n",
						ensm_mode == ENSM_MODE_ALERT ? "OK" : "Error");
				mdelay(1000);
			}
		}
	}
#endif

#ifdef XILINX_PLATFORM
	Xil_DCacheDisable();
	Xil_ICacheDisable();
#endif

#ifdef ALTERA_PLATFORM
	if (altera_bridge_uninit()) {
		printf("Altera Bridge Uninit Error!\n");
		return -1;
	}
#endif

	return 0;
}
Esempio n. 29
0
/***************************************************************************//**
 * @brief main
 *******************************************************************************/
int initAd9361(void) {

	int Status;
	uint64_t Value;
	uint8_t en_dis;

	/*
	 * NOTE: The user has to choose the GPIO numbers according to desired
	 * carrier board. The following configuration is valid for boards other
	 * than the Fmcomms5.
	 */
	default_init_param.gpio_resetb = GPIO_RESET_PIN;
	default_init_param.gpio_sync = -1;
	default_init_param.gpio_cal_sw1 = -1;
	default_init_param.gpio_cal_sw2 = -1;

	/*
	 * Initialize the GPIO
	 */
	gpio_init(GPIO_DEVICE_ID);
	gpio_direction(default_init_param.gpio_resetb, 1);

	/*
	 * Initialize the SPI
	 */
	spi_init(SPI_DEVICE_ID, 1, 0);

	/*
	 * Initialize AD9361
	 */
	Status = ad9361_init(&ad9361_phy, &default_init_param);
	if (Status != 0) {
		xil_printf("Could not initialize AD9361\r\n");
		xil_printf("Status\t%d\r\n", Status);
		return 1;
	}

	/*
	 * Sampling frequency
	 */
	Status = ad9361_set_tx_sampling_freq(ad9361_phy, SAMPLING_FREQ);
	if (Status != 0) {
		xil_printf("Could not set Tx sampling freq.\r\n");
		return 1;
	}
	Status = ad9361_set_rx_sampling_freq(ad9361_phy, SAMPLING_FREQ);
	if (Status != 0) {
		xil_printf("Could not set Rx sampling freq.\r\n");
		return 1;
	}
	/*
	 * Set Tx and Rx FIR
	 */
	Status = ad9361_set_tx_fir_config(ad9361_phy, tx_fir_config);
	if (Status != 0) {
		xil_printf("Could not set Tx FIR\r\n");
		return 1;
	}
	Status = ad9361_set_rx_fir_config(ad9361_phy, rx_fir_config);
	if (Status != 0) {
		xil_printf("Could not set Rx FIR\r\n");
		return 1;
	}
	// Enable both at the same time
	Status = ad9361_set_trx_fir_en_dis(ad9361_phy, 1);
	if (Status != 0) {
		xil_printf("Could not enable Tx and Rx FIR\r\n");
		return 1;
	}
	// Check status
	Status = ad9361_get_tx_fir_en_dis(ad9361_phy, &en_dis);
	if (Status == 0) {
		xil_printf("Tx FIR status\t %d\r\n", en_dis);
	} else {
		xil_printf("Could not get Tx FIR enable\r\n");
		return 1;
	}
	Status = ad9361_get_rx_fir_en_dis(ad9361_phy, &en_dis);
	if (Status == 0) {
		xil_printf("Rx FIR status\t %d\r\n", en_dis);
	} else {
		xil_printf("Could not get Rx FIR enable\r\n");
		return 1;
	}
	/*
	 * Rf bandwidth
	 */
	Status = ad9361_set_tx_rf_bandwidth(ad9361_phy, RF_BW);
	if (Status != 0) {
		xil_printf("Could not set Tx Rf bandwidth\r\n");
		return 1;
	}
	Status = ad9361_set_rx_rf_bandwidth(ad9361_phy, RF_BW);
	if (Status != 0) {
		xil_printf("Could not set Rx Rf bandwidth\r\n");
		return 1;
	}
	/*
	 * Gain control mode
	 */
	Status = ad9361_set_rx_gain_control_mode(ad9361_phy, 0,
			RF_GAIN_SLOWATTACK_AGC);
	if (Status != 0) {
		xil_printf("Could not set Rx gain control mode for channel 0\r\n");
		return 1;
	}
	/*
	 * Hardware gains
	 */
	Status = ad9361_set_rx_rf_gain(ad9361_phy, 0, -10);
	if (Status != 0) {
		xil_printf("Could not set Rx gain for channel 0\r\n");
		return 1;
	}

	Status = ad9361_get_rx_lo_freq(ad9361_phy, &Value);
	if (Status == 0) {
		xil_printf("LO Frequency\t %u \r\n", Value);
	} else {
		xil_printf("Could not get current LO frequency\r\n");
		return 1;
	}

#if ROE_CPRI_SINK == ROE_SINK_DAC
	dac_init(ad9361_phy, DATA_SEL_DMA, 1);
#endif

#ifndef AXI_ADC_NOT_PRESENT
#if defined XILINX_PLATFORM && defined CAPTURE_SCRIPT
	// NOTE: To prevent unwanted data loss, it's recommended to invalidate
	// cache after each adc_capture() call, keeping in mind that the
	// size of the capture and the start address must be alinged to the size
	// of the cache line.
	mdelay(1000);
	adc_capture(16384, ADC_DDR_BASEADDR);
	Xil_DCacheInvalidateRange(ADC_DDR_BASEADDR, 16384);
#endif
#endif

#ifdef CONSOLE_COMMANDS
	get_help(NULL, 0);

	while (1)
	{
		console_get_command(received_cmd);
		invalid_cmd = 0;
		for (cmd = 0; cmd < cmd_no; cmd++)
		{
			param_no = 0;
			cmd_type = console_check_commands(received_cmd, cmd_list[cmd].name,
					param, &param_no);
			if (cmd_type == UNKNOWN_CMD)
			{
				invalid_cmd++;
			}
			else
			{
				cmd_list[cmd].function(param, param_no);
			}
		}
		if (invalid_cmd == cmd_no)
		{
			console_print("Invalid command!\n");
		}
	}
#endif

	printf("AD9361 Initialization Done.\n");

#ifdef XILINX_PLATFORM
	Xil_DCacheDisable();
	Xil_ICacheDisable();
#endif

	return 0;
}
Esempio n. 30
0
int newhelp_loop(int mode)
{

    struct _select_def group_conf;
    int i;
    POINT *pts;

    if (mode < 0 || mode > NUMHELPMODE)
        return -1;

    help_search[0]=0;
    bzero(&group_conf,sizeof(struct _select_def));

    s_help = (struct helps *)malloc(sizeof(struct helps) * BBS_PAGESIZE);
    if (s_help == NULL)
        return -1;
    bzero(s_help, sizeof(struct helps)*BBS_PAGESIZE);

    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
    group_conf.item_per_page = BBS_PAGESIZE;
    group_conf.arg = & mode;
    group_conf.flag = LF_VSCROLL | LF_BELL | LF_MULTIPAGE | LF_LOOP;
    group_conf.prompt = "◆";
    group_conf.item_pos = pts;
    group_conf.title_pos.x = 0;
    group_conf.title_pos.y = 0;
    group_conf.pos=1;
    group_conf.page_pos=1;

    group_conf.on_select = help_select;
    group_conf.show_data = help_show;
    group_conf.pre_key_command = help_prekey;
    group_conf.show_title = help_refresh;
    group_conf.get_data = help_getdata;
    group_conf.key_command = help_key;

    group_conf.item_count = count_help(mode);

    if (group_conf.item_count<=0) {
        free(pts);
        free(s_help);
        if (HAS_PERM(getCurrentUser(), PERM_SYSOP)) {
            add_help(mode, -1);
        } else {
            clear();
            prints("现在没有该状态下帮助,或者系统出错\n");
            pressanykey();
        }
        return -1;
    }

    i = get_help(s_help, mode, 0, BBS_PAGESIZE);

    if (i<=0) {
        free(pts);
        free(s_help);
        clear();
        prints("现在没有该状态下帮助,或者系统出错\n");
        pressanykey();
        return -1;
    }

    help_num = i;
    clear();
    list_select_loop(&group_conf);

    for (i=0; i< help_num; i++) {
        if (s_help[i].content) free(s_help[i].content);
    }
    free(pts);
    free(s_help);
    s_help=NULL;
    help_num=0;

    return 1;

}