reducing smell
This commit is contained in:
parent
03c2342d28
commit
d82157cd68
|
@ -546,11 +546,11 @@ public class BinaryProtocol {
|
|||
|
||||
// TODO: Get rid of the +1. This adds a byte at the front to tack a fake TS response code on the front
|
||||
// of the reassembled packet.
|
||||
byte[] reassemblyBuffer = new byte[GetOutputsCommand.OUTPUT_SIZE + 1];
|
||||
byte[] reassemblyBuffer = new byte[TS_TOTAL_OUTPUT_SIZE + 1];
|
||||
reassemblyBuffer[0] = Fields.TS_RESPONSE_OK;
|
||||
|
||||
int reassemblyIdx = 0;
|
||||
int remaining = GetOutputsCommand.OUTPUT_SIZE;
|
||||
int remaining = TS_TOTAL_OUTPUT_SIZE;
|
||||
|
||||
while (remaining > 0) {
|
||||
// If less than one full chunk left, do a smaller read
|
||||
|
|
|
@ -10,10 +10,9 @@ import static com.rusefi.binaryprotocol.IoHelper.putShort;
|
|||
import static com.rusefi.binaryprotocol.IoHelper.swap16;
|
||||
|
||||
public class GetOutputsCommand {
|
||||
public static int OUTPUT_SIZE = Fields.TS_TOTAL_OUTPUT_SIZE;
|
||||
|
||||
public static byte[] createRequest() {
|
||||
return createRequest(0, GetOutputsCommand.OUTPUT_SIZE);
|
||||
return createRequest(0, Fields.TS_TOTAL_OUTPUT_SIZE);
|
||||
}
|
||||
|
||||
public static byte[] createRequest(int offset, int size) {
|
||||
|
@ -24,7 +23,7 @@ public class GetOutputsCommand {
|
|||
}
|
||||
|
||||
public static void sendOutput(IoStream stream) throws IOException {
|
||||
byte[] response = new byte[1 + GetOutputsCommand.OUTPUT_SIZE];
|
||||
byte[] response = new byte[1 + Fields.TS_TOTAL_OUTPUT_SIZE];
|
||||
response[0] = (byte) BinaryProtocolServer.TS_OK.charAt(0);
|
||||
stream.sendPacket(response);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.rusefi;
|
|||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.Logger;
|
||||
import com.opensr5.ini.field.ScalarIniField;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||
import com.rusefi.config.Field;
|
||||
|
@ -10,9 +9,7 @@ import com.rusefi.config.generated.Fields;
|
|||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.LinkConnector;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.commands.GetOutputsCommand;
|
||||
import com.rusefi.io.tcp.BinaryProtocolServer;
|
||||
import com.rusefi.io.tcp.TcpConnector;
|
||||
import com.rusefi.io.tcp.TcpIoStream;
|
||||
import com.rusefi.proxy.NetworkConnector;
|
||||
import com.rusefi.server.ControllerInfo;
|
||||
|
@ -60,7 +57,7 @@ public class TestHelper {
|
|||
public static BinaryProtocolServer createVirtualController(ConfigurationImage ci, int port, Listener serverSocketCreationCallback, BinaryProtocolServer.Context context) throws IOException {
|
||||
BinaryProtocolState state = new BinaryProtocolState();
|
||||
state.setController(ci);
|
||||
state.setCurrentOutputs(new byte[1 + GetOutputsCommand.OUTPUT_SIZE]);
|
||||
state.setCurrentOutputs(new byte[1 + Fields.TS_TOTAL_OUTPUT_SIZE]);
|
||||
|
||||
LinkManager linkManager = new LinkManager();
|
||||
linkManager.setConnector(LinkConnector.getDetachedConnector(state));
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.opensr5.ini.field.ScalarIniField;
|
|||
import com.rusefi.TestHelper;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.io.commands.GetOutputsCommand;
|
||||
import com.rusefi.io.tcp.BinaryProtocolServer;
|
||||
import com.rusefi.tune.xml.Constant;
|
||||
|
||||
|
@ -26,7 +25,7 @@ class BinaryProtocolServerSandbox {
|
|||
ScalarIniField iniField = TestHelper.createIniField(Fields.TWOSTROKE);
|
||||
iniField.setValue(controller, new Constant(iniField.getName(), "", "1", iniField.getDigits()));
|
||||
state.setController(controller);
|
||||
state.setCurrentOutputs(new byte[1 + GetOutputsCommand.OUTPUT_SIZE]);
|
||||
state.setCurrentOutputs(new byte[1 + Fields.TS_TOTAL_OUTPUT_SIZE]);
|
||||
|
||||
LinkManager linkManager = new LinkManager();
|
||||
linkManager.setConnector(LinkConnector.getDetachedConnector(state));
|
||||
|
|
|
@ -98,7 +98,7 @@ public class LocalApplicationProxyTest {
|
|||
|
||||
applicationConnection.sendPacket(commandPacket);
|
||||
BinaryProtocolServer.Packet response = applicationConnection.readPacket();
|
||||
assertEquals(GetOutputsCommand.OUTPUT_SIZE + 1, response.getPacket().length);
|
||||
assertEquals(Fields.TS_TOTAL_OUTPUT_SIZE + 1, response.getPacket().length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ public class ControllerConnectionState {
|
|||
outputRoundAroundDuration = (int) (System.currentTimeMillis() - start);
|
||||
if (packet == null)
|
||||
throw new IOException("getOutputs: No response");
|
||||
if (packet.length != 1 + GetOutputsCommand.OUTPUT_SIZE)
|
||||
if (packet.length != 1 + Fields.TS_TOTAL_OUTPUT_SIZE)
|
||||
throw new IOException("getOutputs: unexpected package length " + packet.length);
|
||||
sensorsHolder.grabSensorValues(packet);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue