Improved error logging; Add eth address

This commit is contained in:
dualshock-tools
2024-04-25 23:42:20 +02:00
parent e16e3a4ef1
commit 5773adfdbd
3 changed files with 74 additions and 12 deletions

61
core.js
View File

@@ -162,6 +162,7 @@ async function ds4_calibrate_range_begin(perm_ch) {
if(perm_ch) {
await ds4_nvunlock();
if(await ds4_nvstatus() != 0) {
la("ds4_calibrate_range_begin_failed", {"r": "nvunlock"});
close_calibrate_window();
return show_popup(err + l("Cannot unlock NVS"));
}
@@ -173,11 +174,15 @@ async function ds4_calibrate_range_begin(perm_ch) {
// Assert
data = await device.receiveFeatureReport(0x91)
data2 = await device.receiveFeatureReport(0x92)
if(data.getUint32(0, false) != 0x91010201 || data2.getUint32(0, false) != 0x920102ff) {
d1 = data.getUint32(0, false);
d2 = data2.getUint32(0, false);
if(d1 != 0x91010201 || d2 != 0x920102ff) {
la("ds4_calibrate_range_begin_failed", {"d1": d1, "d2": d2});
close_calibrate_window();
return show_popup(err + l("Error 1"));
}
} catch(e) {
la("ds4_calibrate_range_begin_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
close_calibrate_window();
return show_popup(err + e);
@@ -193,7 +198,10 @@ async function ds4_calibrate_range_end(perm_ch) {
data = await device.receiveFeatureReport(0x91)
data2 = await device.receiveFeatureReport(0x92)
if(data.getUint32(0, false) != 0x91010202 || data2.getUint32(0, false) != 0x92010201) {
d1 = data.getUint32(0, false);
d2 = data2.getUint32(0, false);
if(d1 != 0x91010202 || d2 != 0x92010201) {
la("ds4_calibrate_range_end_failed", {"d1": d1, "d2": d2});
close_calibrate_window();
return show_popup(err + l("Error 3"));
}
@@ -201,6 +209,7 @@ async function ds4_calibrate_range_end(perm_ch) {
if(perm_ch) {
await ds4_nvlock();
if(await ds4_nvstatus() != 1) {
la("ds4_calibrate_range_end_failed", {"r": "nvlock"});
close_calibrate_window();
return show_popup(err + l("Cannot relock NVS"));
}
@@ -209,6 +218,7 @@ async function ds4_calibrate_range_end(perm_ch) {
close_calibrate_window();
show_popup(l("Range calibration completed"));
} catch(e) {
la("ds4_calibrate_range_end_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
close_calibrate_window();
return show_popup(err + e);
@@ -222,6 +232,7 @@ async function ds4_calibrate_sticks_begin(has_perm_changes) {
if(has_perm_changes) {
await ds4_nvunlock();
if(await ds4_nvstatus() != 0) {
la("ds4_calibrate_sticks_begin_failed", {"r": "nvunlock"});
show_popup(err + l("Cannot unlock NVS"));
return false;
}
@@ -231,15 +242,19 @@ async function ds4_calibrate_sticks_begin(has_perm_changes) {
await device.sendFeatureReport(0x90, alloc_req(0x90, [1,1,1]))
// Assert
data = await device.receiveFeatureReport(0x91)
data2 = await device.receiveFeatureReport(0x92)
if(data.getUint32(0, false) != 0x91010101 || data2.getUint32(0, false) != 0x920101ff) {
data = await device.receiveFeatureReport(0x91);
data2 = await device.receiveFeatureReport(0x92);
d1 = data.getUint32(0, false);
d2 = data2.getUint32(0, false);
if(d1 != 0x91010101 || d2 != 0x920101ff) {
la("ds4_calibrate_sticks_begin_failed", {"d1": d1, "d2": d2});
show_popup(err + l("Error 1"));
return false;
}
return true;
} catch(e) {
la("ds4_calibrate_sticks_begin_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
show_popup(err + e);
return false;
@@ -260,6 +275,7 @@ async function ds4_calibrate_sticks_sample() {
close_calibrate_window();
d1 = dec2hex32(data.getUint32(0, false));
d2 = dec2hex32(data2.getUint32(0, false));
la("ds4_calibrate_sticks_sample_failed", {"d1": d1, "d2": d2});
show_popup(err + l("Error 2") + " (" + d1 + ", " + d2 + " at i=" + i + ")");
return false;
}
@@ -280,6 +296,7 @@ async function ds4_calibrate_sticks_end(has_perm_changes) {
if(data.getUint32(0, false) != 0x91010101 || data2.getUint32(0, false) != 0x920101FF) {
d1 = dec2hex32(data.getUint32(0, false));
d2 = dec2hex32(data2.getUint32(0, false));
la("ds4_calibrate_sticks_end_failed", {"d1": d1, "d2": d2});
show_popup(err + l("Error 3") + " (" + d1 + ", " + d2 + " at i=" + i + ")");
return false;
}
@@ -287,6 +304,7 @@ async function ds4_calibrate_sticks_end(has_perm_changes) {
if(has_perm_changes) {
await ds4_nvlock();
if(await ds4_nvstatus() != 1) {
la("ds4_calibrate_sticks_end_failed", {"r": "nvlock"});
show_popup(err + l("Cannot relock NVS"));
return false;
}
@@ -294,6 +312,7 @@ async function ds4_calibrate_sticks_end(has_perm_changes) {
return true;
} catch(e) {
la("ds4_calibrate_sticks_end_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
show_popup(err + e);
return false;
@@ -310,9 +329,12 @@ async function ds4_calibrate_sticks() {
await device.sendFeatureReport(0x90, alloc_req(0x90, [1,1,1]))
// Assert
data = await device.receiveFeatureReport(0x91)
data2 = await device.receiveFeatureReport(0x92)
if(data.getUint32(0, false) != 0x91010101 || data2.getUint32(0, false) != 0x920101ff) {
data = await device.receiveFeatureReport(0x91);
data2 = await device.receiveFeatureReport(0x92);
d1 = data.getUint32(0, false);
d2 = data2.getUint32(0, false);
if(d1 != 0x91010101 || d2 != 0x920101ff) {
la("ds4_calibrate_sticks_failed", {"s": 1, "d1": d1, "d2": d2});
close_calibrate_window();
return show_popup(err + l("Error 1"));
}
@@ -328,9 +350,10 @@ async function ds4_calibrate_sticks() {
data = await device.receiveFeatureReport(0x91);
data2 = await device.receiveFeatureReport(0x92);
if(data.getUint32(0, false) != 0x91010101 || data2.getUint32(0, false) != 0x920101ff) {
close_calibrate_window();
d1 = dec2hex32(data.getUint32(0, false));
d2 = dec2hex32(data2.getUint32(0, false));
la("ds4_calibrate_sticks_failed", {"s": 2, "i": i, "d1": d1, "d2": d2});
close_calibrate_window();
return show_popup(err + l("Error 2") + " (" + d1 + ", " + d2 + " at i=" + i + ")");
}
@@ -343,6 +366,7 @@ async function ds4_calibrate_sticks() {
if(data.getUint32(0, false) != 0x91010101 || data2.getUint32(0, false) != 0x920101FF) {
d1 = dec2hex32(data.getUint32(0, false));
d2 = dec2hex32(data2.getUint32(0, false));
la("ds4_calibrate_sticks_failed", {"s": 3, "d1": d1, "d2": d2});
close_calibrate_window();
return show_popup(err + l("Error 3") + " (" + d1 + ", " + d2 + " at i=" + i + ")");
}
@@ -352,6 +376,7 @@ async function ds4_calibrate_sticks() {
close_calibrate_window()
show_popup(l("Stick calibration completed"));
} catch(e) {
la("ds4_calibrate_sticks_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
close_calibrate_window();
return show_popup(err + e);
@@ -488,6 +513,7 @@ async function ds5_calibrate_sticks_begin(has_perm_changes) {
if(has_perm_changes) {
await ds5_nvunlock();
if(await ds5_nvstatus() != 0) {
la("ds5_calibrate_sticks_begin_failed", {"r": "nvunlock"});
show_popup(err + l("Cannot unlock NVS"));
return false;
}
@@ -499,11 +525,13 @@ async function ds5_calibrate_sticks_begin(has_perm_changes) {
data = await device.receiveFeatureReport(0x83)
if(data.getUint32(0, false) != 0x83010101) {
d1 = dec2hex32(data.getUint32(0, false));
la("ds5_calibrate_sticks_begin_failed", {"d1": d1});
show_popup(err + l("Error 1") + " (" + d1 + ").");
return false;
}
return true;
} catch(e) {
la("ds5_calibrate_sticks_begin_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
show_popup(err + e);
return false;
@@ -521,11 +549,13 @@ async function ds5_calibrate_sticks_sample() {
data = await device.receiveFeatureReport(0x83)
if(data.getUint32(0, false) != 0x83010101) {
d1 = dec2hex32(data.getUint32(0, false));
la("ds5_calibrate_sticks_sample_failed", {"d1": d1});
show_popup(err + l("Error 2") + " (" + d1 + ").");
return false;
}
return true;
} catch(e) {
la("ds5_calibrate_sticks_sample_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
show_popup(err + e);
return false;
@@ -542,6 +572,7 @@ async function ds5_calibrate_sticks_end(has_perm_changes) {
data = await device.receiveFeatureReport(0x83)
if(data.getUint32(0, false) != 0x83010102) {
d1 = dec2hex32(data.getUint32(0, false));
la("ds5_calibrate_sticks_end_failed", {"d1": d1});
show_popup(err + l("Error 3") + " (" + d1 + ").");
return false;
}
@@ -549,12 +580,14 @@ async function ds5_calibrate_sticks_end(has_perm_changes) {
if(has_perm_changes) {
await ds5_nvlock();
if(await ds5_nvstatus() != 1) {
la("ds5_calibrate_sticks_end_failed", {"r": "nvlock"});
show_popup(err + l("Cannot relock NVS"));
return false;
}
}
return true;
} catch(e) {
la("ds5_calibrate_sticks_end_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
show_popup(err + e);
return false;
@@ -574,6 +607,7 @@ async function ds5_calibrate_sticks() {
data = await device.receiveFeatureReport(0x83)
if(data.getUint32(0, false) != 0x83010101) {
d1 = dec2hex32(data.getUint32(0, false));
la("ds5_calibrate_sticks_failed", {"s": 1, "d1": d1});
close_calibrate_window();
return show_popup(err + l("Error 1") + " (" + d1 + ").");
}
@@ -590,6 +624,7 @@ async function ds5_calibrate_sticks() {
data = await device.receiveFeatureReport(0x83)
if(data.getUint32(0, false) != 0x83010101) {
d1 = dec2hex32(data.getUint32(0, false));
la("ds5_calibrate_sticks_failed", {"s": 2, "i": i, "d1": d1});
close_calibrate_window();
return show_popup(err + l("Error 2") + " (" + d1 + ").");
}
@@ -607,6 +642,7 @@ async function ds5_calibrate_sticks() {
data = await device.receiveFeatureReport(0x83)
if(data.getUint32(0, false) != 0x83010102) {
d1 = dec2hex32(data.getUint32(0, false));
la("ds5_calibrate_sticks_failed", {"s": 3, "d1": d1});
close_calibrate_window();
return show_popup(err + l("Error 3") + " (" + d1 + ").");
}
@@ -618,6 +654,7 @@ async function ds5_calibrate_sticks() {
show_popup(l("Stick calibration completed"));
} catch(e) {
la("ds5_calibrate_sticks_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
close_calibrate_window();
return show_popup(err + e);
@@ -631,6 +668,7 @@ async function ds5_calibrate_range_begin(perm_ch) {
if(perm_ch) {
await ds5_nvunlock();
if(await ds5_nvstatus() != 0) {
la("ds5_calibrate_range_begin_failed", {"r": "nvunlock"});
close_calibrate_window();
return show_popup(err + l("Cannot unlock NVS"));
}
@@ -643,10 +681,12 @@ async function ds5_calibrate_range_begin(perm_ch) {
data = await device.receiveFeatureReport(0x83)
if(data.getUint32(0, false) != 0x83010201) {
d1 = dec2hex32(data.getUint32(0, false));
la("ds5_calibrate_range_begin_failed", {"d1": d1});
close_calibrate_window();
return show_popup(err + l("Error 1") + " (" + d1 + ").");
}
} catch(e) {
la("ds5_calibrate_range_begin_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
close_calibrate_window();
return show_popup(err + e);
@@ -664,6 +704,7 @@ async function ds5_calibrate_range_end(perm_ch) {
data = await device.receiveFeatureReport(0x83)
if(data.getUint32(0, false) != 0x83010202) {
d1 = dec2hex32(data.getUint32(0, false));
la("ds5_calibrate_range_end_failed", {"d1": d1});
close_calibrate_window();
return show_popup(err + l("Error 1") + " (" + d1 + ").");
}
@@ -671,6 +712,7 @@ async function ds5_calibrate_range_end(perm_ch) {
if(perm_ch) {
await ds5_nvlock();
if(await ds5_nvstatus() != 1) {
la("ds5_calibrate_range_end_failed", {"r": "nvlock"});
close_calibrate_window();
return show_popup(err + l("Cannot relock NVS"));
}
@@ -679,6 +721,7 @@ async function ds5_calibrate_range_end(perm_ch) {
close_calibrate_window();
show_popup(l("Range calibration completed"));
} catch(e) {
la("ds5_calibrate_range_end_failed", {"r": e});
await new Promise(r => setTimeout(r, 500));
close_calibrate_window();
return show_popup(err + e);