REO progress

This commit is contained in:
rusefi 2020-08-15 12:08:20 -04:00
parent 966153a5b7
commit 8f05d735db
3 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package com.rusefi.core;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -11,7 +12,12 @@ public interface ISensorHolder {
continue;
}
ByteBuffer bb = ByteBuffer.wrap(response, 1 + sensor.getOffset(), 4);
int offset = 1 + sensor.getOffset();
int size = 4;
if (offset + size > response.length) {
throw new IllegalArgumentException(sensor + String.format(" but %d+%d in %d", offset, size, response.length));
}
ByteBuffer bb = ByteBuffer.wrap(response, offset, size);
bb.order(ByteOrder.LITTLE_ENDIAN);
double rawValue = sensor.getValueForChannel(bb);

View File

@ -17,6 +17,7 @@ import static com.rusefi.config.generated.Fields.*;
/**
* @author Andrey Belomutskiy
* 2/11/13
* @see Fields#TS_OUTPUT_SIZE
*/
public enum Sensor {
/**

View File

@ -122,6 +122,8 @@ public class ControllerConnectionState {
outputRoundAroundDuration = (int) (System.currentTimeMillis() - start);
if (packet == null)
throw new IOException("getOutputs: No response");
if (packet.length != 1 + Fields.TS_OUTPUT_SIZE)
throw new IOException("getOutputs: unexpected package length " + packet.length);
sensorsHolder.grabSensorValues(packet);
}