Console should get much smarter around compatibility with older units #6845
only:hellen121vag
This commit is contained in:
parent
09ff8c6b28
commit
bcc1008587
|
@ -27,6 +27,14 @@ public class StringIniField extends IniField {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StringIniField{" +
|
||||
"offset=" + getOffset() +
|
||||
", size=" + size +
|
||||
'}';
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String trimAtZeroSymbol(String value) {
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
|
|
|
@ -10,7 +10,7 @@ public interface rusEFIVersion {
|
|||
* *** BE CAREFUL WE HAVE SEPARATE AUTOUPDATE_VERSION also managed manually ***
|
||||
* @see com.rusefi.autoupdate.Autoupdate#AUTOUPDATE_VERSION
|
||||
*/
|
||||
int CONSOLE_VERSION = 20250209;
|
||||
int CONSOLE_VERSION = 20250210;
|
||||
AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
static long classBuildTimeMillis() {
|
||||
|
|
|
@ -181,8 +181,11 @@ public class LuaScriptPanel {
|
|||
}
|
||||
});
|
||||
|
||||
if (newLua.length() >= Fields.LUA_SCRIPT_SIZE) {
|
||||
setText(newLua.length() + " bytes would not fit sorry current limit " + Fields.LUA_SCRIPT_SIZE);
|
||||
BinaryProtocol bp = context.getLinkManager().getCurrentStreamState();
|
||||
StringIniField luaScript = getLuaScriptField(bp);
|
||||
|
||||
if (newLua.length() >= luaScript.getSize()) {
|
||||
setText(newLua.length() + " bytes would not fit sorry current limit " + luaScript.getSize());
|
||||
} else {
|
||||
setText(newLua);
|
||||
// and send to ECU (without burn!)
|
||||
|
@ -252,16 +255,21 @@ public class LuaScriptPanel {
|
|||
setText("No configuration image");
|
||||
return;
|
||||
}
|
||||
StringIniField luaScript = (StringIniField) bp.getIniFile().getIniField("luaScript"); // todo: do we have "luaScript" as code-generated constant anywhere?
|
||||
StringIniField luaScript = getLuaScriptField(bp);
|
||||
ByteBuffer luaScriptBuffer = image.getByteBuffer(luaScript.getOffset(), luaScript.getSize());
|
||||
|
||||
byte[] scriptArr = new byte[Fields.LUA_SCRIPT_SIZE];
|
||||
byte[] scriptArr = new byte[luaScript.getSize()];
|
||||
luaScriptBuffer.get(scriptArr);
|
||||
|
||||
int i = findNullTerminator(scriptArr);
|
||||
setText(new String(scriptArr, 0, i, StandardCharsets.US_ASCII));
|
||||
}
|
||||
|
||||
private static StringIniField getLuaScriptField(BinaryProtocol bp) {
|
||||
// todo: do we have "luaScript" as code-generated constant anywhere?
|
||||
return (StringIniField) bp.getIniFile().getIniField("luaScript");
|
||||
}
|
||||
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
private static int findNullTerminator(byte[] scriptArr) {
|
||||
int i;
|
||||
|
@ -277,18 +285,19 @@ public class LuaScriptPanel {
|
|||
linkManager.submit(() -> {
|
||||
BinaryProtocol bp = linkManager.getCurrentStreamState();
|
||||
|
||||
byte[] paddedScript = new byte[Fields.LUA_SCRIPT_SIZE];
|
||||
byte[] scriptBytes = script.getBytes(StandardCharsets.US_ASCII);
|
||||
System.arraycopy(scriptBytes, 0, paddedScript, 0, scriptBytes.length);
|
||||
StringIniField field = getLuaScriptField(bp);
|
||||
|
||||
byte[] paddedScript = getScriptBytes(field, script);
|
||||
|
||||
int idx = 0;
|
||||
int remaining;
|
||||
|
||||
log.info("Sending " + field);
|
||||
do {
|
||||
remaining = paddedScript.length - idx;
|
||||
int thisWrite = Math.min(remaining, Fields.BLOCKING_FACTOR);
|
||||
|
||||
bp.writeData(paddedScript, idx, Fields.LUASCRIPT.getOffset() + idx, thisWrite);
|
||||
bp.writeData(paddedScript, idx, field.getOffset() + idx, thisWrite);
|
||||
|
||||
idx += thisWrite;
|
||||
|
||||
|
@ -307,6 +316,13 @@ public class LuaScriptPanel {
|
|||
mp.setPaused(false);
|
||||
}
|
||||
|
||||
private static byte @NotNull [] getScriptBytes(StringIniField luaScript, String script) {
|
||||
byte[] paddedScript = new byte[luaScript.getSize()];
|
||||
byte[] scriptBytes = script.getBytes(StandardCharsets.US_ASCII);
|
||||
System.arraycopy(scriptBytes, 0, paddedScript, 0, scriptBytes.length);
|
||||
return paddedScript;
|
||||
}
|
||||
|
||||
private String getScript() {
|
||||
String script = scriptText.getText();
|
||||
return script;
|
||||
|
|
Loading…
Reference in New Issue