TS SD integration #1653
This commit is contained in:
parent
5649aa6a5d
commit
530439c424
|
@ -214,9 +214,9 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
||||||
|
|
||||||
private void handleSD_W_command(TcpIoStream stream, Packet packet, byte[] payload) throws IOException {
|
private void handleSD_W_command(TcpIoStream stream, Packet packet, byte[] payload) throws IOException {
|
||||||
log.info("TS_SD: 'w' " + IoStream.printHexBinary(packet.packet));
|
log.info("TS_SD: 'w' " + IoStream.printHexBinary(packet.packet));
|
||||||
if (payload[1] == 0 && payload[2] == 0x11) {
|
if (payload[1] == 0 && payload[2] == TS_SD_PROTOCOL_FETCH_INFO) {
|
||||||
|
|
||||||
if (payload[6] == 1) {
|
if (payload[6] == TS_SD_PROTOCOL_DO) {
|
||||||
log.info("TS_SD: do command, command=" + payload[payload.length - 1]);
|
log.info("TS_SD: do command, command=" + payload[payload.length - 1]);
|
||||||
sendOkResponse(stream);
|
sendOkResponse(stream);
|
||||||
} else if (payload[6] == TS_SD_PROTOCOL_READ_DIR) {
|
} else if (payload[6] == TS_SD_PROTOCOL_READ_DIR) {
|
||||||
|
@ -233,6 +233,8 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
||||||
int sectorCount = bb.getInt();
|
int sectorCount = bb.getInt();
|
||||||
log.info("TS_SD: sectorNumber=" + sectorNumber + ", sectorCount=" + sectorCount);
|
log.info("TS_SD: sectorNumber=" + sectorNumber + ", sectorCount=" + sectorCount);
|
||||||
sendOkResponse(stream);
|
sendOkResponse(stream);
|
||||||
|
} else {
|
||||||
|
log.info("TS_SD: Got unexpected w fetch " + IoStream.printHexBinary(packet.packet));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("TS_SD: Got unexpected w " + IoStream.printHexBinary(packet.packet));
|
log.info("TS_SD: Got unexpected w " + IoStream.printHexBinary(packet.packet));
|
||||||
|
@ -245,7 +247,7 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
||||||
log.info("TS_SD: RTC read command");
|
log.info("TS_SD: RTC read command");
|
||||||
byte[] response = new byte[9];
|
byte[] response = new byte[9];
|
||||||
stream.sendPacket(response);
|
stream.sendPacket(response);
|
||||||
} else if (payload[1] == 0 && payload[2] == 0x11) {
|
} else if (payload[1] == 0 && payload[2] == TS_SD_PROTOCOL_FETCH_INFO) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(payload, 5, 2);
|
ByteBuffer bb = ByteBuffer.wrap(payload, 5, 2);
|
||||||
bb.order(ByteOrder.BIG_ENDIAN);
|
bb.order(ByteOrder.BIG_ENDIAN);
|
||||||
int bufferLength = bb.getShort();
|
int bufferLength = bb.getShort();
|
||||||
|
@ -269,7 +271,7 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
||||||
|
|
||||||
response[9] = 0;
|
response[9] = 0;
|
||||||
response[10] = 1; // number of files
|
response[10] = 1; // number of files
|
||||||
} else {
|
} else if (bufferLength == 0x202){
|
||||||
// SD read directory command
|
// SD read directory command
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -290,9 +292,12 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
||||||
// response[1 + 30] = (byte) 1;
|
// response[1 + 30] = (byte) 1;
|
||||||
// response[1 + 31] = (byte) 0; // size
|
// response[1 + 31] = (byte) 0; // size
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.info("TS_SD: Got unexpected r fetch " + IoStream.printHexBinary(packet.packet));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
stream.sendPacket(response);
|
stream.sendPacket(response);
|
||||||
} else if (payload[1] == 0 && payload[2] == 0x14) {
|
} else if (payload[1] == 0 && payload[2] == TS_SD_PROTOCOL_FETCH_DATA) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(payload, 3, 4);
|
ByteBuffer bb = ByteBuffer.wrap(payload, 3, 4);
|
||||||
bb.order(ByteOrder.BIG_ENDIAN);
|
bb.order(ByteOrder.BIG_ENDIAN);
|
||||||
int blockNumber = bb.getShort();
|
int blockNumber = bb.getShort();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
debug="true"
|
debug="true"
|
||||||
target="${javac.target}"
|
target="${javac.target}"
|
||||||
destdir="build/classes"
|
destdir="build/classes"
|
||||||
classpath="lib/junit.jar:../../java_console/lib/annotations.jar:lib/snakeyaml.jar">
|
classpath="../../java_console/lib/jsr305-2.0.1.jar:lib/junit.jar:../../java_console/lib/annotations.jar:lib/snakeyaml.jar">
|
||||||
<src path="src"/>
|
<src path="src"/>
|
||||||
<src path="${console_path}/autoupdate/src"/>
|
<src path="${console_path}/autoupdate/src"/>
|
||||||
<src path="${console_path}/inifile/src"/>
|
<src path="${console_path}/inifile/src"/>
|
||||||
|
|
|
@ -11,6 +11,8 @@ import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.rusefi.config.generated.Fields.TS_SD_PROTOCOL_FETCH_INFO;
|
||||||
|
|
||||||
public class ConnectPanel {
|
public class ConnectPanel {
|
||||||
private final JPanel content = new JPanel(new BorderLayout());
|
private final JPanel content = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
|
@ -42,30 +44,33 @@ public class ConnectPanel {
|
||||||
try {
|
try {
|
||||||
byte[] packet;
|
byte[] packet;
|
||||||
byte[] response;
|
byte[] response;
|
||||||
|
IoStream stream = controllerConnector.getConnector().getBinaryProtocol().getStream();
|
||||||
|
|
||||||
packet = new byte[3];
|
packet = new byte[3];
|
||||||
packet[0] = Fields.TS_SD_R_COMMAND;
|
packet[0] = Fields.TS_SD_R_COMMAND;
|
||||||
packet[2] = Fields.TS_SD_PROTOCOL_RTC;
|
packet[2] = Fields.TS_SD_PROTOCOL_RTC;
|
||||||
IoStream stream = controllerConnector.getConnector().getBinaryProtocol().getStream();
|
|
||||||
|
|
||||||
stream.sendPacket(packet);
|
stream.sendPacket(packet);
|
||||||
|
|
||||||
response = stream.getDataBuffer().getPacket("RTC status");
|
response = stream.getDataBuffer().getPacket("RTC status");
|
||||||
System.out.println("RTC response " + IoStream.printHexBinary(response));
|
System.out.println("RTC response " + IoStream.printHexBinary(response));
|
||||||
|
|
||||||
|
|
||||||
packet = new byte[17];
|
packet = new byte[17];
|
||||||
packet[0] = Fields.TS_SD_W_COMMAND;
|
packet[0] = Fields.TS_SD_W_COMMAND;
|
||||||
packet[7] = Fields.TS_SD_PROTOCOL_READ_DIR;
|
packet[2] = TS_SD_PROTOCOL_FETCH_INFO;
|
||||||
|
packet[6] = Fields.TS_SD_PROTOCOL_READ_DIR;
|
||||||
|
stream.sendPacket(packet);
|
||||||
response = stream.getDataBuffer().getPacket("read dir command");
|
response = stream.getDataBuffer().getPacket("read dir command");
|
||||||
System.out.println("read dir command " + IoStream.printHexBinary(response));
|
System.out.println("read dir command " + IoStream.printHexBinary(response));
|
||||||
|
|
||||||
|
|
||||||
packet = new byte[17];
|
packet = new byte[8];
|
||||||
packet[0] = Fields.TS_SD_R_COMMAND;
|
packet[0] = Fields.TS_SD_R_COMMAND;
|
||||||
packet[1] = 0;
|
packet[1] = 0;
|
||||||
packet[2] = 0x11;
|
packet[2] = TS_SD_PROTOCOL_FETCH_INFO;
|
||||||
response = stream.getDataBuffer().getPacket("read command");
|
packet[5] = 0x02;
|
||||||
|
packet[6] = 0x02;
|
||||||
|
stream.sendPacket(packet);
|
||||||
|
response = stream.getDataBuffer().getPacket("read command", true);
|
||||||
System.out.println("read command " + IoStream.printHexBinary(response));
|
System.out.println("read command " + IoStream.printHexBinary(response));
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue