static int send_backup (CalcHandle* handle, BackupContent* content) { uint16_t length; char varname[9]; uint8_t rej_code; uint16_t status; length = content->data_length1; varname[0] = LSB(content->data_length2); varname[1] = MSB(content->data_length2); varname[2] = LSB(content->data_length3); varname[3] = MSB(content->data_length3); varname[4] = LSB(content->mem_address); varname[5] = MSB(content->mem_address); TRYF(ti82_send_RTS(handle, content->data_length1, TI83_BKUP, varname)); TRYF(ti82_recv_ACK(handle, &status)); TRYF(ti82_recv_SKP(handle, &rej_code)) TRYF(ti82_send_ACK(handle)); switch (rej_code) { case REJ_EXIT: case REJ_SKIP: return ERR_ABORT; case REJ_MEMORY: return ERR_OUT_OF_MEMORY; default: // RTS break; } update_->cnt2 = 0; update_->max2 = 3; update_->pbar(); TRYF(ti82_send_XDP(handle, content->data_length1, content->data_part1)); TRYF(ti82_recv_ACK(handle, &status)); update_->cnt2++; update_->pbar(); TRYF(ti82_send_XDP(handle, content->data_length2, content->data_part2)); TRYF(ti82_recv_ACK(handle, &status)); update_->cnt2++; update_->pbar(); TRYF(ti82_send_XDP(handle, content->data_length3, content->data_part3)); TRYF(ti82_recv_ACK(handle, &status)); update_->cnt2++; update_->pbar(); TRYF(ti82_send_ACK(handle)); return 0; }
static int send_var (CalcHandle* handle, CalcMode mode, FileContent* content) { int i; uint8_t rej_code; uint16_t status; char *utf8; update_->cnt2 = 0; update_->max2 = content->num_entries; for (i = 0; i < content->num_entries; i++) { VarEntry *entry = content->entries[i]; if(entry->action == ACT_SKIP) continue; TRYF(ti82_send_RTS(handle, (uint16_t)entry->size, entry->type, entry->name)); TRYF(ti82_recv_ACK(handle, &status)); TRYF(ti82_recv_SKP(handle, &rej_code)); TRYF(ti82_send_ACK(handle)); switch (rej_code) { case REJ_EXIT: return ERR_ABORT; case REJ_SKIP: continue; case REJ_MEMORY: return ERR_OUT_OF_MEMORY; default: // RTS break; } utf8 = ticonv_varname_to_utf8(handle->model, entry->name, entry->type); g_snprintf(update_->text, sizeof(update_->text), "%s", utf8); g_free(utf8); update_label(); TRYF(ti82_send_XDP(handle, entry->size, entry->data)); TRYF(ti82_recv_ACK(handle, &status)); TRYF(ti82_send_EOT(handle)); ticalcs_info(""); update_->cnt2 = i+1; update_->max2 = content->num_entries; update_->pbar(); } return 0; }
static int send_var_ns (CalcHandle* handle, CalcMode mode, FileContent* content) { int i; int err; uint8_t rej_code; uint16_t status; char *utf8; update_->cnt2 = 0; update_->max2 = content->num_entries; for (i = 0; i < content->num_entries; i++) { VarEntry *entry = content->entries[i]; TRYF(ti82_send_VAR((uint16_t)entry->size, entry->type, entry->name)); TRYF(ti82_recv_ACK(&status)); g_snprintf(update_->text, sizeof(update_->text), _("Waiting for user's action...")); update_label(); do { // wait user's action update_refresh(); if (update_->cancel) return ERR_ABORT; err = ti82_recv_SKP(&rej_code); } while (err == ERROR_READ_TIMEOUT); TRYF(ti82_send_ACK()); switch (rej_code) { case REJ_EXIT: return ERR_ABORT; case REJ_SKIP: continue; case REJ_MEMORY: return ERR_OUT_OF_MEMORY; default: // RTS break; } utf8 = ticonv_varname_to_utf8(handle->model, entry->name, entry->type); g_snprintf(update_->text, sizeof(update_->text), "%s", utf8); g_free(utf8); update_label(); TRYF(ti82_send_XDP(entry->size, entry->data)); TRYF(ti82_recv_ACK(&status)); update_->cnt2 = i+1; update_->max2 = content->num_entries; update_->pbar(); } if ((mode & MODE_SEND_ONE_VAR) || (mode & MODE_SEND_LAST_VAR)) { TRYF(ti82_send_EOT()); TRYF(ti82_recv_ACK(NULL)); } return 0; }
static int send_backup (CalcHandle* handle, BackupContent* content) { int err = 0; uint16_t length; char varname[9]; uint8_t rej_code; uint16_t status; g_snprintf(update_->text, sizeof(update_->text), _("Waiting for user's action...")); update_label(); length = content->data_length1; varname[0] = LSB(content->data_length2); varname[1] = MSB(content->data_length2); varname[2] = LSB(content->data_length3); varname[3] = MSB(content->data_length3); varname[4] = LSB(content->mem_address); varname[5] = MSB(content->mem_address); TRYF(ti82_send_VAR(content->data_length1, TI82_BKUP, varname)); TRYF(ti82_recv_ACK(&status)); do { // wait user's action update_refresh(); if (update_->cancel) return ERR_ABORT; err = ti82_recv_SKP(&rej_code); } while (err == ERROR_READ_TIMEOUT); TRYF(ti82_send_ACK()); switch (rej_code) { case REJ_EXIT: case REJ_SKIP: return ERR_ABORT; case REJ_MEMORY: return ERR_OUT_OF_MEMORY; default: // RTS break; } strcpy(update_->text, ""); update_label(); update_->cnt2 = 0; update_->max2 = 3; update_->pbar(); TRYF(ti82_send_XDP(content->data_length1, content->data_part1)); TRYF(ti82_recv_ACK(&status)); update_->cnt2++; update_->pbar(); TRYF(ti82_send_XDP(content->data_length2, content->data_part2)); TRYF(ti82_recv_ACK(&status)); update_->cnt2++; update_->pbar(); TRYF(ti82_send_XDP(content->data_length3, content->data_part3)); TRYF(ti82_recv_ACK(&status)); update_->cnt2++; update_->pbar(); //TRYF(ti82_send_EOT()); return 0; }