Skip to content

Commit

Permalink
can+simulator functional test progress rusefi#5562
Browse files Browse the repository at this point in the history
  • Loading branch information
andreika-git committed Sep 27, 2023
1 parent 1e13a7a commit 0d3e934
Showing 1 changed file with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.rusefi.simulator;

import com.rusefi.enums.bench_test_packet_ids_e;
import com.rusefi.io.LinkManager;
import etch.util.CircularByteBuffer;

Expand All @@ -12,6 +13,8 @@

public class SimulatorFunctionalTest {
private final LinkManager linkManager;
private boolean gotCanPacketAnalog1 = false;
private boolean gotCanPacketAnalog2 = false;

public SimulatorFunctionalTest(LinkManager linkManager) {
this.linkManager = linkManager;
Expand All @@ -31,14 +34,19 @@ public void run() {
try {
int count = swap16(c.getShort());

c.get();
int dataLength = c.get();
c.get();
int ide = c.get();
int eid = c.getInt();
for (int idx = 0; idx < count; idx++) {
c.get();
int dataLength = c.get();
c.get(); // rtr
c.get(); // ide
int eid = c.getInt();
byte[] data = new byte[dataLength];
c.get(data);
processCanPacket(eid, data);
}


System.out.println("Got " + count + " packets");
System.out.println(response);
gotCan.countDown();

} catch (EOFException e) {
Expand All @@ -48,16 +56,29 @@ public void run() {

}
});
// todo 1 assert RAW_ANALOG can packet has arrived
gotCan.await(1, TimeUnit.MINUTES);

// assert RAW_ANALOG can packets have arrived
if (!gotCanPacketAnalog1 || !gotCanPacketAnalog2) {
throw new IllegalStateException("Didn't receive analog CAN packets! "
+ gotCanPacketAnalog1 + " " + gotCanPacketAnalog2);
}


// todo send new CAN command "request pin state for bench_mode_e pin BENCH_FUEL_PUMP

// todo ecu.sendCommand(CMD_FUEL_PUMP_BENCH



gotCan.await(1, TimeUnit.MINUTES);

}

private void processCanPacket(int eid, byte[] data) {
if (eid == bench_test_packet_ids_e.RAW_ANALOG_1.get()) {
gotCanPacketAnalog1 = true;
} else if (eid == bench_test_packet_ids_e.RAW_ANALOG_2.get()) {
gotCanPacketAnalog2 = true;
}
}
}

0 comments on commit 0d3e934

Please sign in to comment.