Skip to content

Commit 9b8bd1f

Browse files
committed
Resolve merge conflict
2 parents 70b6fa6 + 1b5e86c commit 9b8bd1f

File tree

6 files changed

+103
-51
lines changed

6 files changed

+103
-51
lines changed

docs/ssm_info.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The subaru select monitor protocol uses an ISO9141 interface and uses UART settings: 4800 bps n, 8, 1
1+
The Subaru Select Monitor protocol uses an ISO9141 interface and uses UART settings: 4800 bps n, 8, 1
22
All data is sent and recieved using small packets that all share a common header.
33

44

@@ -42,22 +42,27 @@ These are the known commands:
4242
0xB8 Write single address
4343
0xBF ECU init
4444

45+
After the command byte is the read mode byte, if reading continues the ECU will continue to output until it receives another command.
46+
These are the known modes:
47+
48+
0x00 Read Once
49+
0x01 Read Continuous
4550

4651
-------------------------------- Command Formats --------------------------------
4752

4853
A0 Block Read Request
4954

5055
A0 PP AA AA AA CC
5156

52-
PP == pad?
57+
PP == read mode
5358
AA AA AA = address
5459
CC == byte count - 1
5560

5661
A8 Address Read Request
5762

5863
A8 PP A1 A1 A1 A2 A2 A2 A3 A3 A3...
5964

60-
PP == pad?
65+
PP == read mode
6166
A1 A1 A1 == address
6267
A2 A2 A2 ... == optional addresses
6368

@@ -100,13 +105,13 @@ Received:
100105

101106
-----------------------
102107

103-
Address Read: Read Address 0x000008 and 0x00001C (ecu returns values 0x7D and 0xB1)
108+
Address Read: Continiously Read Address 0x000008 and 0x00001C (ecu returns values 0x7D and 0xB1)
104109

105110
Sent:
106-
0x80 0x10 0xF0 0x08 0xA8 0x00 0x00 0x00 0x08 0x00 0x00 0x1C 0x54
111+
0x80 0x10 0xF0 0x08 0xA8 0x01 0x00 0x00 0x08 0x00 0x00 0x1C 0x55
107112

108113
Received:
109-
0x80 0xF0 0x10 0x03 0xE8 0x7D 0xB1 0x99
114+
0x80 0xF0 0x10 0x03 0xE8 0x7D 0xB1 0x99 0x80 0xF0 0x10 0x03 0xE8 0x7D 0xB1 0x99 0x80 0xF0 0x10 0x03 0xE8 0x7D 0xB1 0x99...
110115

111116
-----------------------
112117

@@ -251,6 +256,7 @@ The individual bits are flags that will be set to one if the parameter can be re
251256
2 -------------------------
252257
1 -------------------------
253258
0 -------------------------
259+
254260
********** BYTE 21 **********
255261
7 Neutral Position Switch
256262
6 Idle Switch
@@ -260,17 +266,17 @@ The individual bits are flags that will be set to one if the parameter can be re
260266
2 Power Steering Switch
261267
1 Air Conditioning Switch
262268
0 -------------------------
269+
263270
********** BYTE 22 **********
264-
7 Handle Switchv
271+
7 Handle Switch
265272
6 Starter Switch
266-
267273
5 Front O2 Rich Signal
268274
4 Rear O2 Rich Signal
269-
270275
3 Front O2 #2 Rich Signal
271276
2 Knock Signal 1
272277
1 Knock Signal 2
273278
0 Electrical Load Signal
279+
274280
********** BYTE 23 **********
275281
7 Crank Position Sensor
276282
6 Cam Position Senso

src/main/java/com/romraider/editor/ecu/ECUEditor.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.awt.FlowLayout;
4141
import java.awt.Font;
4242
import java.awt.GridLayout;
43+
import java.awt.datatransfer.DataFlavor;
4344
import java.awt.event.ActionEvent;
4445
import java.awt.event.ActionListener;
4546
import java.awt.event.WindowEvent;
@@ -54,6 +55,7 @@
5455
import java.io.FileWriter;
5556
import java.io.IOException;
5657
import java.text.MessageFormat;
58+
import java.util.List;
5759
import java.util.ResourceBundle;
5860
import java.util.Vector;
5961

@@ -67,6 +69,7 @@
6769
import javax.swing.JSplitPane;
6870
import javax.swing.JTextArea;
6971
import javax.swing.SwingWorker;
72+
import javax.swing.TransferHandler;
7073
import javax.swing.filechooser.FileNameExtensionFilter;
7174
import javax.swing.tree.TreePath;
7275

@@ -199,8 +202,44 @@ public void initializeEditorUI() {
199202
toolBarPanel.setVisible(true);
200203

201204
this.add(toolBarPanel, BorderLayout.NORTH);
205+
setupDragAndDrop();
202206
validate();
203-
}
207+
}
208+
209+
public void setupDragAndDrop()
210+
{
211+
setTransferHandler(new TransferHandler() {
212+
private static final long serialVersionUID = 1L;
213+
214+
@Override
215+
public boolean canImport(TransferSupport support) {
216+
// Accept drops of files only
217+
return support.isDataFlavorSupported(DataFlavor.javaFileListFlavor);
218+
}
219+
220+
@Override
221+
public boolean importData(TransferSupport support) {
222+
if (!canImport(support)) {
223+
return false;
224+
}
225+
226+
try {
227+
@SuppressWarnings("unchecked")
228+
List<File> droppedFiles =
229+
(List<File>) support.getTransferable()
230+
.getTransferData(DataFlavor.javaFileListFlavor);
231+
232+
for (File file : droppedFiles) {
233+
openImage(file);
234+
}
235+
return true;
236+
} catch (Exception e) {
237+
e.printStackTrace();
238+
}
239+
return false;
240+
}
241+
});
242+
}
204243

205244
public void checkDefinitions() {
206245
if (settings.getEcuDefinitionFiles().size() <= 0) {

src/main/java/com/romraider/maps/Table1DView.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* RomRaider Open-Source Tuning, Logging and Reflashing
3-
* Copyright (C) 2006-2021 RomRaider.com
3+
* Copyright (C) 2006-2025 RomRaider.com
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -279,6 +279,7 @@ public void highlightLiveData(String liveVal) {
279279
}
280280

281281
int startIdx = data.length;
282+
double currentErrorToLiveValue = Double.POSITIVE_INFINITY;
282283
for (int i = 0; i < data.length; i++) {
283284
double currentValue = 0.0;
284285
if(table.isStaticDataTable() && null != data[i].getStaticText()) {
@@ -290,14 +291,14 @@ public void highlightLiveData(String liveVal) {
290291
} else {
291292
currentValue = data[i].getDataCell().getRealValue();
292293
}
293-
294-
if (liveValue == currentValue) {
295-
startIdx = i;
296-
break;
297-
} else if (liveValue < currentValue){
298-
startIdx = i-1;
299-
break;
300-
}
294+
295+
if(Math.abs(currentValue - liveValue) < currentErrorToLiveValue)
296+
{
297+
currentErrorToLiveValue = Math.abs(currentValue - liveValue);
298+
startIdx = i;
299+
300+
if(currentErrorToLiveValue <= 0.001) break;
301+
}
301302
}
302303

303304
setLiveDataIndex(startIdx);

src/main/java/com/romraider/maps/Table3D.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,18 @@ public double queryTable(Double input_x, Double input_y) {
572572
}
573573
}
574574

575-
double valueX1 = linearInterpolation(input_x, axisXData[startX].getRealValue(),
576-
axisXData[endX].getRealValue(), tableData[startX][startY].getRealValue(),
577-
tableData[endX][startY].getRealValue());
575+
double valueX1 = linearInterpolation(input_x,
576+
axisXData[startX].getRealValue(),
577+
axisXData[endX].getRealValue(),
578+
tableData[startX][startY].getRealValue(),
579+
tableData[endX][startY].getRealValue());
580+
581+
double valueX2 = linearInterpolation(input_x,
582+
axisXData[startX].getRealValue(),
583+
axisXData[endX].getRealValue(),
584+
tableData[startX][endY].getRealValue(),
585+
tableData[endX][endY].getRealValue());
578586

579-
double valueX2 = linearInterpolation(input_x, axisXData[startX].getRealValue(),
580-
axisXData[endX].getRealValue(), tableData[endX][startY].getRealValue(),
581-
tableData[endX][startY].getRealValue());
582587

583588
return linearInterpolation(input_y, axisYData[startY].getRealValue(), axisYData[endY].getRealValue(),
584589
valueX1, valueX2);

src/main/java/com/romraider/xml/ConversionLayer/XDFConversionLayer.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* RomRaider Open-Source Tuning, Logging and Reflashing
3-
* Copyright (C) 2006-2022 RomRaider.com
3+
* Copyright (C) 2006-2025 RomRaider.com
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -42,6 +42,7 @@
4242

4343
import com.romraider.util.HexUtil;
4444
import com.romraider.util.ResourceUtil;
45+
import com.romraider.xml.RomAttributeParser;
4546

4647
public class XDFConversionLayer extends ConversionLayer {
4748
protected static final ResourceBundle rb = new ResourceUtil().getBundle(
@@ -67,7 +68,7 @@ private class EmbedInfoData {
6768
Node axisNode;
6869
Node flagsNodeTable;
6970
}
70-
71+
7172
@Override
7273
public String getDefinitionPickerInfo() {
7374
return rb.getString("LOADINGWARNING");
@@ -295,13 +296,13 @@ private Element parseAxis(Document doc, Element tableNodeRR, Node axisNode, Node
295296
targetTable.setAttribute("size" + id, "" + staticCells.size());
296297
targetTable.removeAttribute("endian");
297298
targetTable.removeAttribute("storagetype");
298-
299+
299300
for(String label : staticCells)
300301
{
301302
Element data = doc.createElement("data");
302303
data.setTextContent(label);
303304
targetTable.appendChild(data);
304-
305+
305306
if (numDigitsStatic == -1) {
306307
// Assume the format from the static data
307308
String split[] = label.split("\\.");
@@ -397,14 +398,14 @@ private Element getScalingNodeForTable(Element tableNodeRR) {
397398
private void postProcessTable(Element tableNodeRR) {
398399
int validAxis = 0;
399400
int nodeCountTable = tableNodeRR.getChildNodes().getLength();
400-
401+
401402
LinkedList <Element> nodesToRemove = new LinkedList <Element> ();
402403
for (int i = 0; i < nodeCountTable; i++) {
403404
Element n = (Element) tableNodeRR.getChildNodes().item(i);
404405
if (n.getNodeName().equalsIgnoreCase("table")) {
405406
if (n.hasAttribute("storageaddress") || n.getAttributeNode("type").getValue().contains("Static")) {
406407
validAxis++;
407-
408+
408409
// Use the sizes of the X and Y axis
409410
// for the main table
410411
Attr sizex = n.getAttributeNode("sizex");
@@ -416,7 +417,7 @@ else if (sizey != null)
416417
} else {
417418
Element scalingNode = getScalingNodeForTable(tableNodeRR);
418419
Element axisScalingNode = getScalingNodeForTable(n);
419-
420+
420421
// 2D Tables work different in XDFs
421422
// We have to use the unit of the "missing" axis for the main table
422423
if (scalingNode != null && axisScalingNode != null && !scalingNode.hasAttribute("units")) {
@@ -482,7 +483,14 @@ private Node parseXDFHeader(Document doc, Node romNode, Node header) {
482483
Node offsetNode = n.getAttributes().getNamedItem("offset");
483484

484485
if (offsetNode != null) {
485-
offset = Integer.parseInt(offsetNode.getNodeValue());
486+
String nv = offsetNode.getNodeValue();
487+
if (nv.length() > 2 && nv.substring(0, 2).equalsIgnoreCase("0x")) {
488+
// node value is hex in string format
489+
offset = RomAttributeParser.parseHexString(nv);
490+
} else {
491+
// node value is decimal in string format
492+
offset = Integer.parseInt(nv);
493+
}
486494

487495
if (!n.getAttributes().getNamedItem("subtract").getNodeValue().equals("0")) {
488496
offset *= -1;

src/main/java/com/romraider/xml/RomAttributeParser.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* RomRaider Open-Source Tuning, Logging and Reflashing
3-
* Copyright (C) 2006-2022 RomRaider.com
3+
* Copyright (C) 2006-2025 RomRaider.com
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
2929
import com.romraider.maps.Table;
3030
import com.romraider.maps.Table1DView;
3131
import com.romraider.util.ByteUtil;
32+
import com.romraider.util.HexUtil;
3233

3334
public final class RomAttributeParser {
3435

@@ -45,15 +46,7 @@ else if (input.equalsIgnoreCase("little") || input.equalsIgnoreCase(Settings.End
4546
}
4647

4748
public static int parseHexString(String input) {
48-
if (input.equals("0")) {
49-
return 0;
50-
}
51-
else if (input.length() > 2 && input.substring(0, 2).equalsIgnoreCase("0x")) {
52-
return Integer.parseInt(input.substring(2), 16);
53-
}
54-
else {
55-
return Integer.parseInt(input, 16);
56-
}
49+
return HexUtil.hexToInt(input);
5750
}
5851

5952
public static int parseStorageType(String input) {
@@ -95,7 +88,7 @@ public static int parseScaleType(String input) {
9588
return Settings.LINEAR;
9689
}
9790
}
98-
91+
9992
public static Table1DView.Table1DType parseTableAxis(String input) {
10093
//4 and 5 are only for backwards compatibilty, is anybody even using this?
10194
if (input.equalsIgnoreCase("X Axis") || input.equalsIgnoreCase("Static X Axis") || input.equalsIgnoreCase("4")) {
@@ -108,7 +101,7 @@ else if (input.equalsIgnoreCase("Y Axis") || input.equalsIgnoreCase("Static Y Ax
108101
return Table1DView.Table1DType.NO_AXIS;
109102
}
110103
}
111-
104+
112105
public static Table.TableType parseTableType(String input) {
113106
if (input.equalsIgnoreCase("3D") || input.equalsIgnoreCase(Table.TableType.TABLE_3D.getMarshallingString())) {
114107
return Table.TableType.TABLE_3D;
@@ -127,16 +120,16 @@ else if (input.equalsIgnoreCase("Y Axis") || input.equalsIgnoreCase("Static Y Ax
127120
return Table.TableType.TABLE_1D;
128121
}
129122
}
130-
123+
131124
//This assumes the bits inside the mask aren't spread. OK = 11110000, Not OK = 11001100
132-
public static long parseByteValueMasked(byte[] input, Settings.Endian endian, int address, int length, boolean signed, int mask) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
125+
public static long parseByteValueMasked(byte[] input, Settings.Endian endian, int address, int length, boolean signed, int mask) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
133126
long tempValue = parseByteValue(input,endian,address,length,signed) & mask;
134-
127+
135128
byte index = ByteUtil.firstOneOfMask(mask);
136-
129+
137130
return tempValue >> index;
138131
}
139-
132+
140133
public static long parseByteValue(byte[] input, Settings.Endian endian, int address, int length, boolean signed) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
141134
try {
142135
long output = 0L;
@@ -252,7 +245,7 @@ else if (input.substring(input.length() - 2).equalsIgnoreCase("mb")) {
252245
else if (input.substring(input.length() - 1).equalsIgnoreCase("b")) {
253246
return Integer.parseInt(input.substring(0, input.length() - 1));
254247
}
255-
248+
256249
return Integer.parseInt(input);
257250
}
258251

0 commit comments

Comments
 (0)