Exemplo n.º 1
0
Arquivo: gui.c Projeto: awe00/boards
gint do_reboot(GtkWidget *widget, gpointer *data)
{
	if (download_in_progress) {
		download_cancel(NULL);
		gtk_widget_set_sensitive(program_button, FALSE);
		gtk_widget_set_sensitive(reboot_button, FALSE);
		gtk_widget_set_sensitive(bootloader_button, FALSE);
	}
	gtk_widget_set_sensitive(program_button, FALSE);
	gtk_widget_set_sensitive(reboot_button, FALSE);
	gtk_widget_set_sensitive(bootloader_button, FALSE);

	hard_reset_to_user_code();

#if 0
	download_in_progress = 1;
	soft_reboot_begin();
#endif
	if (file_exists(gtk_entry_get_text(GTK_ENTRY(firmware_entry)))) {
		gtk_widget_set_sensitive(program_button, TRUE);
	} else {
		gtk_widget_set_sensitive(program_button, FALSE);
	}
	gtk_widget_set_sensitive(bootloader_button, TRUE);
	return FALSE;
}
Exemplo n.º 2
0
int init()
{
    int result = open_serial_port(port_name);
    pthread_create(&serial_reader, NULL, serial_reader_func, NULL);
    hard_reset_to_user_code();
    return result;
}
Exemplo n.º 3
0
int border_initialize(char *if_name, const char *ip_addr, const char *tty_dev)
{
    int res, i;
    char command[21 + IPV6_ADDR_LEN + IF_NAME_LEN];
    char ip_addr_cpy[IPV6_ADDR_LEN];
    struct in6_addr parsed_addr;

    strncpy(ip_addr_cpy, ip_addr, IPV6_ADDR_LEN);

    strtok(ip_addr_cpy, "/");

    if ((res = inet_pton(AF_INET6, ip_addr_cpy, &parsed_addr)) != 1) {
        return res;
    }

    if ((res = init_multiplex(tty_dev)) != 0) {
        return res;
    }

    tun_fd = open_tun(if_name, IFF_TUN);

    printf("INFO: ip link set %s up\n", if_name);
    sprintf(command, "ip link set %s up", if_name);

    strncpy(tun_if_name, if_name, IF_NAME_LEN);

    if ((res = system(command)) != 0) {
        return res;
    }

    if ((res = tun_add_addr(ip_addr)) != 0) {
        return res;
    }

    // initialize context cache as empty.
    for (i = 0; i < MAXIMUM_CONTEXTS; i++) {
        context_cache[i].cid = 0xFF;
    }

    pthread_create(&serial_reader, NULL, serial_reader_f, NULL);

    hard_reset_to_user_code();
    flowcontrol_init(&parsed_addr);
    pthread_create(&tun_reader, NULL, tun_reader_f, NULL);

    return 0;
}