Ejemplo n.º 1
0
static int get_file_size(struct thread_data *td, struct fio_file *f)
{
	int ret = 0;

	if (fio_file_size_known(f))
		return 0;

	if (f->filetype == FIO_TYPE_FILE)
		ret = file_size(td, f);
	else if (f->filetype == FIO_TYPE_BD)
		ret = bdev_size(td, f);
	else if (f->filetype == FIO_TYPE_CHAR)
		ret = char_size(td, f);
	else
		f->real_file_size = -1;

	if (ret)
		return ret;

	if (f->file_offset > f->real_file_size) {
		log_err("%s: offset extends end (%llu > %llu)\n", td->o.name,
					(unsigned long long) f->file_offset,
					(unsigned long long) f->real_file_size);
		return 1;
	}

	fio_file_set_size_known(f);
	return 0;
}
Ejemplo n.º 2
0
void
label_size(const char *str, struct pack_label * l, int* width, int* height) {
	char utf8[7];
	int i;
	int w=0, max_w=0, h=0, max_h=0;
	for (i=0; str[i];) {
		int unicode;
		int len = unicode_len(str[i]);
		unicode = copystr(utf8, str+i, len);
		i+=len;
		struct font_context ct = char_size(unicode, utf8, l->size, l->edge);
		w += ct.w + l->space_w;
		if (h==0) {
			h = ct.h + l->space_h;
		}
		if((l->auto_scale == 0 && w > l->width) || unicode == '\n') {
			max_h += h;
			h = 0;
			if (w > max_w) max_w = w;
			w = 0;
		}
	}

	max_h += h;
	if (w > max_w) max_w = w;
    if (l->auto_scale > 0 && max_w > l->width)
        max_w = l->width;
   
	*width = max_w;
	*height = max_h;
}
Ejemplo n.º 3
0
int
label_char_size(struct pack_label* l, const char* chr, int* width, int* height, int* unicode) {
	char utf8[7];
	int len = unicode_len(chr[0]);
	*unicode = copystr(utf8, chr, len);
	struct font_context ct = char_size(*unicode, utf8, l->size, l->edge);
	*width = ct.w + l->space_w;
	*height = ct.h + l->space_h;
	return len;
}
Ejemplo n.º 4
0
static int
raw_width(const char * str,  struct pack_label * l) {
	char utf8[7];
	int i;
	int w=0;
	for (i=0; str[i];) {
		int len = unicode_len(str[i]);
		int unicode = copystr(utf8, str+i, len);
		i+=len;
		struct font_context ct = char_size(unicode, utf8, l->size, l->edge);
		w += ct.w + l->space_w;
	}
	return w;
}
Ejemplo n.º 5
0
void
label_size(const char *str, struct pack_label * l, int* width, int* height) {
	char utf8[7];
	int i;
	int w=0, max_w=0, h=0, max_h=0;
	for (i=0; str[i];) {
		int unicode;
		uint8_t c = (uint8_t)str[i];
		if ((c&0x80) == 0) {
			unicode = copystr(utf8,str+i,1);
			i+=1;
		} else if ((c&0xe0) == 0xc0) {
			unicode = copystr(utf8,str+i,2);
			i+=2;
		} else if ((c&0xf0) == 0xe0) {
			unicode = copystr(utf8,str+i,3);
			i+=3;
		} else if ((c&0xf8) == 0xf0) {
			unicode = copystr(utf8,str+i,4);
			i+=4;
		} else if ((c&0xfc) == 0xf8) {
			unicode = copystr(utf8,str+i,5);
			i+=5;
		} else {
			unicode = copystr(utf8,str+i,6);
			i+=6;
		}
		struct font_context ct = char_size(unicode, utf8, l->size);
		w += ct.w + l->space_w;
		if (h==0) {
			h = ct.h + l->space_h;
		}
		if((l->auto_scale == 0 && w > l->width) || unicode == '\n') {
			max_h += h;
			h = 0;
			if (w > max_w) max_w = w;
			w = 0;
		}
	}

	max_h += h;
	if (w > max_w) max_w = w;
    if (l->auto_scale > 0 && max_w > l->width)
        max_w = l->width;
   
	*width = max_w;
	*height = max_h;
}
Ejemplo n.º 6
0
int
label_rawline(const char * str, struct pack_label *l) {
	char utf8[7];
	int i;
	int w=0;
	for (i=0; str[i];) {
		int len = unicode_len(str[i]);
		int unicode = copystr(utf8, str+i, len);
		struct font_context ct = char_size(unicode, utf8, l->size, l->edge);
		if (w+ct.w > l->width) {
			break;
		}
		i+=len;
		w += ct.w + l->space_w;
	}
	return i;
}
Ejemplo n.º 7
0
void main()
{
  badge_setup();
  simpleterm_close();
  ir_start();
  ee_wipe();
  
  // Connection to host routine (FORCE CONNECTION TO HOST)
  port = fdserial_open(31, 30, 0, 115200);
  char_size(SMALL);
  cursor(2, 4);
  display("Connecting...");
  while(1)
  {
    dprint(port, "Propeller\n");
    pause(1000);  // We need this pause, since the host needs time to respond. 5 x 1 second = 10 second timeout
    if (fdserial_rxCount(port) == 0)
    {
      continue;
    }      
    else if (fdserial_rxCount(port) < 5)
    {
      fdserial_rxFlush(port);
      continue;
    }
    else dscan(port, "%s", handshake);
    // Attempt handshake and listen to response
    if (strcmp(handshake, "H0st") == 0)
    {
      break;
    }      
  }
  clear();
  
  while(1)
  {
    rgb(L, OFF);
    rgb(R, OFF);
        
    char_size(BIG);
    cursor(0, 0);
    display("HOTSPOT!");
    char_size(SMALL);
    cursor(4, 5);
    display("Start an");
    cursor(1, 6);
    display("interaction to");
    cursor(0, 7);
    display("upload your data");
    
    memset(&their, 0, sizeof(info));
    
    int t = CNT;
    int dt = CLKFREQ * 2;
    
    if (check_inbox() == 1)
    {
      clear();
      message_get(&their);
      ir_send(&my);
      
      char_size(SMALL);
      cursor(2, 2);
      display("Receiving...");
      
      while(1)
      {
        if (CNT - t > dt)
        {
          clear();
          char_size(SMALL);
          cursor(5, 2);
          display("ERROR!");
          cursor(0, 5);
          display("Please try again");
          dprint(port, "txBegin\n");  
          dprint(port, "Timeout\n");
          ee_wipe();
          clear_inbox();
          pause(2000);
          clear();
          break;
        }
        if (check_inbox() == 1)
        {
          t = CNT;
          message_get(&their);
          if(!strcmp(their.name, "txDone"))
          {
            char_size(SMALL);
            cursor(0, 5);
            display("Upload complete");
            dprint(port, "txBegin\n");
            ee_uploadContacts(port);
            ee_wipe();
            clear_inbox();
            pause(1000);
            clear();
            break;
          }
          ee_save(&their);
          dprint(port, "Name: %s\n", their.name);
          dprint(port, "Email: %s\n", their.email);       
        }
      }        
    }      
  }    
}