From e861b442127002b7fef3d27301678b4ebb1d133a Mon Sep 17 00:00:00 2001 From: Dale Schultz Date: Fri, 29 Oct 2021 20:01:46 -0400 Subject: [PATCH] Catch error when DME doesn't have lambda sensors: issue #107, and a few testing updates --- .../com/romraider/io/j2534/api/TestJ2534.java | 66 +++++++++++++++++-- .../io/connection/DS2LoggerConnection.java | 4 +- .../learning/DS2LearningTableValues.java | 19 ++++-- .../com/romraider/util/SettingsManager.java | 6 +- 4 files changed, 81 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/romraider/io/j2534/api/TestJ2534.java b/src/main/java/com/romraider/io/j2534/api/TestJ2534.java index 3d4e3c34..15b776ac 100644 --- a/src/main/java/com/romraider/io/j2534/api/TestJ2534.java +++ b/src/main/java/com/romraider/io/j2534/api/TestJ2534.java @@ -1,6 +1,6 @@ /* * RomRaider Open-Source Tuning, Logging and Reflashing - * Copyright (C) 2006-2018 RomRaider.com + * Copyright (C) 2006-2021 RomRaider.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,9 @@ package com.romraider.io.j2534.api; import static com.romraider.util.HexUtil.asHex; import static com.romraider.util.LogManager.initDebugLogging; +import java.util.ArrayList; +import java.util.List; + import com.romraider.io.j2534.api.J2534Impl.Config; import com.romraider.io.j2534.api.J2534Impl.Flag; import com.romraider.io.j2534.api.J2534Impl.Protocol; @@ -55,23 +58,76 @@ public class TestJ2534 { int msgId = api.startPassMsgFilter(channelId, (byte) 0x00, (byte) 0x00); try { + List msgs = new ArrayList(); byte[] ecuInit = null; if (protocol.equalsIgnoreCase("ssm")) { ecuInit = new byte[]{ (byte) 0x80, (byte) 0x10, (byte) 0xF0, (byte) 0x01, (byte) 0xBF, (byte) 0x40}; + msgs.add(ecuInit); } else if (protocol.equalsIgnoreCase("ds2")) { ecuInit = new byte[]{ (byte) 0x12, (byte) 0x04, (byte) 0x00, (byte) 0x16}; + byte[] engine = new byte[]{ + (byte) 0x12, (byte) 0x05, (byte) 0x0B, + (byte) 0x03, (byte) 0x1F}; + byte[] swtch = new byte[]{ + (byte) 0x12, (byte) 0x05, (byte) 0x0B, + (byte) 0x04, (byte) 0x18}; + byte[] lambda = new byte[]{ + (byte) 0x12, (byte) 0x05, (byte) 0x0B, + (byte) 0x91, (byte) 0x8D}; + byte[] adapt = new byte[]{ + (byte) 0x12, (byte) 0x05, (byte) 0x0B, + (byte) 0x92, (byte) 0x8E}; + byte[] corr = new byte[]{ + (byte) 0x12, (byte) 0x05, (byte) 0x0B, + (byte) 0x93, (byte) 0x8F}; + byte[] cat = new byte[]{ + (byte) 0x12, (byte) 0x05, (byte) 0x0B, + (byte) 0x94, (byte) 0x88}; + byte[] status = new byte[]{ + (byte) 0x12, (byte) 0x05, (byte) 0x0B, + (byte) 0x95, (byte) 0x89}; + byte[] close = new byte[]{ + (byte) 0x12, (byte) 0x05, (byte) 0x0B, + (byte) 0xFF, (byte) 0xE3}; + byte[] _0C = new byte[]{ + (byte) 0x12, (byte) 0x04, (byte) 0x0C, + (byte) 0x1A}; + byte[] _0D = new byte[]{ + (byte) 0x12, (byte) 0x04, (byte) 0x0D, + (byte) 0x1B}; + byte[] _25 = new byte[]{ + (byte) 0x12, (byte) 0x04, (byte) 0x25, + (byte) 0x33}; + byte[] _53 = new byte[]{ + (byte) 0x12, (byte) 0x04, (byte) 0x53, + (byte) 0x45}; + msgs.add(ecuInit); + msgs.add(engine); + msgs.add(swtch); + msgs.add(lambda); + msgs.add(adapt); + msgs.add(corr); + msgs.add(cat); + msgs.add(status); + msgs.add(close); + msgs.add(_0C); + msgs.add(_0D); + msgs.add(_25); + msgs.add(_53); } - api.writeMsg(channelId, ecuInit, 55L, TxFlags.NO_FLAGS); - System.out.println("Request = " + asHex(ecuInit)); + for (byte[] msg : msgs) { + api.writeMsg(channelId, msg, 55L, TxFlags.NO_FLAGS); + System.out.println("Request = " + asHex(msg)); - byte[] response = api.readMsg(channelId, 1, 2000L); - System.out.println("Response = " + asHex(response)); + byte[] response = api.readMsg(channelId, 500L); + System.out.println("Response = " + asHex(response)); + } } finally { api.stopMsgFilter(channelId, msgId); diff --git a/src/main/java/com/romraider/logger/ecu/comms/io/connection/DS2LoggerConnection.java b/src/main/java/com/romraider/logger/ecu/comms/io/connection/DS2LoggerConnection.java index e967c0ff..09eaa386 100644 --- a/src/main/java/com/romraider/logger/ecu/comms/io/connection/DS2LoggerConnection.java +++ b/src/main/java/com/romraider/logger/ecu/comms/io/connection/DS2LoggerConnection.java @@ -166,7 +166,9 @@ public final class DS2LoggerConnection implements LoggerConnection { || groupTest.startsWith("0x0b0x04") || groupTest.startsWith("0x0b0x91") || groupTest.startsWith("0x0b0x92") - || groupTest.startsWith("0x0b0x93")) { + || groupTest.startsWith("0x0b0x93") + || groupTest.startsWith("0x0b0x94") + || groupTest.startsWith("0x0b0x95")) { request = protocol.constructReadGroupRequest( module, group); diff --git a/src/main/java/com/romraider/logger/ecu/comms/learning/DS2LearningTableValues.java b/src/main/java/com/romraider/logger/ecu/comms/learning/DS2LearningTableValues.java index 2c9a6b52..1c3abcbe 100644 --- a/src/main/java/com/romraider/logger/ecu/comms/learning/DS2LearningTableValues.java +++ b/src/main/java/com/romraider/logger/ecu/comms/learning/DS2LearningTableValues.java @@ -1,6 +1,6 @@ /* * RomRaider Open-Source Tuning, Logging and Reflashing - * Copyright (C) 2006-2019 RomRaider.com + * Copyright (C) 2006-2021 RomRaider.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -149,12 +149,17 @@ public final class DS2LearningTableValues extends SwingWorker try { Collection queries = buildLearningQueries(); - LOGGER.info("Retrieving vehicle info & A/F values ..."); - connection.sendAddressReads( - queries, - settings.getDestinationTarget(), - new PollingStateImpl()); - LOGGER.info("Current vehicle info & A/F values retrieved."); + try { + LOGGER.info("Retrieving vehicle info & A/F values ..."); + connection.sendAddressReads( + queries, + settings.getDestinationTarget(), + new PollingStateImpl()); + LOGGER.info("Current vehicle info & A/F values retrieved."); + } + catch (Exception e) { + LOGGER.error(message + " Error retrieving values", e); + } Collections.sort( (List)queries, new ParameterIdComparator()); diff --git a/src/main/java/com/romraider/util/SettingsManager.java b/src/main/java/com/romraider/util/SettingsManager.java index b09b9a1d..a50dac54 100644 --- a/src/main/java/com/romraider/util/SettingsManager.java +++ b/src/main/java/com/romraider/util/SettingsManager.java @@ -1,6 +1,6 @@ /* * RomRaider Open-Source Tuning, Logging and Reflashing - * Copyright (C) 2006-2020 RomRaider.com + * Copyright (C) 2006-2021 RomRaider.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ResourceBundle; +import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.xml.sax.InputSource; @@ -38,6 +39,8 @@ import com.romraider.xml.DOMSettingsUnmarshaller; import com.sun.org.apache.xerces.internal.parsers.DOMParser; public class SettingsManager { + private static final Logger LOGGER = + Logger.getLogger(SettingsManager.class); private static final ResourceBundle rb = new ResourceUtil().getBundle( SettingsManager.class.getName()); private static final String SETTINGS_FILE = "/settings.xml"; @@ -68,6 +71,7 @@ public class SettingsManager { sf = new File(USER_HOME + SETTINGS_FILE); settingsFileIn = new FileInputStream(sf); } + LOGGER.info("Loaded settings from file: " + settingsDir.replace("\\", "/") + SETTINGS_FILE); final InputSource src = new InputSource(settingsFileIn); final DOMSettingsUnmarshaller domUms = new DOMSettingsUnmarshaller();