logging of live data structs was: data points #3614
This commit is contained in:
parent
0c0d843457
commit
b0158c8350
|
@ -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
|
// 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.
|
// of the reassembled packet.
|
||||||
byte[] reassemblyBuffer = new byte[Fields.TS_OUTPUT_SIZE + 1];
|
byte[] reassemblyBuffer = new byte[GetOutputsCommand.OUTPUT_SIZE + 1];
|
||||||
reassemblyBuffer[0] = Fields.TS_RESPONSE_OK;
|
reassemblyBuffer[0] = Fields.TS_RESPONSE_OK;
|
||||||
|
|
||||||
int reassemblyIdx = 0;
|
int reassemblyIdx = 0;
|
||||||
int remaining = Fields.TS_OUTPUT_SIZE;
|
int remaining = GetOutputsCommand.OUTPUT_SIZE;
|
||||||
|
|
||||||
while (remaining > 0) {
|
while (remaining > 0) {
|
||||||
// If less than one full chunk left, do a smaller read
|
// If less than one full chunk left, do a smaller read
|
||||||
|
|
|
@ -10,8 +10,10 @@ import static com.rusefi.binaryprotocol.IoHelper.putShort;
|
||||||
import static com.rusefi.binaryprotocol.IoHelper.swap16;
|
import static com.rusefi.binaryprotocol.IoHelper.swap16;
|
||||||
|
|
||||||
public class GetOutputsCommand {
|
public class GetOutputsCommand {
|
||||||
|
public static int OUTPUT_SIZE = Fields.TS_OUTPUT_SIZE;
|
||||||
|
|
||||||
public static byte[] createRequest() {
|
public static byte[] createRequest() {
|
||||||
return createRequest(0, Fields.TS_OUTPUT_SIZE);
|
return createRequest(0, GetOutputsCommand.OUTPUT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] createRequest(int offset, int size) {
|
public static byte[] createRequest(int offset, int size) {
|
||||||
|
@ -22,7 +24,7 @@ public class GetOutputsCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendOutput(IoStream stream) throws IOException {
|
public static void sendOutput(IoStream stream) throws IOException {
|
||||||
byte[] response = new byte[1 + Fields.TS_OUTPUT_SIZE];
|
byte[] response = new byte[1 + GetOutputsCommand.OUTPUT_SIZE];
|
||||||
response[0] = (byte) BinaryProtocolServer.TS_OK.charAt(0);
|
response[0] = (byte) BinaryProtocolServer.TS_OK.charAt(0);
|
||||||
stream.sendPacket(response);
|
stream.sendPacket(response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
import com.rusefi.io.LinkConnector;
|
import com.rusefi.io.LinkConnector;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
|
import com.rusefi.io.commands.GetOutputsCommand;
|
||||||
import com.rusefi.io.tcp.BinaryProtocolServer;
|
import com.rusefi.io.tcp.BinaryProtocolServer;
|
||||||
import com.rusefi.io.tcp.TcpConnector;
|
import com.rusefi.io.tcp.TcpConnector;
|
||||||
import com.rusefi.io.tcp.TcpIoStream;
|
import com.rusefi.io.tcp.TcpIoStream;
|
||||||
|
@ -59,7 +60,7 @@ public class TestHelper {
|
||||||
public static BinaryProtocolServer createVirtualController(ConfigurationImage ci, int port, Listener serverSocketCreationCallback, BinaryProtocolServer.Context context) throws IOException {
|
public static BinaryProtocolServer createVirtualController(ConfigurationImage ci, int port, Listener serverSocketCreationCallback, BinaryProtocolServer.Context context) throws IOException {
|
||||||
BinaryProtocolState state = new BinaryProtocolState();
|
BinaryProtocolState state = new BinaryProtocolState();
|
||||||
state.setController(ci);
|
state.setController(ci);
|
||||||
state.setCurrentOutputs(new byte[1 + Fields.TS_OUTPUT_SIZE]);
|
state.setCurrentOutputs(new byte[1 + GetOutputsCommand.OUTPUT_SIZE]);
|
||||||
|
|
||||||
LinkManager linkManager = new LinkManager();
|
LinkManager linkManager = new LinkManager();
|
||||||
linkManager.setConnector(LinkConnector.getDetachedConnector(state));
|
linkManager.setConnector(LinkConnector.getDetachedConnector(state));
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.opensr5.ini.field.ScalarIniField;
|
||||||
import com.rusefi.TestHelper;
|
import com.rusefi.TestHelper;
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
|
import com.rusefi.io.commands.GetOutputsCommand;
|
||||||
import com.rusefi.io.tcp.BinaryProtocolServer;
|
import com.rusefi.io.tcp.BinaryProtocolServer;
|
||||||
import com.rusefi.tune.xml.Constant;
|
import com.rusefi.tune.xml.Constant;
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ class BinaryProtocolServerSandbox {
|
||||||
ScalarIniField iniField = TestHelper.createIniField(Fields.TWOSTROKE);
|
ScalarIniField iniField = TestHelper.createIniField(Fields.TWOSTROKE);
|
||||||
iniField.setValue(controller, new Constant(iniField.getName(), "", "1", iniField.getDigits()));
|
iniField.setValue(controller, new Constant(iniField.getName(), "", "1", iniField.getDigits()));
|
||||||
state.setController(controller);
|
state.setController(controller);
|
||||||
state.setCurrentOutputs(new byte[1 + Fields.TS_OUTPUT_SIZE]);
|
state.setCurrentOutputs(new byte[1 + GetOutputsCommand.OUTPUT_SIZE]);
|
||||||
|
|
||||||
LinkManager linkManager = new LinkManager();
|
LinkManager linkManager = new LinkManager();
|
||||||
linkManager.setConnector(LinkConnector.getDetachedConnector(state));
|
linkManager.setConnector(LinkConnector.getDetachedConnector(state));
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class LocalApplicationProxyTest {
|
||||||
|
|
||||||
applicationConnection.sendPacket(commandPacket);
|
applicationConnection.sendPacket(commandPacket);
|
||||||
BinaryProtocolServer.Packet response = applicationConnection.readPacket();
|
BinaryProtocolServer.Packet response = applicationConnection.readPacket();
|
||||||
assertEquals(Fields.TS_OUTPUT_SIZE + 1, response.getPacket().length);
|
assertEquals(GetOutputsCommand.OUTPUT_SIZE + 1, response.getPacket().length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class ControllerConnectionState {
|
||||||
outputRoundAroundDuration = (int) (System.currentTimeMillis() - start);
|
outputRoundAroundDuration = (int) (System.currentTimeMillis() - start);
|
||||||
if (packet == null)
|
if (packet == null)
|
||||||
throw new IOException("getOutputs: No response");
|
throw new IOException("getOutputs: No response");
|
||||||
if (packet.length != 1 + Fields.TS_OUTPUT_SIZE)
|
if (packet.length != 1 + GetOutputsCommand.OUTPUT_SIZE)
|
||||||
throw new IOException("getOutputs: unexpected package length " + packet.length);
|
throw new IOException("getOutputs: unexpected package length " + packet.length);
|
||||||
sensorsHolder.grabSensorValues(packet);
|
sensorsHolder.grabSensorValues(packet);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue