diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 6c4b2dda03..36c19a9bf3 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -409,6 +409,7 @@ void handleBurnCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint1 static TunerStudioReadRequest readRequest; static TunerStudioWriteChunkRequest writeChunkRequest; +static TunerStudioOchRequest ochRequest; static short int pageIn; static bool isKnownCommand(char command) { @@ -587,11 +588,20 @@ void handleQueryCommand(ts_channel_s *tsChannel, ts_response_format_e mode) { /** * @brief 'Output' command sends out a snapshot of current values */ -void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e mode) { +void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count) { + +// +// if (size < offset + count) { +// scheduleMsg(&tsLogger, "invalid offset/count %d/%d", offset, count); +// sendErrorCode(tsChannel); +// return; +// } + + tsState.outputChannelsCommandCounter++; prepareTunerStudioOutputs(); // this method is invoked too often to print any debug information - sr5SendResponse(tsChannel, mode, (const uint8_t *) &tsOutputChannels, sizeof(TunerStudioOutputChannels)); + sr5SendResponse(tsChannel, mode, ((const uint8_t *) &tsOutputChannels) + offset, count); } #define TEST_RESPONSE_TAG " ts_p_alive\r\n" @@ -706,8 +716,14 @@ bool handlePlainCommand(ts_channel_s *tsChannel, uint8_t command) { handlePageReadCommand(tsChannel, TS_PLAIN, readRequest.page, readRequest.offset, readRequest.count); return true; } else if (command == TS_OUTPUT_COMMAND) { + int received = sr5ReadData(tsChannel, (uint8_t * )&ochRequest, sizeof(ochRequest)); + if (received != sizeof(ochRequest)) { + tunerStudioError("Not enough for OutputChannelsCommand"); + return true; + } + //scheduleMsg(logger, "Got naked Channels???"); - handleOutputChannelsCommand(tsChannel, TS_PLAIN); + handleOutputChannelsCommand(tsChannel, TS_PLAIN, ochRequest.offset, ochRequest.count); return true; } else if (command == TS_LEGACY_HELLO_COMMAND) { tunerStudioDebug("ignoring LEGACY_HELLO_COMMAND"); @@ -735,7 +751,9 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin } else if (command == TS_EXECUTE) { handleExecuteCommand(tsChannel, data, incomingPacketSize - 1); } else if (command == TS_OUTPUT_COMMAND) { - handleOutputChannelsCommand(tsChannel, TS_CRC); + uint16_t offset = *(uint16_t *) (data); + uint16_t count = *(uint16_t *) (data + 2); + handleOutputChannelsCommand(tsChannel, TS_CRC, offset, count); } else if (command == TS_PAGE_COMMAND) { uint16_t page = *(uint16_t *) data; handlePageSelectCommand(tsChannel, TS_CRC, page); diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index c6dcd25667..9b6e577cde 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -251,5 +251,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20170525; + return 20170527; } diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index ce38bebc10..4dc8fb24b6 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -841,7 +841,7 @@ page = 1 ; see TS_FILE_VERSION in firmware code fileVersion = { 20161225 } - ochGetCommand = "O" + ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code ochBlockSize = 356 diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index cb7255ebde..49f335afb8 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -101,7 +101,7 @@ enable2ndByteCanID = false ; see TS_FILE_VERSION in firmware code fileVersion = { 20161225 } - ochGetCommand = "O" + ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code ochBlockSize = 356 diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index 7f4785f958..a81d66dced 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -498,7 +498,13 @@ public class BinaryProtocol { public boolean requestOutputChannels() { if (isClosed) return false; - byte[] response = executeCommand(new byte[]{COMMAND_OUTPUTS}, "output channels", false); + + byte packet[] = new byte[5]; + packet[0] = COMMAND_OUTPUTS; + putShort(packet, 1, 0); // offset + putShort(packet, 3, swap16(Fields.TS_OUTPUT_SIZE)); + + byte[] response = executeCommand(packet, "output channels", false); if (response == null || response.length != (Fields.TS_OUTPUT_SIZE + 1) || response[0] != RESPONSE_OK) return false; diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 8825b0716b..b78dcabd10 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -44,7 +44,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20170522; + public static final int CONSOLE_VERSION = 20170527; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port";