Skip to content

Commit

Permalink
libticalcs: only do the nspire login check on pre-touchpads.
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed Apr 7, 2024
1 parent d777dda commit f202e47
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions libticalcs/trunk/src/calc_nsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,44 +142,48 @@ static int is_ready (CalcHandle* handle)
break;
}

// XXX when commenting this OS version detection code, sending many Status or Dirlist
// requests in quick succession often triggers memory corruption (hangs, reboots,
// a variable amount of black pixels on the screen) on (at least) Nspire (CAS) OS 1.7...
ticalcs_info(" waiting for LOGIN request (OS >= 1.2 check)...");
const int old = ticables_options_set_timeout(handle->cable, 40); // 3s mini

ret = nsp_cmd_r_login(handle); // no call to nsp_send_nack(handle) because nack is managed in nsp_recv_data()
// Only pre-Touchpad models may have OS 1.x
if (handle->model < CALC_NSPIRE_TOUCHPAD)
{
// XXX when commenting this OS version detection code, sending many Status or Dirlist
// requests in quick succession often triggers memory corruption (hangs, reboots,
// a variable amount of black pixels on the screen) on (at least) Nspire (CAS) OS 1.7...
ticalcs_info(" waiting for LOGIN request (OS >= 1.2 check)...");
const int old = ticables_options_set_timeout(handle->cable, 40); // 3s mini

ticables_options_set_timeout(handle->cable, old);
ret = nsp_cmd_r_login(handle); // no call to nsp_send_nack(handle) because nack is managed in nsp_recv_data()

if (ret)
{
ticalcs_info("OS = 1.1");
//rom_11 = !0;
ticables_options_set_timeout(handle->cable, old);

ret = nsp_addr_request(handle);
if (ret)
{
break;
}
ret = nsp_addr_assign(handle, NSP_DEV_ADDR);
if (ret)
{
break;
}
}
else
{
ret = nsp_recv_disconnect(handle);
if (ret)
{
ticalcs_info("OS = 1.2 or 1.3");
//rom_14 = 0;
ticalcs_info("OS = 1.1");
//rom_11 = !0;

ret = nsp_addr_request(handle);
if (ret)
{
break;
}
ret = nsp_addr_assign(handle, NSP_DEV_ADDR);
if (ret)
{
break;
}
}
else
{
ticalcs_info("OS = 1.4 or later");
//rom_14 = !0;
ret = nsp_recv_disconnect(handle);
if (ret)
{
ticalcs_info("OS = 1.2 or 1.3");
//rom_14 = 0;
}
else
{
ticalcs_info("OS = 1.4 or later");
//rom_14 = !0;
}
}
}

Expand Down

0 comments on commit f202e47

Please sign in to comment.