parent
70385e0951
commit
d0db738647
|
@ -21,7 +21,7 @@ public interface IniFileModel {
|
|||
@Deprecated // always use 'Field' generated parameter with code-generated name?
|
||||
IniField getIniField(String key);
|
||||
|
||||
IniField getOutputChannel(String key);
|
||||
IniField getOutputChannel(String key) throws IniMemberNotFound;
|
||||
|
||||
Map<String, String> getProtocolMeta();
|
||||
|
||||
|
|
|
@ -96,9 +96,11 @@ public class IniFileModelImpl implements IniFileModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IniField getOutputChannel(String key) {
|
||||
public IniField getOutputChannel(String key) throws IniMemberNotFound {
|
||||
IniField result = allOutputChannels.get(key);
|
||||
return Objects.requireNonNull(result, () -> key + " field not found");
|
||||
if (result == null)
|
||||
throw new IniMemberNotFound(key + " field not found");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.opensr5.ini;
|
||||
|
||||
public class IniMemberNotFound extends Exception {
|
||||
public IniMemberNotFound(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.panama;
|
||||
|
||||
import com.opensr5.ini.IniMemberNotFound;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.generated.TsOutputs;
|
||||
|
@ -10,11 +11,13 @@ import com.rusefi.io.LinkManager;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PanamaHelper {
|
||||
public static IniField getIniField(final BinaryProtocol bp) {
|
||||
return bp.getIniFile().getOutputChannel(TsOutputs.MCUSERIAL.getName());
|
||||
public static final String MCUSERIAL = TsOutputs.MCUSERIAL.getName();
|
||||
|
||||
public static IniField getIniField(final BinaryProtocol bp) throws IniMemberNotFound {
|
||||
return bp.getIniFile().getOutputChannel(MCUSERIAL);
|
||||
}
|
||||
|
||||
public static IniField getIniField(LinkManager linkManager) {
|
||||
public static IniField getIniField(LinkManager linkManager) throws IniMemberNotFound {
|
||||
return getIniField(linkManager.getBinaryProtocol());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* @see BinaryProtocolServerSandbox
|
||||
*/
|
||||
public class SerialSandbox {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
public static void main(String[] args) throws Exception {
|
||||
boolean textPull = false;
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
|
|
|
@ -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 = 20250216;
|
||||
int CONSOLE_VERSION = 20250221;
|
||||
AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
static long classBuildTimeMillis() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.maintenance;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ini.IniMemberNotFound;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import com.rusefi.SerialPortScanner;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
|
@ -15,6 +16,7 @@ import static com.devexperts.logging.Logging.getLogging;
|
|||
|
||||
public class OutputChannelsHelper {
|
||||
private static final Logging log = getLogging(OutputChannelsHelper.class);
|
||||
private static final String MCUSERIAL = PanamaHelper.MCUSERIAL;
|
||||
|
||||
public static Optional<Integer> readMcuSerial(
|
||||
final SerialPortScanner.PortResult ecuPort,
|
||||
|
@ -23,15 +25,7 @@ public class OutputChannelsHelper {
|
|||
return BinaryProtocolExecutor.executeWithSuspendedPortScanner(
|
||||
ecuPort.port,
|
||||
callbacks,
|
||||
(binaryProtocol) -> {
|
||||
try {
|
||||
return readMcuSerial(binaryProtocol, callbacks);
|
||||
} catch (final Exception e) {
|
||||
log.error("Reading `MCUSERIAL` output channel failed:", e);
|
||||
callbacks.logLine("Reading `MCUSERIAL` output channel failed");
|
||||
return Optional.empty();
|
||||
}
|
||||
},
|
||||
(binaryProtocol) -> readMcuSerial(binaryProtocol, callbacks),
|
||||
Optional.empty(),
|
||||
false
|
||||
);
|
||||
|
@ -41,24 +35,25 @@ public class OutputChannelsHelper {
|
|||
final BinaryProtocol binaryProtocol,
|
||||
final UpdateOperationCallbacks callbacks
|
||||
) {
|
||||
callbacks.logLine("Reading `MCUSERIAL` output channel...");
|
||||
Optional<Integer> result = Optional.empty();
|
||||
final IniField mcuSerialField = PanamaHelper.getIniField(binaryProtocol);
|
||||
if (mcuSerialField != null) {
|
||||
final AtomicInteger mcuSerial = new AtomicInteger();
|
||||
SensorCentral.getInstance().addListener(() -> {
|
||||
mcuSerial.set(PanamaHelper.getMcuSerial(mcuSerialField));
|
||||
});
|
||||
if (binaryProtocol.requestOutputChannels()) {
|
||||
callbacks.logLine(String.format("`MCUSERIAL` is %d", mcuSerial.get()));
|
||||
result = Optional.of(mcuSerial.get());
|
||||
} else {
|
||||
callbacks.logLine("Failed to request output channels...");
|
||||
}
|
||||
} else {
|
||||
callbacks.logLine("Reading `" + MCUSERIAL + "` output channel...");
|
||||
IniField mcuSerialField;
|
||||
try {
|
||||
mcuSerialField = PanamaHelper.getIniField(binaryProtocol);
|
||||
} catch (IniMemberNotFound e) {
|
||||
callbacks.logLine("Please update firmware to use this feature...");
|
||||
return Optional.empty();
|
||||
}
|
||||
final AtomicInteger mcuSerial = new AtomicInteger();
|
||||
SensorCentral.getInstance().addListener(() -> {
|
||||
mcuSerial.set(PanamaHelper.getMcuSerial(mcuSerialField));
|
||||
});
|
||||
if (binaryProtocol.requestOutputChannels()) {
|
||||
callbacks.logLine(String.format("`MCUSERIAL` is %d", mcuSerial.get()));
|
||||
return Optional.of(mcuSerial.get());
|
||||
} else {
|
||||
callbacks.logLine("Failed to request output channels...");
|
||||
return Optional.empty();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ public enum TuneUploader {
|
|||
|
||||
private static final String CALIBRATIONS_TO_UPLOAD_FILE_NAME = BinaryProtocolLocalCache.STATE_FOLDER + "calibrations_to_upload";
|
||||
|
||||
/**
|
||||
* @return true in case of success, false otherwise
|
||||
*/
|
||||
public synchronized boolean uploadTune(
|
||||
final SerialPortScanner.PortResult ecuPort,
|
||||
final String panamaUrl,
|
||||
|
@ -29,6 +32,7 @@ public enum TuneUploader {
|
|||
if (instanceName == null || instanceName.isEmpty()) {
|
||||
callbacks.logLine("Instance name is not defined!");
|
||||
callbacks.logLine("Please right-click on logo and use `Instance name` context menu to specify an instance name.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final Optional<CalibrationsInfo> calibrationsToUpload = readAndBackupCurrentCalibrations(
|
||||
|
@ -43,7 +47,7 @@ public enum TuneUploader {
|
|||
|
||||
final Optional<Integer> receivedMcuSerial = OutputChannelsHelper.readMcuSerial(ecuPort, callbacks);
|
||||
if (!receivedMcuSerial.isPresent()) {
|
||||
callbacks.logLine("Failed to read `MCUSERIAL` output channel");
|
||||
callbacks.logLine("Failed to read `MCUSERIAL` output channel - please update firmware first!");
|
||||
return false;
|
||||
}
|
||||
final int mcuSerial = receivedMcuSerial.get();
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.tune;
|
|||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.opensr5.ini.IniMemberNotFound;
|
||||
import com.opensr5.ini.field.ScalarIniField;
|
||||
import com.opensr5.ini.field.StringIniField;
|
||||
import com.rusefi.*;
|
||||
|
@ -150,7 +151,7 @@ public class LoadOlderTuneTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void findFieldByName() {
|
||||
public void findFieldByName() throws IniMemberNotFound {
|
||||
IniFileModel ini = IniFileModelImpl.readIniFile(TuneReadWriteTest.TEST_INI);
|
||||
StringIniField make = (StringIniField) ini.getIniField(Fields.ENGINEMAKE);
|
||||
assertNotNull(make);
|
||||
|
|
Loading…
Reference in New Issue