added write functions to ssm protocol

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@633 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
kascade 2007-04-19 05:23:49 +00:00
parent c6cd52ea85
commit 14a0f46a88
2 changed files with 23 additions and 0 deletions

View File

@ -28,6 +28,10 @@ public interface Protocol {
byte[] constructEcuInitRequest();
byte[] constructWriteMemoryRequest(byte[] address, byte[] values);
byte[] constructWriteAddressRequest(byte[] address, byte value);
byte[] constructReadMemoryRequest(byte[] address, int numBytes);
byte[] constructReadAddressRequest(byte[][] addresses);

View File

@ -31,6 +31,7 @@ import enginuity.logger.ecu.exception.InvalidResponseException;
import static enginuity.util.ByteUtil.asByte;
import static enginuity.util.HexUtil.asHex;
import static enginuity.util.ParamChecker.checkGreaterThanZero;
import static enginuity.util.ParamChecker.checkNotNull;
import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
public final class SSMProtocol implements Protocol {
@ -42,6 +43,10 @@ public final class SSMProtocol implements Protocol {
public static final byte READ_MEMORY_RESPONSE = (byte) 0xE0;
public static final byte READ_ADDRESS_COMMAND = (byte) 0xA8;
public static final byte READ_ADDRESS_RESPONSE = (byte) 0xE8;
public static final byte WRITE_MEMORY_COMMAND = (byte) 0xB0;
public static final byte WRITE_MEMORY_RESPONSE = (byte) 0xF0;
public static final byte WRITE_ADDRESS_COMMAND = (byte) 0xB8;
public static final byte WRITE_ADDRESS_RESPONSE = (byte) 0xF8;
public static final byte ECU_INIT_COMMAND = (byte) 0xBF;
public static final byte ECU_INIT_RESPONSE = (byte) 0xFF;
public static final int ADDRESS_SIZE = 3;
@ -54,6 +59,20 @@ public final class SSMProtocol implements Protocol {
return buildRequest(ECU_INIT_COMMAND, false, new byte[0]);
}
public byte[] constructWriteMemoryRequest(byte[] address, byte[] values) {
checkNotNullOrEmpty(address, "address");
checkNotNullOrEmpty(values, "values");
// 0x80 0x10 0xF0 data_length 0xB0 from_address value1 value2 ... valueN checksum
return buildRequest(WRITE_MEMORY_COMMAND, false, address, values);
}
public byte[] constructWriteAddressRequest(byte[] address, byte value) {
checkNotNullOrEmpty(address, "address");
checkNotNull(value, "value");
// 0x80 0x10 0xF0 data_length 0xB8 from_address value checksum
return buildRequest(WRITE_ADDRESS_COMMAND, false, address, new byte[]{value});
}
public byte[] constructReadMemoryRequest(byte[] address, int numBytes) {
checkNotNullOrEmpty(address, "address");
checkGreaterThanZero(numBytes, "numBytes");