ROE progress

This commit is contained in:
rusefi 2020-06-20 22:04:08 -04:00
parent 0b285ac98a
commit cf32ced944
3 changed files with 24 additions and 3 deletions

View File

@ -96,7 +96,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
public boolean isClosed;
/**
* Snapshot of current gauges status
* @see BinaryProtocolCommands#COMMAND_OUTPUTS
* @see Fields#TS_OUTPUT_COMMAND
*/
public byte[] currentOutputs;
private SensorCentral.SensorListener rpmListener = value -> {
@ -552,7 +552,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
return false;
byte packet[] = new byte[5];
packet[0] = COMMAND_OUTPUTS;
packet[0] = Fields.TS_OUTPUT_COMMAND;
putShort(packet, 1, 0); // offset
putShort(packet, 3, swap16(Fields.TS_OUTPUT_SIZE));

View File

@ -36,7 +36,7 @@ public class IoHelper {
}
public static int swap16(int x) {
return (((x & 0xFF) << 8) | ((x) >> 8));
return (((x & 0xff) << 8) | ((x >> 8) & 0xff));
}
static int swap32(int x) {

View File

@ -0,0 +1,21 @@
package com.rusefi.binaryprotocol.test;
import com.rusefi.binaryprotocol.IoHelper;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
public class IoHelperTest {
@Test
public void testSwap16() throws IOException {
byte packet[] = {-12, 0};
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet));
short a = dis.readShort();
int x = IoHelper.swap16(a);
assertEquals(244, x);
}
}