Example #1
0
/* This function is invoked by the main CAmkES thread in this component. */
int run(void)
{
    int error = camkes_io_port_ops(&io_port_ops);
    assert(!error);

    /* Use the dataport address */
    void *bga_ptr = (void *)mock_hdmi;

    bga = bga_init(bga_ptr, out16, in16);
    bga_set_mode(bga, 1024, 768, 24); /* 1024x768 resolution at 24 BPP */

    ringbuffer_t *low = rb_new((void *)low_input, sizeof(*low_input));
    if (low == NULL) {
        abort();
    }

    ringbuffer_t *high = rb_new((void *)high_input, sizeof(*high_input));
    if (high == NULL) {
        abort();
    }

    borders();

    /* Check both inputs for data and pass it to the relevant framebuffer. */
    while (true) {
        char c;

        if ((c = (char)rb_poll_byte(low)) != 0) {
            write_low(c);
        }

        if ((c = (char)rb_poll_byte(high)) != 0) {
            write_high(c);
        }
    }

    return 0;
}
Example #2
0
static void draw_race()
{
	 char file[5];
	 char files[20];
	 int s1,s2;

	 ttk_blit_image (map.image,iracer_srf,0,0); //Map 
	
	 ttk_blit_image (car[cpos],iracer_srf,ipods[(map.xstart+(xoff*speed))],ipods[(map.ystart+(yoff*speed))]); //Car
	 	
	 if(count>0){ //3,2,1 
		 sprintf(file,"%d",count);	
		 pz_vector_string_center(iracer_srf, file, ipods[160], ipods[100], ipods[((z<<2)+z)], ipods[((z<<2)+z)],1, ttk_makecol(BLACK));
		if(z==5){ttk_click_ex(100, 150);}
	 }  
	 else if(count>-1){ //GO
		 sprintf(file,"GO");	
		 pz_vector_string_center(iracer_srf, file, ipods[160], ipods[100], ipods[((z<<2)+z)], ipods[((z<<2)+z)],1, ttk_makecol(BLACK)); wall2=0;
		lphold=1;
		if(z==5){ttk_click_ex(50,250);}
	 }

	if(fina==1&&(timed-(times/11))>0&&settings.gdif==0||(fina==1&&settings.gdif==0&&timed==0)){
	  	sprintf(files,"FINISHED");	
		pz_vector_string_center(iracer_srf, files, ipods[160], ipods[100], ipods[20], 
		ipods[(20*z)],1, ttk_makecol(BLACK));
		write_high();
	}
	else if(fina==1&&settings.gdif==0){
	  	sprintf(files,"FAILED");	
		pz_vector_string_center(iracer_srf, files, ipods[160], ipods[100], ipods[20], 
		ipods[(20*z)],1, ttk_makecol(BLACK));
	}
	else if(fina==1){
	  	sprintf(files,"FINISHED");	
		pz_vector_string_center(iracer_srf, files, ipods[160], ipods[100], ipods[20], 
		ipods[(20*z)],1, ttk_makecol(BLACK));
	}

	 ttk_fillrect (iracer_srf, 0, ipods[220], ipods[320], ipods[240], ttk_makecol(BLACK));

 
	 sprintf(files,"Lap %d of %d",lap,set_laps[settings.laps]);	
	 pz_vector_string(iracer_srf, files, ipods[5], ipods[225] , ipods[8],ipods[14], 1, ttk_makecol(WHITE));


	if(settings.gdif==1||(settings.gdif==0&&timed==0)){
			s1 = times/11;
			s2 = (times/11)*10;
			s2 = s2 % 10;
	 sprintf(files,"Time %2d.%1d secs", s1,s2);	
	 pz_vector_string(iracer_srf, files, ipods[150], ipods[225] , ipods[8] ,ipods[14] , 1, ttk_makecol(WHITE));
	}
	else if(settings.gdif==0){
		if(timed-(times/11)<=0)
			sprintf(files,"Time 0.0 secs");
		else{	
			s1 = timed- (times/11);
			s2 = (timed-(times/11))*10;
			s2 = s2 % 10;

		sprintf(files,"Time %2d.%1d secs",s1,s2);}	
	 pz_vector_string(iracer_srf, files, ipods[150], ipods[225] , ipods[8] ,ipods[14] , 1, ttk_makecol(WHITE));
	}
	  
}
int main(int argc, char* argv[])
{
    int opt, option_index;
    int test_num  = -1;
    int level = -1;
    context_t ctx = NULL;
    security_context_t ctx_check = NULL;
    char *path = NULL;
    char *log_path = NULL;
    time_t t;

    static struct option long_options[] = {
      {"output",  required_argument, 0, 'o'},
      {"test",    required_argument, 0, 't'},
      {"file",    required_argument, 0, 'f'},
      {0, 0, 0, 0}
    };
    
    while ((opt = getopt_long(argc, argv, "o:t:f:",
                              long_options, &option_index)) != -1)
    {
        switch (opt) {            
            case 'o':
                log_path = optarg;
                if (freopen(log_path, "a+", stdout) == NULL) {
                    exit(-1);
                }
                if (freopen(log_path, "a+", stderr) == NULL) {
                    exit(-1);
                }
                break;
            case 't':
                test_num = atoi(optarg);
                break;
            case 'f':
                path = optarg;
                break;
            default:
                printf("bad argument.\n");
                exit(-1);
            }
    }     

    if (test_num == -1) {
        printf("no test specified.\n");
        exit(-1);
    } else if (path == NULL) {
        printf("no path specified.\n");
        exit(-1);
    }

    time(&t);
    printf("\n%s", ctime(&t));
    getcon(&ctx_check);
    printf("Context: '%s'\n", ctx_check); 
    ctx = context_new(ctx_check);
    const char *range = context_range_get(ctx);

    if (strncmp(LVL_HIGH"-", range, sizeof(LVL_HIGH"-")-1) == 0) {
        level = AT_HIGH;
        printf("process is at high\n");
    } else if (strncmp(LVL_LOW"-", range, sizeof(LVL_LOW"-")-1) == 0) {
        level = AT_LOW;
        printf("process is at low\n");
    } else {
        printf("unexpected level\n");
        exit(-1);
    }

    fflush(stdout); fflush(stderr);

    switch(test_num) {
        case 1:
            read_low(level, path);
            break;
        case 2:
            read_high(level, path);
            break;
        case 3:
            write_low(level, path);
            break;
        case 4:
            write_high(level, path);
            break;
        default:
            printf("invalid test chosen\n");
            exit(-1);
            break;
    }
    return 0;
}