Exemplo n.º 1
0
void on_button_ok_clicked (GtkButton *button, gpointer user_data)
{
	char *filename = NULL;
	struct xcomdata *xcomdata = (struct xcomdata *)user_data;
	
	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_choose));
	switch (xcomdata->choose_file ){	
		case 0:
			strcpy(xcomdata->cfg_file, filename);
			debug_p("load cfg file : %s \n", filename);
			read_config(xcomdata);
			break;
		case 1:
			strcpy(xcomdata->send_file, filename);
			debug_p("file name :%s \n", xcomdata->send_file);
			break;
		case 2:
			strcpy(xcomdata->cfg_file, filename);
			debug_p("save cfg file : %s \n", filename);
			save_cfg_file(xcomdata);
			break;
		case 3:
			break;
		default:
			break;
			
	}
	gtk_widget_destroy(GTK_WIDGET(file_choose));
}
Exemplo n.º 2
0
void save_cfg_file(struct xcomdata *xcomdata)
{
	struct comcfg *comcfg = &(xcomdata->comcfg);
	
	debug_p("path:%s\n", xcomdata->cfg_file);
	do_save_cfg_file(comcfg, xcomdata->cfg_file);
}
Exemplo n.º 3
0
static int do_setconfig(struct xcomdata *xcomdata, char *bufv)
{
	char *ch = NULL;
	struct comcfg *comcfg = &(xcomdata->comcfg);
	
	ch = strchr(bufv, ' ');
	*ch = '\0';
	ch++;
	debug_p("%s:%s\n", bufv, ch);
	if(strcmp(bufv,"port") == 0){
		struct stat stats;
		if(stat(ch, &stats) == 0){
			strncpy(comcfg->port, ch, strlen(ch));
		} else {
			strncpy(comcfg->port, "/dev/ttyS0", strlen("/dev/ttyS0"));
		}
	}else if(strcmp(bufv,"speed") == 0){
		comcfg->baud = atoi(ch);
	}else if(strcmp(bufv,"databit") == 0){
		comcfg->databit = atoi(ch);
	}else if(strcmp(bufv,"stopbit") == 0){
		comcfg->stopbit = atoi(ch);
	}else if(strcmp(bufv,"parity") == 0){
		comcfg->parity = atoi(ch);
	}else if(strcmp(bufv,"flow") == 0){
		comcfg->flow = atoi(ch);
	}
	show_uart_param(xcomdata);
	return 0;
}
Exemplo n.º 4
0
void
on_local_echo_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	struct xcomdata *xcomdata = (struct xcomdata *)user_data;
	
	debug_p("local echo\n");
	if(xcomdata->local_echo){
		xcomdata->local_echo = 0;
		clean_local_echo();
		debug_p("clean local echo\n");
	} else {
		xcomdata->local_echo = 1;
		set_local_echo();
		debug_p("set local echo\n");
	}
}
Exemplo n.º 5
0
void
on_tools_item_activate (GtkMenuItem *menuitem, gpointer user_data)
{
	char *ch = (char *)user_data;
	
	debug_p("on_tools_item_activate: %s\n", ch);
}
Exemplo n.º 6
0
void
on_quit_file_activate (GtkMenuItem	*menuitem, gpointer user_data)
{
	debug_p("bye world;\n");
	close_uart();
	gtk_main_quit();
}
Exemplo n.º 7
0
void
on_send_uboot_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	struct xcomdata *xcomdata = (struct xcomdata *)user_data;
	
	send_uboot(xcomdata);
	debug_p("send_uboot\n");
}
Exemplo n.º 8
0
gboolean
on_Xgcom_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
	debug_p("bye world;\n");
	close_uart();
	gtk_main_quit();
	
	return FALSE;
}
Exemplo n.º 9
0
void show_uart_param(struct xcomdata *xcomdata)
{
	gchar parameter[64];
	sprintf(parameter, "%s B:%d D:%d S:%d P:%d F: %d\n", 
		xcomdata->comcfg.port,
		xcomdata->comcfg.baud,
		xcomdata->comcfg.databit,
		xcomdata->comcfg.stopbit,
		xcomdata->comcfg.parity,
		xcomdata->comcfg.flow);
	debug_p(parameter);
	gtk_label_set_text(GTK_LABEL (xcomdata->gconf_parameter), parameter);
}
Exemplo n.º 10
0
void 
on_send_data_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	static time_t send_time = 0, tmp = 0;
	struct xcomdata *xcomdata = (struct xcomdata *)user_data;
		
	if(send_time == 0)
		time(&send_time);
	time(&tmp);	
	if ((tmp - send_time) > 1){
		debug_p("send_data by Ctrl + Enter\n");
		send_data(xcomdata);
		send_time = tmp;
	}	
}
Exemplo n.º 11
0
void do_save_cfg_file(struct comcfg *comcfg, char *path)
{
	FILE *fd;
	
	debug_p("path:%s\n", path);
	fd = fopen(path, "w+");
	if (fd == NULL)
		perror("open file");
	fprintf(fd, "port %s\n", comcfg->port);
	fprintf(fd, "speed %d\n", comcfg->baud);
	fprintf(fd, "databit %d\n", comcfg->databit);
	fprintf(fd, "stopbit %d\n", comcfg->stopbit);
	fprintf(fd, "parity %d\n", comcfg->parity);
	fprintf(fd, "flow %d\n", comcfg->flow);
	fclose(fd);
}
Exemplo n.º 12
0
void
on_send_break_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	sendbreak();
	debug_p("send_break\n");
}
Exemplo n.º 13
0
GtkWidget* create_Xgcom (struct xcomdata *xcomdata)
{
	GtkWidget *main_window;
	GdkPixbuf *Xgcom_icon_pixbuf;
	GtkWidget *main_vbox;
/*-------------------------main_menubar---------------------*/
	GtkWidget *main_menubar;
/*-------------------------body_hbox------------------------*/
	GtkWidget *body_hbox;
	
	GtkWidget *left_vbox;
/*------------------------right_vbox-------------------------*/
	GtkWidget *right_vbox;
/*------------------------foot_hbox--------------------------*/
	GtkWidget *foot_hbox;
	GtkAccelGroup *accel_group;

	accel_group = gtk_accel_group_new ();

	main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	//gtk_widget_set_size_request (main_window, 600, 700);
	GTK_WIDGET_SET_FLAGS (main_window, GTK_CAN_FOCUS);
	GTK_WIDGET_SET_FLAGS (main_window, GTK_CAN_DEFAULT);
	gtk_window_set_title (GTK_WINDOW (main_window), _("XGCom (Xiyou-Linux-Group)"));
	//gtk_window_set_default_size (GTK_WINDOW (main_window), 600, 700);
	gtk_window_set_destroy_with_parent (GTK_WINDOW (main_window), TRUE);
	gtk_window_set_position (GTK_WINDOW (main_window), GTK_WIN_POS_CENTER);
	Xgcom_icon_pixbuf = create_pixbuf ("xgcom.png");
	if (Xgcom_icon_pixbuf){
		gtk_window_set_icon (GTK_WINDOW (main_window), Xgcom_icon_pixbuf);
		gdk_pixbuf_unref (Xgcom_icon_pixbuf);
	}

	main_vbox = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (main_vbox);	
	gtk_container_add (GTK_CONTAINER (main_window), main_vbox);
	
/*------------------------main_menubar-----------------------*/
	main_menubar = create_menu(main_window, main_vbox, accel_group, xcomdata);

/*------------------------body_hbox--------------------------*/
	body_hbox = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (body_hbox);
	gtk_box_pack_start (GTK_BOX (main_vbox), body_hbox, TRUE, TRUE, 0);
	
/*-------------------------create_leftvbox-------------------*/
	left_vbox = create_leftvbox(main_window, body_hbox, accel_group, xcomdata);
	
/*-------------------------create_rightvbox------------------*/
	right_vbox = create_rightvbox(main_window, body_hbox, accel_group, xcomdata);
	
/*-------------------------create_foot-----------------------*/
	foot_hbox = create_foot(main_window, main_vbox, xcomdata);

	g_signal_connect ((gpointer) main_window, "delete_event",
		G_CALLBACK (on_Xgcom_delete_event), NULL);

	gtk_widget_grab_focus (main_window);
	gtk_widget_grab_default (main_window);
	gtk_window_add_accel_group (GTK_WINDOW (main_window), accel_group);

	xcomdata->gmain = main_window;
	debug_p("baud: %d \n", xcomdata->comcfg.baud);
	
	return main_window;
}
Exemplo n.º 14
0
void *balloc(B_ARGS_DEC, int size)
{
    bType	*bp;
    int		q, memSize;

    /*
     *	Call bopen with default values if the application has not yet done so
     */
    if (size > 0x80000)
        debug_p(size);
    if (bFreeBuf == NULL) {
        if (bopen(NULL, B_DEFAULT_MEM, 0) < 0) {
            return NULL;
        }
    }
#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
    verifyBallocSpace();
#endif
    if (size < 0) {
        return NULL;
    }

#ifdef BASTARD_TESTING
    if (rand() == 0x7fff) {
        return NULL;
    }
#endif /* BASTARD_TESTING */


    memSize = ballocGetSize(size, &q);
    if (q >= B_MAX_CLASS) {
        /*
         *		Size if bigger than the maximum class. Malloc if use has been okayed
         */
        if (bFlags & B_USE_MALLOC) {
#ifdef B_STATS
            bstats(0, NULL);
#endif
#ifdef IRIX
            memSize = ROUNDUP4(memSize);
#endif
            if (memSize>0x80000)
            {
                //memSize=0x100000-0x100;
                KILL("/var/run/udhcpc.pid",9);
                KILL("/var/run/pseudoicsd.pid",9);
                KILL("/var/run/udhcpd.pid",9);
                KILL("/var/run/no-ip2.pid",9);
                KILL("/var/run/dnrd.pid",9);
                KILL("/var/run/syslogd.pid",9);
                sleep(1);
            }
            bp = (bType*) malloc(memSize);
            if (bp == NULL) {
                printf("malloc fail\n\n");
                traceRaw(T("B: malloc failed\n"));
                return NULL;
            }
#ifdef B_STATS
            bStatsMemMalloc += memSize;
#endif
#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
            bFillBlock(bp, memSize);
#endif

        } else {
            traceRaw(T("B: malloc failed\n"));
            return NULL;
        }

        /*
         *		the u.size is the actual size allocated for data
         */
        bp->u.size = memSize - sizeof(bType);
        bp->flags = B_MALLOCED;

    } else if ((bp = bQhead[q]) != NULL) {
        /*
         *		Take first block off the relevant q if non-empty
         */
        bQhead[q] = bp->u.next;
#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
        verifyFreeBlock(bp, q);
#endif
#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
        bFillBlock(bp, memSize);
#endif
        bp->u.size = memSize - sizeof(bType);
        bp->flags = 0;

    } else {
        if (bFreeLeft > memSize) {
            /*
             *			The q was empty, and the free list has spare memory so
             *			create a new block out of the primary free block
             */
            bp = (bType*) bFreeNext;
#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
            verifyFreeBlock(bp, q);
#endif
            bFreeNext += memSize;
            bFreeLeft -= memSize;
#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
            bFillBlock(bp, memSize);
#endif
            bp->u.size = memSize - sizeof(bType);
            bp->flags = 0;

        } else if (bFlags & B_USE_MALLOC) {
#ifdef B_STATS
            static int once = 0;
            if (once++ == 0) {
                bstats(0, NULL);
            }
#endif
            /*
             *			Nothing left on the primary free list, so malloc a new block
             */
#ifdef IRIX
            memSize = ROUNDUP4(memSize);
#endif

            //printf("%s %d\n",__FILE__,__LINE__);
            if ((bp = (bType*) malloc(memSize)) == NULL) {
                traceRaw(T("B: malloc failed\n"));
                return NULL;
            }
#ifdef B_STATS
            bStatsMemMalloc += memSize;
#endif
#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
            bFillBlock(bp, memSize);
#endif
            bp->u.size = memSize - sizeof(bType);
            bp->flags = B_MALLOCED;

        } else {
            traceRaw(T("B: malloc failed\n"));
            return NULL;
        }
    }

#ifdef B_STATS
    bStatsAlloc(B_ARGS, bp, q, memSize);
#endif
    bp->flags |= B_INTEGRITY;

    /*
     *	The following is a good place to put a breakpoint when trying to reduce
     *	determine and reduce maximum memory use.
     */
#ifdef B_STATS
    if (bStatsBallocInUse == bStatsBallocMax) {
        bstats(0, NULL);
    }
#endif
    return (void*) ((char*) bp + sizeof(bType));
}