Depending on what PIDs are disabled/enabled, the AT command for the operation is generated incorrectly.
For example, the GUI generates the following command when some combination of enable/disable PIDs of the page "Throttle" is done:
Code: Select all
ATSET 0140=91,3,bf,a3
The correct AT command would be "ATSET 0140=91,03,bf,a3" (added a leading 0 on the second byte).
I managed to track the bug on the function togglePID(), contained in the file emulator.js.
Below is the corrected function:
Code: Select all
function togglePID(pid, enabled)
{
var i = parseInt(pid, 16) & 0xff;
pidDisabled[i] = !enabled;
var specialPid = i & 0xE0;
var val = 0;
var vals = "";
var pidTmp = specialPid + 1;
var valHex;
for (m = 0; m < 4; m++) {
val = 0;
for (n = 1; n <= 8; n++) {
val <<= 1;
if (!pidDisabled[pidTmp++]) val |= 1;
}
// vals += val.toString(16) + ","; <-- toString(16) does not add leading zero in case val < 0x10
// Corrected code. Always add a leading zero and do substr if necessary.
valHex = ( "0" + val.toString(16) );
vals += ( ( valHex.length > 2 ) ? valHex.substring(1) : valHex ) + ",";
}
specialPid |= 0x100;
var cmd = "ATSET 0" + specialPid.toString(16) + "=" + vals.substr(0, vals.length - 1);
if (!sendCommand(cmd)) {
alert("Unable to set PID " + specialPid.toString(16));
return false;
} else {
alert("PID " + pid + " is " + (enabled ? "enabled" : "disabled"));
}
}
I am not a JavaScript expert, so if there is a better way to do this, feel free to comment.
[]'s
Rhobison Alves Pereira