Пример #1
0
static int		recv_backup	(CalcHandle* handle, BackupContent* content)
{
	char varname[9] = { 0 };

	g_snprintf(update_->text, sizeof(update_->text), _("Waiting for backup..."));
    update_label();

	content->model = CALC_TI86;
	strcpy(content->comment, tifiles_comment_set_backup());

    TRYF(ti85_recv_VAR(&(content->data_length1), &content->type, varname));
    content->data_length2 = (uint8_t)varname[0] | ((uint8_t)varname[1] << 8);
    content->data_length3 = (uint8_t)varname[2] | ((uint8_t)varname[3] << 8);
    content->data_length4 = (uint8_t)varname[4] | ((uint8_t)varname[5] << 8);
    TRYF(ti85_send_ACK());

    TRYF(ti85_send_CTS());
    TRYF(ti85_recv_ACK(NULL));

    strcpy(update_->text, "");
	update_label();

	update_->cnt2 = 0;
	update_->max2 = 4;
	update_->pbar();

    content->data_part1 = tifiles_ve_alloc_data(65536);
    TRYF(ti85_recv_XDP(&content->data_length1, content->data_part1));
    TRYF(ti85_send_ACK());
    update_->cnt2++;
	update_->pbar();

    content->data_part2 = tifiles_ve_alloc_data(65536);
    TRYF(ti85_recv_XDP(&content->data_length2, content->data_part2));
    TRYF(ti85_send_ACK());
    update_->cnt2++;
	update_->pbar();

    if (content->data_length3) 
	{
      content->data_part3 = tifiles_ve_alloc_data(65536);
      TRYF(ti85_recv_XDP(&content->data_length3, content->data_part3));
      TRYF(ti85_send_ACK());
    } else
      content->data_part3 = NULL;
    update_->cnt2++;
	update_->pbar();

    content->data_part4 = tifiles_ve_alloc_data(65536);
    TRYF(ti85_recv_XDP(&content->data_length4, content->data_part4));
    TRYF(ti85_send_ACK());
    update_->cnt2++;
	update_->pbar();

	return 0;
}
Пример #2
0
static int		recv_var	(CalcHandle* handle, CalcMode mode, FileContent* content, VarRequest* vr)
{
	uint16_t unused;
	VarEntry *ve;
	char *utf8;
	uint16_t ve_size;

	content->model = CALC_TI86;
	strcpy(content->comment, tifiles_comment_set_single());
	content->num_entries = 1;
	content->entries = tifiles_ve_create_array(1);
	ve = content->entries[0] = tifiles_ve_create();
	memcpy(ve, vr, sizeof(VarEntry));

	utf8 = ticonv_varname_to_utf8(handle->model, vr->name, vr->type);
	g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
	update_label();

	// silent request
	TRYF(ti85_send_REQ((uint16_t)vr->size, vr->type, vr->name));
	TRYF(ti85_recv_ACK(&unused));

	TRYF(ti85_recv_VAR(&ve_size, &ve->type, ve->name));
	ve->size = ve_size;
	TRYF(ti85_send_ACK());

	TRYF(ti85_send_CTS());
	TRYF(ti85_recv_ACK(NULL));

	ve->data = tifiles_ve_alloc_data(ve->size);
	TRYF(ti85_recv_XDP(&ve_size, ve->data));
	ve->size = ve_size;
	TRYF(ti85_send_ACK());

	return 0;
}
Пример #3
0
static int		recv_var_ns	(CalcHandle* handle, CalcMode mode, FileContent* content, VarEntry** vr)
{
  int nvar = 0;
  int err = 0;
  char *utf8;
  uint16_t ve_size;

  g_snprintf(update_->text, sizeof(update_->text), _("Waiting for var(s)..."));
  update_label();

  content->model = CALC_TI85;

  for (nvar = 0;; nvar++) 
  {
    VarEntry *ve;

    content->entries = tifiles_ve_resize_array(content->entries, nvar+1);
    ve = content->entries[nvar] = tifiles_ve_create();;

    do 
	{
      update_refresh();
      if (update_->cancel)
		return ERR_ABORT;

      err = ti85_recv_VAR(&ve_size, &(ve->type), ve->name);
      ve->size = ve_size;
    }
    while (err == ERROR_READ_TIMEOUT);

    TRYF(ti85_send_ACK());
    if (err == ERR_EOT) 
      goto exit;
    TRYF(err);

    TRYF(ti85_send_CTS());
    TRYF(ti85_recv_ACK(NULL));

	utf8 = ticonv_varname_to_utf8(handle->model, ve->name, ve->type);
    g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
    update_label();

    ve->data = tifiles_ve_alloc_data(ve->size);
    TRYF(ti85_recv_XDP(&ve_size, ve->data));
    ve->size = ve_size;
    TRYF(ti85_send_ACK());
  }

exit:
  content->num_entries = nvar;
  if(nvar == 1)
  {
	strcpy(content->comment, tifiles_comment_set_single());
	*vr = tifiles_ve_dup(content->entries[0]);
  }
  else
  {
	strcpy(content->comment, tifiles_comment_set_group());
	*vr = NULL;
  }

  return 0;
}