mirror of https://github.com/rusefi/RomRaider.git
logger code cleanup
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@464 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
926b7e6072
commit
0f935a4896
|
@ -96,7 +96,6 @@ public final class TestSSMConnectionImpl implements SerialConnection {
|
|||
|
||||
private boolean isIamRequest() {
|
||||
String hex = asHex(request);
|
||||
System.out.println("request = " + hex);
|
||||
return hex.startsWith("8010F011A8") && hex.contains("FF8228FF8229FF822AFF822B");
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ public interface Protocol {
|
|||
|
||||
byte[] constructReadAddressRequest(byte[][] addresses);
|
||||
|
||||
byte[] preprocessResponse(byte[] request, byte[] response);
|
||||
|
||||
void checkValidEcuInitResponse(byte[] bytes) throws InvalidResponseException;
|
||||
|
||||
EcuInit parseEcuInitResponse(byte[] response);
|
||||
|
|
|
@ -68,13 +68,16 @@ public final class SSMProtocol implements Protocol {
|
|||
return buildRequest(READ_ADDRESS_COMMAND, true, addresses);
|
||||
}
|
||||
|
||||
public byte[] preprocessResponse(byte[] request, byte[] response) {
|
||||
return filterRequestFromResponse(request, response);
|
||||
}
|
||||
|
||||
public void checkValidEcuInitResponse(byte[] response) throws InvalidResponseException {
|
||||
// request response_header 3_unknown_bytes 5_ecu_id_bytes readable_params_switches... checksum
|
||||
// 8010F001BF40 80F01039FF A21011315258400673FACB842B83FEA800000060CED4FDB060000F200000000000DC0000551E30C0F222000040FB00E10000000000000000 59
|
||||
// response_header 3_unknown_bytes 5_ecu_id_bytes readable_params_switches... checksum
|
||||
// 80F01039FF A21011315258400673FACB842B83FEA800000060CED4FDB060000F200000000000DC0000551E30C0F222000040FB00E10000000000000000 59
|
||||
checkNotNullOrEmpty(response, "response");
|
||||
byte[] filteredResponse = filterRequestFromResponse(constructEcuInitRequest(), response);
|
||||
validateResponse(filteredResponse);
|
||||
byte responseType = filteredResponse[4];
|
||||
validateResponse(response);
|
||||
byte responseType = response[4];
|
||||
if (responseType != ECU_INIT_RESPONSE) {
|
||||
throw new InvalidResponseException("Unexpected ECU Init response type: " + asHex(new byte[]{responseType}));
|
||||
}
|
||||
|
@ -82,7 +85,7 @@ public final class SSMProtocol implements Protocol {
|
|||
|
||||
public EcuInit parseEcuInitResponse(byte[] response) {
|
||||
checkNotNullOrEmpty(response, "response");
|
||||
byte[] responseData = extractResponseData(filterRequestFromResponse(constructEcuInitRequest(), response));
|
||||
byte[] responseData = extractResponseData(response);
|
||||
return new SSMEcuInit(responseData);
|
||||
}
|
||||
|
||||
|
|
|
@ -260,7 +260,8 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
controller.addLogger(id, fileLoggingControllerSwitch, new LoggerCallback() {
|
||||
public void callback(byte[] bytes) {
|
||||
// update handlers
|
||||
if ((int) fileLoggingControllerSwitch.getSelectedConvertor().convert(bytes) == 1) {
|
||||
double value = fileLoggingControllerSwitch.getSelectedConvertor().convert(bytes);
|
||||
if ((int) value == 1) {
|
||||
fileUpdateHandler.start();
|
||||
} else {
|
||||
fileUpdateHandler.stop();
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
package enginuity.logger.comms.io.connection;
|
||||
|
||||
import enginuity.io.connection.SerialConnection;
|
||||
import enginuity.io.connection.TestSSMConnectionImpl;
|
||||
import static enginuity.io.protocol.SSMResponseProcessor.filterRequestFromResponse;
|
||||
import enginuity.io.connection.SerialConnectionImpl;
|
||||
import enginuity.logger.comms.io.protocol.LoggerProtocol;
|
||||
import enginuity.logger.comms.io.protocol.SSMLoggerProtocol;
|
||||
import enginuity.logger.comms.query.RegisteredQuery;
|
||||
|
@ -41,8 +40,8 @@ public final class SSMLoggerConnection implements LoggerConnection {
|
|||
protocol = new SSMLoggerProtocol();
|
||||
|
||||
// Use TestSSMConnectionImpl for testing!!
|
||||
//serialConnection = new SerialConnectionImpl(protocol.getConnectionProperties(), portName);
|
||||
serialConnection = new TestSSMConnectionImpl(protocol.getConnectionProperties(), portName);
|
||||
serialConnection = new SerialConnectionImpl(protocol.getConnectionProperties(), portName);
|
||||
// serialConnection = new TestSSMConnectionImpl(protocol.getConnectionProperties(), portName);
|
||||
}
|
||||
|
||||
public void sendAddressReads(Collection<RegisteredQuery> queries) {
|
||||
|
@ -65,7 +64,12 @@ public final class SSMLoggerConnection implements LoggerConnection {
|
|||
}
|
||||
serialConnection.read(response);
|
||||
|
||||
protocol.processReadAddressResponses(queries, filterRequestFromResponse(request, response));
|
||||
byte[] processedResponse = protocol.preprocessResponse(request, response);
|
||||
|
||||
System.out.println("Request ---> " + asHex(request));
|
||||
System.out.println("Response <--- " + asHex(processedResponse));
|
||||
|
||||
protocol.processReadAddressResponses(queries, processedResponse);
|
||||
} catch (Exception e) {
|
||||
close();
|
||||
throw new SerialCommunicationException(e);
|
||||
|
|
|
@ -32,8 +32,9 @@ public interface LoggerProtocol {
|
|||
|
||||
byte[] constructReadAddressResponse(Collection<RegisteredQuery> queries);
|
||||
|
||||
byte[] preprocessResponse(byte[] request, byte[] response);
|
||||
|
||||
void processReadAddressResponses(Collection<RegisteredQuery> queries, byte[] response);
|
||||
|
||||
ConnectionProperties getConnectionProperties();
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import static enginuity.io.protocol.SSMProtocol.DATA_SIZE;
|
|||
import static enginuity.io.protocol.SSMProtocol.REQUEST_NON_DATA_BYTES;
|
||||
import static enginuity.io.protocol.SSMProtocol.RESPONSE_NON_DATA_BYTES;
|
||||
import static enginuity.io.protocol.SSMResponseProcessor.extractResponseData;
|
||||
import static enginuity.io.protocol.SSMResponseProcessor.filterRequestFromResponse;
|
||||
import enginuity.logger.comms.query.RegisteredQuery;
|
||||
import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
|
||||
|
||||
|
@ -57,6 +58,10 @@ public final class SSMLoggerProtocol implements LoggerProtocol {
|
|||
return new byte[(numAddresses * DATA_SIZE + RESPONSE_NON_DATA_BYTES) + (numAddresses * ADDRESS_SIZE + REQUEST_NON_DATA_BYTES)];
|
||||
}
|
||||
|
||||
public byte[] preprocessResponse(byte[] request, byte[] response) {
|
||||
return filterRequestFromResponse(request, response);
|
||||
}
|
||||
|
||||
// processes the response bytes and sets individual responses on corresponding query objects
|
||||
@SuppressWarnings({"PointlessArithmeticExpression"})
|
||||
public void processReadAddressResponses(Collection<RegisteredQuery> queries, byte[] response) {
|
||||
|
|
|
@ -113,10 +113,13 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
EcuConnection ecuConnection = new EcuConnectionImpl(protocol.getConnectionProperties(), settings.getLoggerPort());
|
||||
try {
|
||||
messageListener.reportMessage("Sending ECU Init...");
|
||||
byte[] response = ecuConnection.send(protocol.constructEcuInitRequest());
|
||||
System.out.println("Ecu Init response = " + asHex(response));
|
||||
protocol.checkValidEcuInitResponse(response);
|
||||
ecuInitCallback.callback(protocol.parseEcuInitResponse(response));
|
||||
byte[] request = protocol.constructEcuInitRequest();
|
||||
System.out.println("Ecu Init Request ---> " + asHex(request));
|
||||
byte[] response = ecuConnection.send(request);
|
||||
byte[] processedResponse = protocol.preprocessResponse(request, response);
|
||||
protocol.checkValidEcuInitResponse(processedResponse);
|
||||
System.out.println("Ecu Init Response <--- " + asHex(processedResponse));
|
||||
ecuInitCallback.callback(protocol.parseEcuInitResponse(processedResponse));
|
||||
messageListener.reportMessage("Sending ECU Init...done.");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue