Allow user to specific read block size in Test App

This commit is contained in:
Dale Schultz 2015-03-03 19:00:09 -05:00
parent 0652b2d9e6
commit e04dc48276
6 changed files with 25 additions and 14 deletions

View File

@ -111,6 +111,7 @@ public final class RamTuneTestApp extends AbstractFrame {
private final JTextField addressField = new JTextField(6);
private final JTextField lengthField = new JTextField(4);
private final JTextField sendTimeoutField = new JTextField(4);
private final JTextField blocksize = new JTextField(3);
private final JTextArea dataField = new JTextArea(5, 80);
private final JTextArea responseField = new JTextArea(10, 80);
private final JCheckBox blockRead = new JCheckBox("Block Read");
@ -237,6 +238,11 @@ public final class RamTuneTestApp extends AbstractFrame {
blockRead.setSelected(true);
blockRead.setToolTipText("uncheck to read range byte at a time");
blockReadPanel.add(blockRead);
blockReadPanel.add(new JLabel("Block Size:"));
blocksize.setText("128");
blocksize.setToolTipText("Set to value allowed by the ECU");
blockReadPanel.add(blocksize);
JPanel addressPanel = new JPanel(new FlowLayout(LEFT));
addressPanel.add(addressFieldPanel);
addressPanel.add(lengthPanel);
@ -297,7 +303,7 @@ public final class RamTuneTestApp extends AbstractFrame {
final CommandGenerator commandGenerator = (CommandGenerator) commandComboBox.getSelectedItem();
if (validateInput(commandGenerator) && confirmCommandExecution(commandGenerator)) {
StringBuilder builder = new StringBuilder();
List<byte[]> commands = commandGenerator.createCommands(module, getData(), getAddress(), getLength(), getBlockRead());
List<byte[]> commands = commandGenerator.createCommands(module, getData(), getAddress(), getLength(), getBlockRead(), getBlockSize());
for (byte[] command : commands) {
appendResponseLater("SND [" + commandGenerator + "]:\t" + asHex(command) + "\n");
byte[] response = protocol.preprocessResponse(command, commandExecutor.executeCommand(command), pollMode);
@ -352,6 +358,10 @@ public final class RamTuneTestApp extends AbstractFrame {
return blockRead.isSelected();
}
private int getBlockSize() {
return getIntFromField(blocksize);
}
private int getSendTimeout() {
return getIntFromField(sendTimeoutField);
}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
* Copyright (C) 2006-2015 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
@ -30,5 +30,6 @@ public abstract class AbstractCommandGenerator implements CommandGenerator {
this.protocol = protocol;
}
@Override
public abstract String toString();
}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2014 RomRaider.com
* Copyright (C) 2006-2015 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
@ -25,6 +25,6 @@ import com.romraider.logger.ecu.definition.Module;
public interface CommandGenerator {
List<byte[]> createCommands(Module module, byte[] data, byte[] address, int length, boolean blockRead);
List<byte[]> createCommands(Module module, byte[] data, byte[] address,
int length, boolean blockRead, int blocksize);
}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2014 RomRaider.com
* Copyright (C) 2006-2015 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
@ -33,7 +33,7 @@ public final class EcuInitCommandGenerator extends AbstractCommandGenerator {
}
public List<byte[]> createCommands(Module module, byte[] data, byte[] address,
int length, boolean blockRead) {
int length, boolean blockRead, int blocksize) {
return asList(protocol.constructEcuInitRequest(module));
}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2014 RomRaider.com
* Copyright (C) 2006-2015 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
@ -32,21 +32,21 @@ import com.romraider.io.protocol.Protocol;
import com.romraider.logger.ecu.definition.Module;
public final class ReadCommandGenerator extends AbstractCommandGenerator {
private static final int INCREMENT_SIZE = 128;
public ReadCommandGenerator(Protocol protocol) {
super(protocol);
}
public List<byte[]> createCommands(Module module, byte[] data, byte[] address,
int length, boolean blockRead) {
int length, boolean blockRead, int blocksize) {
checkNotNull(module, "module");
checkNotNullOrEmpty(address, "address");
checkGreaterThanZero(length, "length");
checkGreaterThanZero(blocksize, "blocksize");
if (length == 1) {
return asList(createCommandForAddress(module, address));
} else {
return createCommandsForRange(module, address, length, blockRead);
return createCommandsForRange(module, address, length, blockRead, blocksize);
}
}
@ -55,10 +55,10 @@ public final class ReadCommandGenerator extends AbstractCommandGenerator {
}
private List<byte[]> createCommandsForRange(Module module, byte[] address,
int length, boolean blockRead) {
int length, boolean blockRead, int blocksize) {
int incrementSize = 1;
if (blockRead) {
incrementSize = INCREMENT_SIZE;
incrementSize = blocksize;
}
List<byte[]> commands = new ArrayList<byte[]>();
byte[] readAddress = copy(address);

View File

@ -38,7 +38,7 @@ public final class WriteCommandGenerator extends AbstractCommandGenerator {
}
public List<byte[]> createCommands(Module module, byte[] data, byte[] address,
int length, boolean blockRead) {
int length, boolean blockRead, int blocksize) {
checkNotNull(module, "module");
checkNotNullOrEmpty(address, "address");
checkNotNullOrEmpty(data, "data");