int server_init(struct command_context *cmd_ctx) { int ret = tcl_init(); if (ERROR_OK != ret) return ret; return telnet_init("Open On-Chip Debugger"); }
void tcl_run(char *script) { if (tcl_startup == 0) { tcl_init(); } tcl_update_modeldata(); if (Tcl_Eval(tcl_interp, script) != TCL_OK) { SDL_Log("TCL-ERROR:\n"); SDL_Log("#######################################################\n"); SDL_Log("%s\n", script); SDL_Log("#######################################################\n"); SDL_Log("%s\n", Tcl_GetStringResult(tcl_interp)); SDL_Log("#######################################################\n"); } }
void tcl_runFile(char *file) { if (tcl_startup == 0) { tcl_init(); TclUpdateVarString("BASE_DIR", BASE_DIR); } tcl_update_modeldata(); if (Tcl_EvalFile(tcl_interp, file) != TCL_OK) { SDL_Log("TCL-ERROR:\n"); SDL_Log("#######################################################\n"); SDL_Log("%s\n", file); SDL_Log("#######################################################\n"); SDL_Log("%s\n", Tcl_GetStringResult(tcl_interp)); SDL_Log("#######################################################\n"); } }
int server_init(struct command_context *cmd_ctx) { int ret = tcl_init(); if (ret != ERROR_OK) return ret; ret = telnet_init("Open On-Chip Debugger"); if (ret != ERROR_OK) { remove_services(); return ret; } return ERROR_OK; }
int main(int argc, char *argv[]) { tcl_buffer buf; int fd; int return_value; tcl_color *p; int i; struct timeval start_time; unsigned long *change_times; unsigned long current_time; /* Open the device file using Low-Level IO */ fd = open(device,O_WRONLY); if(fd<0) { fprintf(stderr,"Error %d: %s\n",errno,strerror(errno)); exit(1); } /* Initialize the SPI bus for Total Control Lighting */ return_value = spi_init(fd); if(return_value==-1) { fprintf(stderr,"SPI initialization error %d: %s\n",errno, strerror(errno)); exit(1); } /* Initialize pixel buffer */ if(tcl_init(&buf,leds)<0) { fprintf(stderr,"Pixel buffer initialization error: Not enough memory.\n"); exit(1); } /* Set the gamma correction factors for each color */ set_gamma(2.2,2.2,2.2); /* Get the current time */ return_value = gettimeofday(&start_time,NULL); if(return_value==-1) { fprintf(stderr, "Error reading the current time: %s\n", strerror(errno)); exit(1); } /* Set scattered intervals for the lights to change */ /* Set all pixels to black */ change_times = (unsigned long *)malloc(leds*sizeof(unsigned long)); if(change_times==NULL) { fprintf(stderr, "Error allocating array of change times.\n"); exit(1); } for(i=0;i<leds;i++) { change_times[i] = min_interval+random()%(max_interval-min_interval); write_gamma_color(&buf.pixels[i],0x00,0x00,0x00); } send_buffer(fd,&buf); /* Prepare to receive ctrl-c to stop looping */ continue_looping = 1; signal(SIGINT,stop_program); /* Loop while continue_looping is true */ while(continue_looping) { current_time = microseconds_since(&start_time); for(i=0;i<leds;i++) { if(current_time>change_times[i]) { p = &buf.pixels[i]; if(p->red==0x00 && p->blue==0x00 && p->green==0x00) { write_gamma_color(p,(int)random()%256,(int)random()%256,(int)random%256); } else { write_gamma_color(p,0x00,0x00,0x00); } change_times[i]=current_time+min_interval+random()%(max_interval-min_interval); } } send_buffer(fd,&buf); } tcl_free(&buf); free(change_times); close(fd); printf("Program Terminated.\n"); return 0; }
int main(int argc, char *argv[]) { int fd; /* SPI device file descriptor */ const int leds = 50; /* 50 LEDs in the strand */ tcl_buffer buf; /* Memory buffer for pixel values */ int count; /* Count of iterations (up to 3) */ int i; /* Counting Integer */ /* Open SPI device */ fd = open(device,O_WRONLY); if(fd<0) { /* Open failed */ fprintf(stderr, "Error: SPI device open failed.\n"); exit(1); } /* Initialize SPI bus for TCL pixels */ if(spi_init(fd)<0) { /* Initialization failed */ fprintf(stderr, "Unable to initialize SPI bus.\n"); exit(1); } /* Allocate memory for the pixel buffer and initialize it */ if(tcl_init(&buf,leds)<0) { /* Memory allocation failed */ fprintf(stderr, "Insufficient memory for pixel buffer.\n"); exit(1); } /* Loop Forever */ while(1) { /* Do three iterations */ for(count=0;count<3;count++) { /* Write color for every pixel */ for(i=0;i<leds;i++) { if((i+count)%3==0) { /* Red pixel */ write_color(&buf.pixels[i],255,0,0); } else if((i+count)%3==1) { /* Green pixel */ write_color(&buf.pixels[i],0,255,0); } else { /* Blue pixel */ write_color(&buf.pixels[i],0,0,255); } } /* Send the data to the TCL lighting strand */ if(send_buffer(fd,&buf)<0) { fprintf(stderr, "Error sending data.\n"); exit(1); } /* Sleep for 1 second */ usleep(1000000); } } /* Although the program never gets to this point, below is how to clean up */ /* Free the pixel buffer */ tcl_free(&buf); /* Close the SPI device */ close(fd); return 0; }
/* OpenOCD can't really handle failure of this command. Patches welcome! :-) */ int handle_init_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc!=0) return ERROR_COMMAND_SYNTAX_ERROR; int retval; static int initialized=0; if (initialized) return ERROR_OK; initialized=1; atexit(exit_handler); if (target_init(cmd_ctx) != ERROR_OK) return ERROR_FAIL; LOG_DEBUG("target init complete"); if ((retval=jtag_interface_init(cmd_ctx)) != ERROR_OK) { /* we must be able to set up the jtag interface */ return retval; } LOG_DEBUG("jtag interface init complete"); /* Try to initialize & examine the JTAG chain at this point, but * continue startup regardless */ if (jtag_init(cmd_ctx) == ERROR_OK) { LOG_DEBUG("jtag init complete"); if (target_examine() == ERROR_OK) { LOG_DEBUG("jtag examine complete"); } } if (flash_init_drivers(cmd_ctx) != ERROR_OK) return ERROR_FAIL; LOG_DEBUG("flash init complete"); if (mflash_init_drivers(cmd_ctx) != ERROR_OK) return ERROR_FAIL; LOG_DEBUG("mflash init complete"); if (nand_init(cmd_ctx) != ERROR_OK) return ERROR_FAIL; LOG_DEBUG("NAND init complete"); if (pld_init(cmd_ctx) != ERROR_OK) return ERROR_FAIL; LOG_DEBUG("pld init complete"); /* initialize tcp server */ server_init(); /* initialize telnet subsystem */ telnet_init("Open On-Chip Debugger"); gdb_init(); tcl_init(); /* allows tcl to just connect without going thru telnet */ target_register_event_callback(log_target_callback_event_handler, cmd_ctx); return ERROR_OK; }