/* FLASH (special var header: size, id, flag, offset, page) */ int ti73_recv_VAR2_h(CalcHandle* handle, uint16_t * length, uint8_t * type, char *name, uint16_t * offset, uint16_t * page) { uint8_t host, cmd; uint8_t *buffer = (uint8_t *)handle->priv2; uint16_t len; TRYF(dbus_recv(handle, &host, &cmd, &len, buffer)); if (cmd == CMD_EOT) return ERR_EOT; // not really an error if (cmd == CMD_SKP) return ERR_VAR_REJECTED; if (cmd != CMD_VAR) return ERR_INVALID_CMD; if (len != 10) return ERR_INVALID_PACKET; *length = buffer[0] | (buffer[1] << 8); *type = buffer[2]; memcpy(name, buffer + 3, 3); name[3] = '\0'; *offset = buffer[6] | (buffer[7] << 8); *page = buffer[8] | (buffer[9] << 8); *page &= 0xff; ticalcs_info(" TI->PC: VAR (size=0x%04X, type=%02X, name=%s, offset=%04X, page=%02X)", *length, *type, name, *offset, *page); return 0; }
/* Receive acknowledge - status [in/out]: if NULL is passed, the function checks that 00 00 has been received. Otherwise, it put in status the received value. - int [out]: an error code */ TIEXPORT3 int TICALL ti73_recv_ACK(CalcHandle* handle, uint16_t * status) { uint8_t host, cmd; uint16_t length; uint8_t *buffer; if (handle == NULL) { ticalcs_critical("%s: handle is NULL", __FUNCTION__); return ERR_INVALID_HANDLE; } buffer = (uint8_t *)handle->priv2; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (status != NULL) { *status = length; } else if (length != 0x0000) // is an error code ? (=5 when app is rejected) { return ERR_NACK; } if (cmd != CMD_ACK) { return ERR_INVALID_CMD; } ticalcs_info(" TI->PC: ACK"); return 0; }
TIEXPORT3 int TICALL ti68k_recv_CNT(CalcHandle* handle) { uint8_t host, cmd; uint16_t sts; int ret; VALIDATE_HANDLE(handle); ret = dbus_recv(handle, &host, &cmd, &sts, NULL); if (ret) { return ret; } if (cmd == DBUS_CMD_EOT) { return ERR_EOT; // not really an error } if (cmd != DBUS_CMD_CNT) { return ERR_INVALID_CMD; } ticalcs_info(" TI->PC: CNT"); return 0; }
int ti73_recv_VAR_h(CalcHandle* handle, uint16_t * varsize, uint8_t * vartype, char *varname, uint8_t * varattr) { uint8_t host, cmd; uint8_t *buffer = (uint8_t *)handle->priv2; uint16_t length; char trans[9]; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_EOT) return ERR_EOT; // not really an error if (cmd == CMD_SKP) return ERR_VAR_REJECTED; if (cmd != CMD_VAR) return ERR_INVALID_CMD; if(length < 9 || length > 13) //if ((length != (11 + EXTRAS)) && (length != 9)) return ERR_INVALID_PACKET; *varsize = buffer[0] | (buffer[1] << 8); *vartype = buffer[2]; memcpy(varname, buffer + 3, 8); varname[8] = '\0'; *varattr = (buffer[12] & 0x80) ? ATTRB_ARCHIVED : ATTRB_NONE; ticonv_varname_to_utf8_s(handle->model, varname, trans, *vartype); ticalcs_info(" TI->PC: VAR (size=0x%04X, id=%02X, name=%s, attrb=%i)", *varsize, *vartype, trans, *varattr); return 0; }
int ti89_recv_RTS_h(CalcHandle* handle, uint32_t * varsize, uint8_t * vartype, char *varname) { uint8_t host, cmd; uint8_t *buffer = (uint8_t *)handle->priv2; uint16_t length; uint8_t strl; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_EOT) return ERR_EOT; // not really an error if (cmd == CMD_SKP) return ERR_CALC_ERROR1 + err_code(buffer); if (cmd != CMD_VAR) return ERR_INVALID_CMD; *varsize = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24); *vartype = buffer[4]; strl = buffer[5]; memcpy(varname, buffer + 6, strl); varname[strl] = '\0'; if (length != (6 + strlen(varname))) return ERR_INVALID_PACKET; ticalcs_info(" TI->PC: RTS (size=0x%08X=%i, id=%02X, name=%s)", *varsize, *varsize, *vartype, varname); return 0; }
int ti82_recv_VAR_h(CalcHandle* handle, uint16_t * varsize, uint8_t * vartype, char *varname) { uint8_t host, cmd; uint8_t *buffer = (uint8_t *)handle->priv2; uint16_t length; char trans[9]; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_EOT) return ERR_EOT; // not really an error if (cmd == CMD_SKP) return ERR_VAR_REJECTED; if (cmd != CMD_VAR) return ERR_INVALID_CMD; if ((length != 11) && (length != 9)) return ERR_INVALID_PACKET; *varsize = buffer[0] | (buffer[1] << 8); *vartype = buffer[2]; memcpy(varname, buffer + 3, 8); varname[8] = '\0'; ticonv_varname_to_utf8_s(handle->model, varname, trans, *vartype); ticalcs_info(" TI->PC: VAR (size=0x%04X=%i, id=%02X, name=%s)", *varsize, *varsize, *vartype, trans); return 0; }
static int ti68k_recv_CTS(CalcHandle* handle, uint8_t is_92) { uint8_t host, cmd; uint16_t length; uint8_t *buffer; int ret; VALIDATE_HANDLE(handle); buffer = (uint8_t *)handle->buffer; ret = dbus_recv(handle, &host, &cmd, &length, buffer); if (ret) { return ret; } if (cmd == DBUS_CMD_SKP) { return is_92 ? ERR_VAR_REJECTED : ERR_CALC_ERROR1 + err_code(buffer); } else if (cmd != DBUS_CMD_CTS) { return ERR_INVALID_CMD; } if (length != 0x0000) { return ERR_CTS_ERROR; } ticalcs_info(" TI->PC: CTS"); return 0; }
TIEXPORT3 int TICALL ti73_recv_CTS(CalcHandle* handle, uint16_t length) { uint8_t host, cmd; uint16_t len; uint8_t *buffer; if (handle == NULL) { ticalcs_critical("%s: handle is NULL", __FUNCTION__); return ERR_INVALID_HANDLE; } buffer = (uint8_t *)handle->priv2; TRYF(dbus_recv(handle, &host, &cmd, &len, buffer)); if (cmd == CMD_SKP) { return ERR_VAR_REJECTED; } else if (cmd != CMD_CTS) { return ERR_INVALID_CMD; } if (length != len) { return ERR_CTS_ERROR; } ticalcs_info(" TI->PC: CTS"); return 0; }
TIEXPORT3 int TICALL ti89_recv_VAR(CalcHandle* handle, uint32_t * varsize, uint8_t * vartype, char *varname) { uint8_t host, cmd; uint8_t *buffer; uint16_t length; uint8_t strl; uint8_t flag; char * varname_nofldname; int ret; VALIDATE_HANDLE(handle); VALIDATE_NONNULL(varsize); VALIDATE_NONNULL(vartype); VALIDATE_NONNULL(varname); buffer = (uint8_t *)handle->buffer; ret = dbus_recv(handle, &host, &cmd, &length, buffer); if (ret) { return ret; } if (cmd == DBUS_CMD_EOT) { ticalcs_info(" TI->PC: EOT"); return ERR_EOT; // not really an error } if (cmd == DBUS_CMD_SKP) { return ERR_CALC_ERROR1 + err_code(buffer); } if (cmd != DBUS_CMD_VAR) { return ERR_INVALID_CMD; } *varsize = buffer[0] | (((uint32_t)buffer[1]) << 8) | (((uint32_t)buffer[2]) << 16) | (((uint32_t)buffer[3]) << 24); *vartype = buffer[4]; strl = buffer[5]; memcpy(varname, buffer + 6, strl); varname[strl] = '\0'; flag = buffer[6 + strl]; if ((length != (6 + strlen(varname))) && (length != (7 + strlen(varname)))) { return ERR_INVALID_PACKET; } ticalcs_info(" TI->PC: VAR (size=0x%08X=%i, id=%02X, name=%s, flag=%i)", *varsize, *varsize, *vartype, varname, flag); varname_nofldname = tifiles_get_varname(varname); if (varname_nofldname != varname) { // This variable name contains a folder name. Erase it. ticalcs_info(" TI->PC: VAR: the variable name contains a folder name, stripping it."); memmove(varname, varname_nofldname, strlen(varname_nofldname)+1); } return 0; }
/* FLASH (special var header: size, id, flag, offset, page) */ TIEXPORT3 int TICALL ti73_recv_VAR2(CalcHandle* handle, uint16_t * length, uint8_t * type, char *name, uint16_t * offset, uint16_t * page) { uint8_t host, cmd; uint8_t *buffer; uint16_t len; if (handle == NULL) { ticalcs_critical("%s: handle is NULL", __FUNCTION__); return ERR_INVALID_HANDLE; } if (length == NULL || type == NULL || name == NULL || offset == NULL || page == NULL) { ticalcs_critical("%s: an argument is NULL", __FUNCTION__); return ERR_INVALID_PACKET; } buffer = (uint8_t *)handle->priv2; TRYF(dbus_recv(handle, &host, &cmd, &len, buffer)); if (cmd == CMD_EOT) { return ERR_EOT; // not really an error } if (cmd == CMD_SKP) { return ERR_VAR_REJECTED; } if (cmd != CMD_VAR) { return ERR_INVALID_CMD; } if (len != 10) { return ERR_INVALID_PACKET; } *length = buffer[0] | (buffer[1] << 8); *type = buffer[2]; memcpy(name, buffer + 3, 3); name[3] = '\0'; *offset = buffer[6] | (buffer[7] << 8); *page = buffer[8] | (buffer[9] << 8); *page &= 0xff; ticalcs_info(" TI->PC: VAR (size=0x%04X, type=%02X, name=%s, offset=%04X, page=%02X)", *length, *type, name, *offset, *page); return 0; }
TIEXPORT3 int TICALL ti73_recv_VAR(CalcHandle* handle, uint16_t * varsize, uint8_t * vartype, char *varname, uint8_t * varattr) { uint8_t host, cmd; uint8_t *buffer; uint16_t length; char trans[9]; if (handle == NULL) { ticalcs_critical("%s: handle is NULL", __FUNCTION__); return ERR_INVALID_HANDLE; } if (varsize == NULL || vartype == NULL || varname == NULL || varattr == NULL) { ticalcs_critical("%s: an argument is NULL", __FUNCTION__); return ERR_INVALID_PACKET; } buffer = (uint8_t *)handle->priv2; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_EOT) { return ERR_EOT; // not really an error } if (cmd == CMD_SKP) { return ERR_VAR_REJECTED; } if (cmd != CMD_VAR) { return ERR_INVALID_CMD; } if(length < 9 || length > 13) //if ((length != (11 + EXTRAS)) && (length != 9)) { return ERR_INVALID_PACKET; } *varsize = buffer[0] | (buffer[1] << 8); *vartype = buffer[2]; memcpy(varname, buffer + 3, 8); varname[8] = '\0'; *varattr = (buffer[12] & 0x80) ? ATTRB_ARCHIVED : ATTRB_NONE; ticonv_varname_to_utf8_s(handle->model, varname, trans, *vartype); ticalcs_info(" TI->PC: VAR (size=0x%04X, id=%02X, name=%s, attrb=%i)", *varsize, *vartype, trans, *varattr); return 0; }
int ti82_recv_XDP_h(CalcHandle* handle, uint16_t * length, uint8_t * data) { uint8_t host, cmd; TRYF(dbus_recv(handle, &host, &cmd, length, data)); if (cmd != CMD_XDP) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: XDP (%04X=%i bytes)", *length, *length); return 0; }
int ti89_recv_EOT_h(CalcHandle* handle) { uint8_t host, cmd; uint16_t length; TRYF(dbus_recv(handle, &host, &cmd, &length, NULL)); if (cmd != CMD_EOT) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: EOT"); return 0; }
TIEXPORT3 int TICALL ti92_recv_VAR(CalcHandle* handle, uint32_t * varsize, uint8_t * vartype, char *varname) { uint8_t host, cmd; uint8_t *buffer; uint16_t length; uint8_t strl; int ret; VALIDATE_HANDLE(handle); VALIDATE_NONNULL(varsize); VALIDATE_NONNULL(vartype); VALIDATE_NONNULL(varname); buffer = (uint8_t *)handle->buffer; ret = dbus_recv(handle, &host, &cmd, &length, buffer); if (ret) { return ret; } if (cmd == DBUS_CMD_EOT) { ticalcs_info(" TI->PC: EOT"); return ERR_EOT; // not really an error } if (cmd == DBUS_CMD_SKP) { return ERR_VAR_REJECTED; } if (cmd != DBUS_CMD_VAR) { return ERR_INVALID_CMD; } *varsize = buffer[0] | (((uint32_t)buffer[1]) << 8) | (((uint32_t)buffer[2]) << 16) | (((uint32_t)buffer[3]) << 24); *vartype = buffer[4]; strl = buffer[5]; memcpy(varname, buffer + 6, strl); varname[strl] = '\0'; if (length != (6 + strlen(varname))) { return ERR_INVALID_PACKET; } ticalcs_info(" TI->PC: VAR (size=0x%08X=%i, id=%02X, name=%s)", *varsize, *varsize, *vartype, varname); return 0; }
TIEXPORT3 int TICALL ti73_recv_XDP(CalcHandle* handle, uint16_t * length, uint8_t * data) { uint8_t host, cmd; TRYF(dbus_recv(handle, &host, &cmd, length, data)); if (cmd != CMD_XDP) { return ERR_INVALID_CMD; } ticalcs_info(" TI->PC: XDP (%04X bytes)", *length); return 0; }
int ti92_recv_XDP_h(CalcHandle* handle, uint32_t * length, uint8_t * data) { uint8_t host, cmd; int err; uint16_t len; err = dbus_recv(handle, &host, &cmd, &len, data); *length = len; if (cmd != CMD_XDP) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: XDP (%04X=%i bytes)", *length, *length); TRYF(err); return 0; }
int ti89_recv_CNT_h(CalcHandle* handle) { uint8_t host, cmd; uint16_t sts; TRYF(dbus_recv(handle, &host, &cmd, &sts, NULL)); if (cmd == CMD_EOT) return ERR_EOT; // not really an error if (cmd != CMD_CNT) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: CNT"); return 0; }
/* Variable (std var header: variable length) */ int ti89_recv_VAR_h(CalcHandle* handle, uint32_t * varsize, uint8_t * vartype, char *varname) { uint8_t host, cmd; uint8_t *buffer = (uint8_t *)handle->priv2; uint16_t length; uint8_t strl; uint8_t flag; char * varname_nofldname; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_EOT) return ERR_EOT; // not really an error if (cmd == CMD_SKP) return ERR_CALC_ERROR1 + err_code(buffer); if (cmd != CMD_VAR) return ERR_INVALID_CMD; *varsize = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24); *vartype = buffer[4]; strl = buffer[5]; memcpy(varname, buffer + 6, strl); varname[strl] = '\0'; flag = buffer[6 + strl]; if ((length != (6 + strlen(varname))) && (length != (7 + strlen(varname)))) return ERR_INVALID_PACKET; ticalcs_info(" TI->PC: VAR (size=0x%08X=%i, id=%02X, name=%s, flag=%i)", *varsize, *varsize, *vartype, varname, flag); varname_nofldname = tifiles_get_varname(varname); if (varname_nofldname != varname) { // This variable name contains a folder name. Erase it. ticalcs_info(" TI->PC: VAR: the variable name contains a folder name, stripping it."); memmove(varname, varname_nofldname, strlen(varname_nofldname)+1); } return 0; }
/* Receive acknowledge - status [in/out]: if NULL is passed, the function checks that 00 00 has been received. Otherwise, it put in status the received value. - int [out]: an error code */ int ti82_recv_ACK_h(CalcHandle* handle, uint16_t * status) { uint8_t host, cmd; uint16_t sts; TRYF(dbus_recv(handle, &host, &cmd, &sts, NULL)); if (status != NULL) *status = sts; else if (sts != 0x0000) return ERR_NACK; if (cmd != CMD_ACK) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: ACK"); return 0; }
int ti82_recv_CTS_h(CalcHandle* handle) { uint8_t host, cmd; uint16_t length; TRYF(dbus_recv(handle, &host, &cmd, &length, NULL)); if (cmd == CMD_SKP) return ERR_VAR_REJECTED; else if (cmd != CMD_CTS) return ERR_INVALID_CMD; if (length != 0x0000) return ERR_CTS_ERROR; ticalcs_info(" TI->PC: CTS"); return 0; }
int ti73_recv_CTS_h(CalcHandle* handle, uint16_t length) { uint8_t host, cmd; uint16_t len; uint8_t *buffer = (uint8_t *)handle->priv2; TRYF(dbus_recv(handle, &host, &cmd, &len, buffer)); if (cmd == CMD_SKP) return ERR_VAR_REJECTED; else if (cmd != CMD_CTS) return ERR_INVALID_CMD; if (length != len) return ERR_CTS_ERROR; ticalcs_info(" TI->PC: CTS"); return 0; }
/* Receive acknowledge - status [in/out]: if NULL is passed, the function checks that 00 00 has been received. Otherwise, it put in status the received value. - int [out]: an error code */ int ti73_recv_ACK_h(CalcHandle* handle, uint16_t * status) { uint8_t host, cmd; uint16_t length; uint8_t *buffer = (uint8_t *)handle->priv2; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (status != NULL) *status = length; else if (length != 0x0000) // is an error code ? (=5 when app is rejected) return ERR_NACK; if (cmd != CMD_ACK) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: ACK"); return 0; }
/* Variable (std var header: NUL padded, variable length) */ int ti85_recv_VAR(CalcHandle* handle, uint16_t * varsize, uint8_t * vartype, char *varname) { uint8_t host, cmd; uint8_t *buffer = (uint8_t *)handle->priv2; uint16_t length; char trans[9]; uint8_t strl; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_EOT) return ERR_EOT; // not really an error if (cmd == CMD_SKP) return ERR_VAR_REJECTED; if (cmd != CMD_VAR) return ERR_INVALID_CMD; //if((length != (4+strlen(varname))) && (length != 9)) //return ERR_INVALID_PACKET; *varsize = buffer[0] | (buffer[1] << 8); *vartype = buffer[2]; if (*vartype != TI8586_BKUP) { strl = buffer[3]; memcpy(varname, buffer + 4, strl); varname[strl] = '\0'; } else { memcpy(varname, buffer + 3, 8); } ticonv_varname_to_utf8_s(handle->model, varname, trans, *vartype); ticalcs_info(" TI->PC: VAR (size=0x%04X, id=%02X, name=%s)", *varsize, *vartype, trans); return 0; }
int ti82_recv_SKP_h(CalcHandle* handle, uint8_t * rej_code) { uint8_t host, cmd; uint16_t length; *rej_code = 0; TRYF(dbus_recv(handle, &host, &cmd, &length, rej_code)); if (cmd == CMD_CTS) { ticalcs_info(" TI->PC: CTS"); return 0; } if (cmd != CMD_SKP) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: SKP (rejection code = %i)", *rej_code); return 0; }
int ti89_recv_CTS_h(CalcHandle* handle) { uint8_t host, cmd; uint16_t length; uint8_t *buffer = (uint8_t *)handle->priv2; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_SKP) return ERR_CALC_ERROR1 + err_code(buffer); if (cmd != CMD_CTS) return ERR_INVALID_CMD; if (length != 0x0000) return ERR_CTS_ERROR; ticalcs_info(" TI->PC: CTS"); return 0; }
TIEXPORT3 int TICALL ti68k_recv_SKP(CalcHandle* handle, uint8_t * rej_code) { uint8_t host, cmd; uint16_t length; uint8_t *buffer; int retval; VALIDATE_HANDLE(handle); VALIDATE_NONNULL(rej_code); buffer = (uint8_t *)handle->buffer; *rej_code = 0; retval = dbus_recv(handle, &host, &cmd, &length, buffer); if (retval == 0) { if (cmd == DBUS_CMD_CTS) { ticalcs_info("CTS"); } else { if (cmd != DBUS_CMD_SKP) { retval = ERR_INVALID_CMD; } else { ticalcs_info(" TI->PC: SKP (rejection code = %i)", buffer[0]); if (rej_code != NULL) { *rej_code = buffer[0]; } } } } return retval; }
/* ACK: receive acknowledge - status [in/out]: if NULL is passed, the function checks that 00 00 has been received. Otherwise, it put in status the received value. - int [out]: an error code */ static int ti68k_recv_ACK(CalcHandle* handle, uint16_t * status, uint8_t is_92) { uint8_t host, cmd; uint16_t length; uint8_t *buffer; int ret; VALIDATE_HANDLE(handle); buffer = (uint8_t *)handle->buffer; ret = dbus_recv(handle, &host, &cmd, &length, buffer); if (ret) { return ret; } if (!is_92 && cmd == DBUS_CMD_SKP) { return ERR_CALC_ERROR1 + err_code(buffer); } if (status != NULL) { *status = length; } else if (length != 0x0000) { return ERR_NACK; } if (cmd != DBUS_CMD_ACK) { return ERR_INVALID_CMD; } ticalcs_info(" TI->PC: ACK"); return 0; }
int ti89_recv_SKP_h(CalcHandle* handle, uint8_t * rej_code) { uint8_t host, cmd; uint16_t length; uint8_t *buffer = (uint8_t *)handle->priv2; *rej_code = 0; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_CTS) { ticalcs_info("CTS"); return 0; } if (cmd != CMD_SKP) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: SKP (rejection code = %i)", *rej_code = buffer[0]); return 0; }
int ti82_recv_RTS_h(CalcHandle* handle, uint16_t * varsize, uint8_t * vartype, char *varname) { uint8_t host, cmd; uint8_t *buffer = (uint8_t *)handle->priv2; char trans[9]; TRYF(dbus_recv(handle, &host, &cmd, varsize, buffer)); if (cmd != CMD_RTS) return ERR_INVALID_CMD; *varsize = buffer[0] | (buffer[1] << 8); *vartype = buffer[2]; memcpy(varname, buffer + 3, 8); varname[8] = '\0'; ticonv_varname_to_utf8_s(handle->model, varname, trans, *vartype); ticalcs_info(" TI->PC: RTS (size=0x%04X=%i, id=%02X, name=%s)", *varsize, *varsize, *vartype, trans); return 0; }
/* Receive acknowledge - status [in/out]: if NULL is passed, the function checks that 00 00 has been received. Otherwise, it put in status the received value. - int [out]: an error code */ int ti89_recv_ACK_h(CalcHandle* handle, uint16_t * status) { uint8_t host, cmd; uint16_t length; uint8_t *buffer = (uint8_t *)handle->priv2; TRYF(dbus_recv(handle, &host, &cmd, &length, buffer)); if (cmd == CMD_SKP) return ERR_CALC_ERROR1 + err_code(buffer); if (status != NULL) *status = length; else if (length != 0x0000) return ERR_NACK; if (cmd != CMD_ACK) return ERR_INVALID_CMD; ticalcs_info(" TI->PC: ACK"); return 0; }