From 8bd4bb96b62977f9ce410c2f981b1094626b6f04 Mon Sep 17 00:00:00 2001 From: David Holdeman Date: Sun, 19 Jul 2020 15:05:47 -0500 Subject: [PATCH 01/18] upload artifacts --- .github/workflows/build-firmware.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index 71269b7d2a..bbdb9a267a 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -133,6 +133,27 @@ jobs: name: console ${{matrix.build-target}} junit path: ./java_console/build/*.txt + - name: Upload build bin + if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} + uses: actions/upload-artifacts@v2 + with: + name: rusefi_${{matrix.build-target}}.bin + path: firmware/deliver/rusefi_${{matrix.build-target}}.bin + + - name: Upload build hex + if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} + uses: actions/upload-artifacts@v2 + with: + name: rusefi_${{matrix.build-target}}.hex + path: firmware/deliver/rusefi_${{matrix.build-target}}.hex + + - name: Upload build dfu + if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} + uses: actions/upload-artifacts@v2 + with: + name: rusefi_${{matrix.build-target}}.dfu + path: firmware/deliver/rusefi_${{matrix.build-target}}.dfu + - name: Upload bundle if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} uses: actions/upload-artifact@v2 From f02f65957ae5ac06713302893a4e5f15b2751b9d Mon Sep 17 00:00:00 2001 From: David Holdeman Date: Sun, 19 Jul 2020 15:09:29 -0500 Subject: [PATCH 02/18] fix typo --- .github/workflows/build-firmware.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index bbdb9a267a..9605b36076 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -135,21 +135,21 @@ jobs: - name: Upload build bin if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} - uses: actions/upload-artifacts@v2 + uses: actions/upload-artifact@v2 with: name: rusefi_${{matrix.build-target}}.bin path: firmware/deliver/rusefi_${{matrix.build-target}}.bin - name: Upload build hex if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} - uses: actions/upload-artifacts@v2 + uses: actions/upload-artifact@v2 with: name: rusefi_${{matrix.build-target}}.hex path: firmware/deliver/rusefi_${{matrix.build-target}}.hex - name: Upload build dfu if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} - uses: actions/upload-artifacts@v2 + uses: actions/upload-artifact@v2 with: name: rusefi_${{matrix.build-target}}.dfu path: firmware/deliver/rusefi_${{matrix.build-target}}.dfu From fe8cc068a83f2fa3fe7fb02870eff7e2af0e6af5 Mon Sep 17 00:00:00 2001 From: David Holdeman Date: Sun, 19 Jul 2020 15:30:32 -0500 Subject: [PATCH 03/18] try ./ --- .github/workflows/build-firmware.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index 9605b36076..b14b3f4de0 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -138,21 +138,21 @@ jobs: uses: actions/upload-artifact@v2 with: name: rusefi_${{matrix.build-target}}.bin - path: firmware/deliver/rusefi_${{matrix.build-target}}.bin + path: ./firmware/deliver/rusefi_${{matrix.build-target}}.bin - name: Upload build hex if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} uses: actions/upload-artifact@v2 with: name: rusefi_${{matrix.build-target}}.hex - path: firmware/deliver/rusefi_${{matrix.build-target}}.hex + path: ./firmware/deliver/rusefi_${{matrix.build-target}}.hex - name: Upload build dfu if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} uses: actions/upload-artifact@v2 with: name: rusefi_${{matrix.build-target}}.dfu - path: firmware/deliver/rusefi_${{matrix.build-target}}.dfu + path: ./firmware/deliver/rusefi_${{matrix.build-target}}.dfu - name: Upload bundle if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} From e0bf2eb9098340bed9049bd5d7881a7de9cfaf3b Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sun, 19 Jul 2020 15:05:31 -0700 Subject: [PATCH 04/18] fix (#1620) --- unit_tests/tests/sensor/func_sensor.cpp | 2 +- unit_tests/tests/sensor/mock/mock_sensor.h | 8 +++----- unit_tests/tests/tests.mk | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/unit_tests/tests/sensor/func_sensor.cpp b/unit_tests/tests/sensor/func_sensor.cpp index b5551dd403..ed78e49300 100644 --- a/unit_tests/tests/sensor/func_sensor.cpp +++ b/unit_tests/tests/sensor/func_sensor.cpp @@ -40,7 +40,7 @@ TEST_F(SensorConverted, TestValid) { EXPECT_FALSE(s.Valid); } - dut.postRawValue(25, 0); + dut.postRawValue(25, getTimeNowNt()); // Should be valid, with a value of 25*2 = 50 { diff --git a/unit_tests/tests/sensor/mock/mock_sensor.h b/unit_tests/tests/sensor/mock/mock_sensor.h index c037194b00..287758046b 100644 --- a/unit_tests/tests/sensor/mock/mock_sensor.h +++ b/unit_tests/tests/sensor/mock/mock_sensor.h @@ -9,13 +9,11 @@ struct MockSensor final : public StoredValueSensor { } - void set(float value) - { - setValidValue(value, 0); + void set(float value) { + setValidValue(value, getTimeNowNt()); } - void invalidate() - { + void invalidate() { StoredValueSensor::invalidate(); } diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index 72d0c281a4..2051f8fc50 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -9,6 +9,7 @@ TESTS_SRC_CPP = \ tests/ignition_injection/injection_mode_transition.cpp \ tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp \ tests/ignition_injection/test_miata_na6_real_cranking.cpp \ + tests/ignition_injection/test_multispark.cpp \ tests/ignition_injection/test_ignition_scheduling.cpp \ tests/ignition_injection/test_fuelCut.cpp \ tests/test_util.cpp \ @@ -37,7 +38,6 @@ TESTS_SRC_CPP = \ tests/test_accel_enrichment.cpp \ tests/test_tacho.cpp \ tests/test_gpiochip.cpp \ - tests/ignition_injection/test_multispark.cpp \ tests/test_deadband.cpp \ tests/sensor/basic_sensor.cpp \ tests/sensor/func_sensor.cpp \ From 8617e2f81cb179b308b5334a11338e08e9240e0a Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 18:27:30 -0400 Subject: [PATCH 05/18] poke --- firmware/svnversion.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/svnversion.h b/firmware/svnversion.h index e81ad4d022..c28b38be05 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,12 +1,12 @@ // This file was generated by Version2Header -// Sun Jul 19 01:43:06 EDT 2020 +// Sun Jul 19 18:27:20 EDT 2020 #ifndef GIT_HASH -#define GIT_HASH "5e39d1ff305f1d5e2fe176e82bf2e1860723af98" +#define GIT_HASH "d6464fffe715cdfa7b4c46f18eb5b60ffd93302f" #endif #ifndef VCS_VERSION -#define VCS_VERSION "24365" +#define VCS_VERSION "24395" #endif From dabc5f321e09cdaad0e21e3c935f8e6151482649 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 18:33:51 -0400 Subject: [PATCH 06/18] poke --- firmware/svnversion.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/svnversion.h b/firmware/svnversion.h index c28b38be05..f3f7cbca7a 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,12 +1,12 @@ // This file was generated by Version2Header -// Sun Jul 19 18:27:20 EDT 2020 +// Sun Jul 19 18:33:27 EDT 2020 #ifndef GIT_HASH -#define GIT_HASH "d6464fffe715cdfa7b4c46f18eb5b60ffd93302f" +#define GIT_HASH "6aea8881742a55601b09f44648b9e66d105cb7b0" #endif #ifndef VCS_VERSION -#define VCS_VERSION "24395" +#define VCS_VERSION "24396" #endif From 3d6da4a910aa9360e8ed4d08f8b9bd74aab4f00a Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 18:34:53 -0400 Subject: [PATCH 07/18] poke --- firmware/svnversion.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/svnversion.h b/firmware/svnversion.h index f3f7cbca7a..3bb52d90b9 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,12 +1,12 @@ // This file was generated by Version2Header -// Sun Jul 19 18:33:27 EDT 2020 +// Sun Jul 19 18:34:45 EDT 2020 #ifndef GIT_HASH -#define GIT_HASH "6aea8881742a55601b09f44648b9e66d105cb7b0" +#define GIT_HASH "f96e4c88e0b38256ceec956e48c22b9f0e63b2ed" #endif #ifndef VCS_VERSION -#define VCS_VERSION "24396" +#define VCS_VERSION "24397" #endif From ff4cfad888a8effbf3c6f6b3331ea9b26545c7de Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 18:37:10 -0400 Subject: [PATCH 08/18] status update --- work_in_progress.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/work_in_progress.md b/work_in_progress.md index ba146a5c16..27e296c6e6 100644 --- a/work_in_progress.md +++ b/work_in_progress.md @@ -1,3 +1,10 @@ +July, 19 2020 status +* Stefan and AndreiKA are looking to improve miata idle (again!) +* AndreiKA and AndreyB are focuses on rusEFI Online +* Matt is dealing with a number of different scheduling defects +* Miata NA base tune is getting closer +* GDI is a bit on hold + Apr, 20 2020 status: * Nick and Chris are focusing on GDI progress * Matt is focusing on ETB https://github.com/rusefi/rusefi/issues/1240 https://github.com/rusefi/rusefi/issues/1336 From 736326a616e2e504545d5385383b1b57a4f4622e Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 18:55:33 -0400 Subject: [PATCH 09/18] byte counter just for fun --- .../rusefi/stream/LogicdataStreamFile.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/java_console/models/src/main/java/com/rusefi/stream/LogicdataStreamFile.java b/java_console/models/src/main/java/com/rusefi/stream/LogicdataStreamFile.java index 01f446c761..33a0310c09 100644 --- a/java_console/models/src/main/java/com/rusefi/stream/LogicdataStreamFile.java +++ b/java_console/models/src/main/java/com/rusefi/stream/LogicdataStreamFile.java @@ -47,6 +47,7 @@ public class LogicdataStreamFile extends StreamFile { private final String fileName; private final List eventsBuffer = new ArrayList<>(); + private int totalBytes = 0; private static final String [] channelNames = { "Primary", "Secondary", "Trg", "Sync", "Coil", "Injector", "Channel 6", "Channel 7" }; @@ -149,7 +150,7 @@ public class LogicdataStreamFile extends StreamFile { //////////////////////////////////////////////////////////////////// private void writeHeader() throws IOException { - stream.write(magic); + writeByte(magic); write(title.length()); write(title); @@ -352,17 +353,22 @@ public class LogicdataStreamFile extends StreamFile { // set 16-bit 'sign' flag if (!useLongDeltas && (d & SIGN_FLAG) == SIGN_FLAG) d = (d & 0x7fff) | (SIGN_FLAG >> 16); - stream.write((byte)(d & 0xff)); - stream.write((byte)((d >> 8) & 0xff)); + writeByte((byte)(d & 0xff)); + writeByte((byte)((d >> 8) & 0xff)); if (useLongDeltas) { - stream.write((byte)((d >> 16) & 0xff)); - stream.write((byte)((d >> 24) & 0xff)); + writeByte((byte)((d >> 16) & 0xff)); + writeByte((byte)((d >> 24) & 0xff)); } } - stream.write(0x00); + writeByte(0x00); } - private void writeChannelDataFooter() throws IOException { + private void writeByte(int i) throws IOException { + stream.write(i); + totalBytes++; + } + + private void writeChannelDataFooter() throws IOException { write(0, 3); write(1); write(1); @@ -453,11 +459,11 @@ public class LogicdataStreamFile extends StreamFile { private void writeAs(long value, int numBytes) throws IOException { if (value == 0) { - stream.write(0); + writeByte(0); } else { - stream.write(numBytes); + writeByte(numBytes); for (int i = 0; i < numBytes; i++) { - stream.write((byte)((value >> (i * 8)) & 0xff)); + writeByte((byte)((value >> (i * 8)) & 0xff)); } } } @@ -467,7 +473,7 @@ public class LogicdataStreamFile extends StreamFile { if (value < 0 || value > 0xFFFFFFFFL) { writeAs(value, 8); } else if (value == 0) { - stream.write(0); + writeByte(0); } else if (value <= 0xff) { writeAs(value, 1); } else if (value <= 0xffff) { @@ -481,16 +487,16 @@ public class LogicdataStreamFile extends StreamFile { private void write(double value) throws IOException { if (value == 0.0) { - stream.write(0); + writeByte(0); } else { - stream.write(8); + writeByte(8); // doubles are saved little-endian, sorry Java :) ByteBuffer bb = ByteBuffer.allocate(8); bb.order(ByteOrder.LITTLE_ENDIAN); bb.putDouble(value); bb.rewind(); for (int i = 0; i < 8; i++) { - stream.write(bb.get()); + writeByte(bb.get()); } } } @@ -498,13 +504,13 @@ public class LogicdataStreamFile extends StreamFile { private void write(String str) throws IOException { write(str.length()); for (char c : str.toCharArray()) { - stream.write(c); + writeByte(c); } } private void writeRaw(int value, int num) throws IOException { for (int i = 0; i < num; i++) { - stream.write(value); + writeByte(value); } } } From 5be0eac528e36d009743d7c378f336d9abdb111d Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 19:29:26 -0400 Subject: [PATCH 10/18] addind a bit of clarity --- .../java/com/rusefi/stream/LogicdataStreamFile.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java_console/models/src/main/java/com/rusefi/stream/LogicdataStreamFile.java b/java_console/models/src/main/java/com/rusefi/stream/LogicdataStreamFile.java index 33a0310c09..fc1faea5bc 100644 --- a/java_console/models/src/main/java/com/rusefi/stream/LogicdataStreamFile.java +++ b/java_console/models/src/main/java/com/rusefi/stream/LogicdataStreamFile.java @@ -186,11 +186,11 @@ public class LogicdataStreamFile extends StreamFile { write(ch); write(channelNames[ch]); write(0, 2); - write(1.0); + writeDouble(1.0); write(0); - write(0.0); + writeDouble(0.0); write(1); // or 2 - write(0.0); // or 1.0 + writeDouble(0.0); // or 1.0 // this part sounds like the 'next' pointer? if (ch == numChannels - 1) { @@ -411,7 +411,7 @@ public class LogicdataStreamFile extends StreamFile { write(BLOCK); write(0); - write(1.0); + writeDouble(1.0); write(SUB); write(0, 6); write(1); @@ -485,7 +485,7 @@ public class LogicdataStreamFile extends StreamFile { } } - private void write(double value) throws IOException { + private void writeDouble(double value) throws IOException { if (value == 0.0) { writeByte(0); } else { From 2fee9e696dce9cf31fa53f9fb90038f72bd4a641 Mon Sep 17 00:00:00 2001 From: GitHub set-date Action Date: Mon, 20 Jul 2020 00:31:59 +0000 Subject: [PATCH 11/18] Update date --- firmware/controllers/date_stamp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/controllers/date_stamp.h b/firmware/controllers/date_stamp.h index cbe2827ecf..77b68fcb19 100644 --- a/firmware/controllers/date_stamp.h +++ b/firmware/controllers/date_stamp.h @@ -1,2 +1,2 @@ #pragma once -#define VCS_DATE 20200719 +#define VCS_DATE 20200720 From ef3de11be02d9d0a86fabca9762df986c6f7ef16 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 20:47:58 -0400 Subject: [PATCH 12/18] first bugfixes --- unit_tests/logicdata.cpp | 54 ++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/unit_tests/logicdata.cpp b/unit_tests/logicdata.cpp index eb60229b77..e278c2575b 100644 --- a/unit_tests/logicdata.cpp +++ b/unit_tests/logicdata.cpp @@ -58,19 +58,11 @@ static void writeAs(int64_t value, int numBytes) { } else { writeByte(numBytes); for (int i = 0; i < numBytes; i++) { - writeByte((uint8_t)((value >> (i * 8)) & 0xff)); + writeByte((uint8_t) ((value >> (i * 8)) & 0xff)); } } } -static void writeString(const char *value) { - int len = strlen(value); - writeByte(len); - for (int i = 0; i < len; i++) { - writeByte(value[i]); - } -} - // This is the main secret of this format! :) static void write(int64_t value) { if (value < 0 || value > 0xFFFFFFFFL) { @@ -88,6 +80,14 @@ static void write(int64_t value) { } } +static void writeString(const char *value) { + int len = strlen(value); + write(len); + for (int i = 0; i < len; i++) { + writeByte(value[i]); + } +} + // todo: some C++ magic would allow us to drop 'count' parameter // todo: Look at efi::size in util static void write(int values[], int count) { @@ -138,16 +138,31 @@ static void writeHeader() { } +static void writeDouble(double value) { + static_assert(sizeof(double) == 8); + + if (value == 0.0) { + writeByte(0); + } else { + writeByte(8); + char *ptr = (char*) (void*) &value; + + for (int i = 0; i < 8; i++) { + writeByte(ptr[i]); + } + } +} + static void writeChannelHeader(int ch) { write(0xff); write(ch); writeString(channelNames[ch]); write(0, 2); - write(1.0); + writeDouble(1.0); write(0); - write(0.0); + writeDouble(0.0); write(1); // or 2 - write(0.0); // or 1.0 + writeDouble(0.0); // or 1.0 // this part sounds like the 'next' pointer? if (ch == numChannels - 1) { @@ -167,11 +182,11 @@ static void writeEdges(int64_t *chDeltas, bool useLongDeltas, int numEdges) { // set 16-bit 'sign' flag if (!useLongDeltas && (d & SIGN_FLAG) == SIGN_FLAG) d = (d & 0x7fff) | (SIGN_FLAG >> 16); - writeByte((uint8_t)(d & 0xff)); - writeByte((uint8_t)((d >> 8) & 0xff)); + writeByte((uint8_t) (d & 0xff)); + writeByte((uint8_t) ((d >> 8) & 0xff)); if (useLongDeltas) { - writeByte((uint8_t)((d >> 16) & 0xff)); - writeByte((uint8_t)((d >> 24) & 0xff)); + writeByte((uint8_t) ((d >> 16) & 0xff)); + writeByte((uint8_t) ((d >> 24) & 0xff)); } } writeByte(0x00); @@ -197,6 +212,7 @@ static void writeChannelData(int ch, int64_t *chDeltas, int chLastState, write(ch + 1); write(0); write(realDurationInSamples); + printf("realDurationInSamples=%d\n", realDurationInSamples); write(1); write(lastRecord); @@ -417,9 +433,9 @@ static void writeEvents(CompositeEvent *events, int count) { prevTs = ts; chPrevState = chState; } - writeChannelData(ch, chDeltas, chPrevState, prevTs, useLongDeltas, - deltaCount); } + writeChannelData(ch, chDeltas, chPrevState, prevTs, useLongDeltas, + deltaCount); } free(chDeltas); @@ -458,7 +474,7 @@ static void writeFooter() { write(BLOCK); write(0); - write(1.0); + writeDouble(1.0); write(SUB); write(0, 6); write(1); From ac7166fce1bb90b8c031d26acb84116769db6d56 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 21:27:28 -0400 Subject: [PATCH 13/18] OMG it works! --- unit_tests/Makefile | 1 + unit_tests/logicdata.cpp | 3 +-- unit_tests/logicdata_sandbox.cpp | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/unit_tests/Makefile b/unit_tests/Makefile index 7d7e5f88f6..3c68262b20 100644 --- a/unit_tests/Makefile +++ b/unit_tests/Makefile @@ -142,6 +142,7 @@ CPPSRC = $(UTILSRC_CPP) \ $(HW_SENSORS_SRC) \ $(TRIGGER_SRC_CPP) \ $(INIT_SRC_CPP) \ + $(PROJECT_DIR)/../unit_tests/logicdata.cpp \ $(PROJECT_DIR)/../unit_tests/main.cpp \ $(PROJECT_DIR)/console/binary_log/log_field.cpp \ diff --git a/unit_tests/logicdata.cpp b/unit_tests/logicdata.cpp index e278c2575b..c76299a119 100644 --- a/unit_tests/logicdata.cpp +++ b/unit_tests/logicdata.cpp @@ -212,7 +212,6 @@ static void writeChannelData(int ch, int64_t *chDeltas, int chLastState, write(ch + 1); write(0); write(realDurationInSamples); - printf("realDurationInSamples=%d\n", realDurationInSamples); write(1); write(lastRecord); @@ -403,12 +402,12 @@ static void writeEvents(CompositeEvent *events, int count) { writeChannelDataHeader(); int64_t *chDeltas = (int64_t*) malloc(sizeof(int64_t) * count); - int deltaCount = 0; bool useLongDeltas = false; for (int ch = 0; ch < numChannels; ch++) { int chPrevState = -1; int prevTs = 0; + int deltaCount = 0; for (int i = 0; i < count; i++) { CompositeEvent *event = &events[i]; diff --git a/unit_tests/logicdata_sandbox.cpp b/unit_tests/logicdata_sandbox.cpp index 091e924f25..e56c98b713 100644 --- a/unit_tests/logicdata_sandbox.cpp +++ b/unit_tests/logicdata_sandbox.cpp @@ -9,9 +9,14 @@ void setEvent(CompositeEvent *events, int index, int timestamp, bool primaryTrigger, bool secondaryTrigger, bool trg, bool sync, bool coil, bool injector) { events[index].timestamp = timestamp; events[index].primaryTrigger = primaryTrigger; + events[index].secondaryTrigger = secondaryTrigger; + events[index].trg = trg; + events[index].sync = sync; + events[index].coil = coil; + events[index].injector = injector; } -int main(int argc, char **argv) { +void runLogicdataSandbox() { printf(".logicdata Sandbox 20200719\n"); @@ -26,3 +31,7 @@ int main(int argc, char **argv) { printf("Done!\n"); } + +int main(int argc, char **argv) { + runLogicdataSandbox(); +} From f940f1458fc2c35b8c1fd51a36d4fdb81536b06b Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 21:30:49 -0400 Subject: [PATCH 14/18] filename parameter --- unit_tests/logicdata.cpp | 4 ++-- unit_tests/logicdata.h | 2 +- unit_tests/logicdata_sandbox.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unit_tests/logicdata.cpp b/unit_tests/logicdata.cpp index c76299a119..cd7b5f629e 100644 --- a/unit_tests/logicdata.cpp +++ b/unit_tests/logicdata.cpp @@ -486,9 +486,9 @@ static void writeFooter() { writeTimingMarker(); } -void writeFile(CompositeEvent *events, int count) { +void writeFile(const char * fileName, CompositeEvent *events, int count) { - ptr = fopen("test.logicdata", "wb"); + ptr = fopen(fileName, "wb"); writeHeader(); writeEvents(events, count); diff --git a/unit_tests/logicdata.h b/unit_tests/logicdata.h index cff6f83b79..249877487d 100644 --- a/unit_tests/logicdata.h +++ b/unit_tests/logicdata.h @@ -17,4 +17,4 @@ struct CompositeEvent { bool injector; }; -void writeFile(CompositeEvent *events, int count); +void writeFile(const char * fileName, CompositeEvent *events, int count); diff --git a/unit_tests/logicdata_sandbox.cpp b/unit_tests/logicdata_sandbox.cpp index e56c98b713..02e303b564 100644 --- a/unit_tests/logicdata_sandbox.cpp +++ b/unit_tests/logicdata_sandbox.cpp @@ -27,7 +27,7 @@ void runLogicdataSandbox() { setEvent(events, index++, 1000030, false, false, false, false, true, false); setEvent(events, index++, 2000030, false, false, true, false, false, true); - writeFile(events, index); + writeFile("test.logicdata", events, index); printf("Done!\n"); } From 403603b1263d23bd743971e2f0ad11251fb673ac Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 22:03:30 -0400 Subject: [PATCH 15/18] logicdata into unit tests --- .../engine_cycle/main_trigger_callback.cpp | 17 +++++++++++------ .../controllers/engine_cycle/spark_logic.cpp | 13 +++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index b929ac66c6..ea43db5c0d 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -117,6 +117,10 @@ void turnInjectionPinHigh(InjectionEvent *event) { efitick_t nowNt = getTimeNowNt(); #if EFI_TOOTH_LOGGER +#if EFI_UNIT_TEST + Engine *engine = event->engine; + EXPAND_Engine; +#endif // EFI_UNIT_TEST LogTriggerInjectorState(nowNt, true PASS_ENGINE_PARAMETER_SUFFIX); #endif // EFI_TOOTH_LOGGER @@ -131,7 +135,7 @@ void turnInjectionPinHigh(InjectionEvent *event) { void InjectorOutputPin::close() { #if FUEL_MATH_EXTREME_LOGGING - printf("turnInjectionPinLow %s %d %d\r\n", name, overlappingCounter, (int)getTimeNowUs()); + printf("InjectorOutputPin::close %s %d %d\r\n", name, overlappingCounter, (int)getTimeNowUs()); #endif /* FUEL_MATH_EXTREME_LOGGING */ overlappingCounter--; @@ -147,7 +151,12 @@ void InjectorOutputPin::close() { void turnInjectionPinLow(InjectionEvent *event) { efitick_t nowNt = getTimeNowNt(); -#if EFI_TOOTH_LOGGER +#if EFI_UNIT_TEST + Engine *engine = event->engine; + EXPAND_Engine; +#endif + + #if EFI_TOOTH_LOGGER LogTriggerInjectorState(nowNt, false PASS_ENGINE_PARAMETER_SUFFIX); #endif // EFI_TOOTH_LOGGER @@ -158,10 +167,6 @@ void turnInjectionPinLow(InjectionEvent *event) { output->close(); } } -#if EFI_UNIT_TEST - Engine *engine = event->engine; - EXPAND_Engine; -#endif ENGINE(injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX)); } diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index c05863bae9..0f852e4b99 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -127,6 +127,11 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) { efitick_t nowNt = getTimeNowNt(); +#if EFI_UNIT_TEST + Engine *engine = event->engine; + EXPAND_Engine; +#endif // EFI_UNIT_TEST + #if EFI_TOOTH_LOGGER LogTriggerCoilState(nowNt, false PASS_ENGINE_PARAMETER_SUFFIX); #endif // EFI_TOOTH_LOGGER @@ -165,10 +170,6 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) { #endif } -#endif /* EFI_UNIT_TEST */ -#if EFI_UNIT_TEST - Engine *engine = event->engine; - EXPAND_Engine; #endif /* EFI_UNIT_TEST */ // now that we've just fired a coil let's prepare the new schedule for the next engine revolution @@ -246,6 +247,10 @@ void turnSparkPinHigh(IgnitionEvent *event) { efitick_t nowNt = getTimeNowNt(); #if EFI_TOOTH_LOGGER +#if EFI_UNIT_TEST + Engine *engine = event->engine; + EXPAND_Engine; +#endif // EFI_UNIT_TEST LogTriggerCoilState(nowNt, true PASS_ENGINE_PARAMETER_SUFFIX); #endif // EFI_TOOTH_LOGGER From ea0ed5b133c08f821c45eff5360b635f35ada2ef Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 22:22:28 -0400 Subject: [PATCH 16/18] the miracle of makefile --- firmware/console/console.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/console/console.mk b/firmware/console/console.mk index 0b4b178006..1f88b68f2e 100644 --- a/firmware/console/console.mk +++ b/firmware/console/console.mk @@ -5,7 +5,7 @@ CONSOLE_SRC_CPP = $(PROJECT_DIR)/console/status_loop.cpp \ $(PROJECT_DIR)/console/console_io.cpp \ $(PROJECT_DIR)/console/eficonsole.cpp \ $(PROJECT_DIR)/console/connector_uart_dma.cpp \ - $(PROJECT_DIR)/console/binary_log/tooth_logger.cpp \ + $(PROJECT_DIR)/console/binary/tooth_logger.cpp \ $(PROJECT_DIR)/console/binary_log/log_field.cpp \ $(PROJECT_DIR)/console/binary_log/binary_logging.cpp \ From 5b75acdaf52fe5389800c01943c4cbe90dc3b02d Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Jul 2020 22:41:34 -0400 Subject: [PATCH 17/18] logicdata into unit tests --- firmware/console/binary/tooth_logger.cpp | 4 ++++ unit_tests/Makefile | 1 + unit_tests/efifeatures.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp index df531c9978..9226e23df1 100644 --- a/firmware/console/binary/tooth_logger.cpp +++ b/firmware/console/binary/tooth_logger.cpp @@ -156,11 +156,13 @@ void EnableToothLogger() { // Enable logging of edges as they come ToothLoggerEnabled = true; +#if EFI_TUNER_STUDIO // Tell TS that we're ready for it to read out the log // nb: this is a lie, as we may not have written anything // yet. However, we can let it continuously read out the buffer // as we update it, which looks pretty nice. tsOutputChannels.toothLogReady = true; +#endif // EFI_TUNER_STUDIO } void EnableToothLoggerIfNotEnabled() { @@ -171,7 +173,9 @@ void EnableToothLoggerIfNotEnabled() { void DisableToothLogger() { ToothLoggerEnabled = false; +#if EFI_TUNER_STUDIO tsOutputChannels.toothLogReady = false; +#endif // EFI_TUNER_STUDIO } ToothLoggerBuffer GetToothLoggerBuffer() { diff --git a/unit_tests/Makefile b/unit_tests/Makefile index 3c68262b20..c1f3596319 100644 --- a/unit_tests/Makefile +++ b/unit_tests/Makefile @@ -144,6 +144,7 @@ CPPSRC = $(UTILSRC_CPP) \ $(INIT_SRC_CPP) \ $(PROJECT_DIR)/../unit_tests/logicdata.cpp \ $(PROJECT_DIR)/../unit_tests/main.cpp \ + $(PROJECT_DIR)/console/binary/tooth_logger.cpp \ $(PROJECT_DIR)/console/binary_log/log_field.cpp \ diff --git a/unit_tests/efifeatures.h b/unit_tests/efifeatures.h index 5af53c1aec..29679ab606 100644 --- a/unit_tests/efifeatures.h +++ b/unit_tests/efifeatures.h @@ -17,6 +17,8 @@ #define ENABLE_PERF_TRACE FALSE +#define EFI_TOOTH_LOGGER TRUE + #define EFI_LAUNCH_CONTROL TRUE #define EFI_BOOST_CONTROL TRUE From e2c8e97aa0d8eda29f5d310cae8529a4aa251b20 Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 20 Jul 2020 00:36:10 -0400 Subject: [PATCH 18/18] logicdata into unit tests --- firmware/console/binary/tooth_logger.cpp | 19 +++++++++++++ firmware/console/binary/tooth_logger.h | 5 ++++ unit_tests/engine_test_helper.cpp | 27 +++++++++++++++++-- unit_tests/engine_test_helper.h | 2 ++ unit_tests/logicdata_sandbox.cpp | 4 +++ .../injection_mode_transition.cpp | 3 +++ 6 files changed, 58 insertions(+), 2 deletions(-) diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp index 9226e23df1..c13942d80f 100644 --- a/firmware/console/binary/tooth_logger.cpp +++ b/firmware/console/binary/tooth_logger.cpp @@ -55,6 +55,25 @@ int getCompositeRecordCount() { return NextIdx; } + +#if EFI_UNIT_TEST +#include "logicdata.h" +int copyCompositeEvents(CompositeEvent *events) { + for (int i = 0;i < NextIdx;i++) { + CompositeEvent *event = &events[i]; + event->timestamp = buffer[i].timestamp; + event->primaryTrigger = buffer[i].priLevel; + event->secondaryTrigger = buffer[i].secLevel; + event->trg = buffer[i].trigger; + event->sync = buffer[i].sync; + event->coil = buffer[i].coil; + event->injector = buffer[i].injector; + } + return NextIdx; +} + +#endif // EFI_UNIT_TEST + static void SetNextCompositeEntry(efitick_t timestamp, bool trigger1, bool trigger2, bool isTDC DECLARE_ENGINE_PARAMETER_SUFFIX) { uint32_t nowUs = NT2US(timestamp); diff --git a/firmware/console/binary/tooth_logger.h b/firmware/console/binary/tooth_logger.h index be0c07f1a6..5c91d0c53d 100644 --- a/firmware/console/binary/tooth_logger.h +++ b/firmware/console/binary/tooth_logger.h @@ -13,6 +13,11 @@ #include "rusefi_enums.h" #include "engine.h" +#if EFI_UNIT_TEST +#include "logicdata.h" +int copyCompositeEvents(CompositeEvent *events); +#endif // EFI_UNIT_TEST + int getCompositeRecordCount(); void EnableToothLoggerIfNotEnabled(); diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index bfcf90a5ee..9d03274804 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -15,6 +15,8 @@ #include "engine_controller.h" #include "advance_map.h" #include "sensor.h" +#include "tooth_logger.h" +#include "logicdata.h" extern int timeNowUs; extern WarningCodeState unitTestWarningCodeState; @@ -25,6 +27,7 @@ extern bool printFuelDebug; EngineTestHelperBase::EngineTestHelperBase() { // todo: make this not a global variable, we need currentTimeProvider interface on engine timeNowUs = 0; + EnableToothLogger(); } EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callback_t boardCallback) @@ -86,6 +89,18 @@ EngineTestHelper::~EngineTestHelper() { Sensor::resetRegistry(); } +static CompositeEvent compositeEvents[COMPOSITE_PACKET_COUNT]; + +void EngineTestHelper::writeEvents(const char *fileName) { + int count = copyCompositeEvents(compositeEvents); + if (count < 2) { + printf("Not enough data for %s\n", fileName); + return; + } + printf("Writing %d records to %s\n", count, fileName); + writeFile(fileName, compositeEvents, count); +} + /** * mock a change of time and fire single RISE front event */ @@ -98,7 +113,11 @@ void EngineTestHelper::fireRise(float delayMs) { * fire single RISE front event */ void EngineTestHelper::firePrimaryTriggerRise() { - engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, getTimeNowNt(), &engine, engine.engineConfigurationPtr, &persistentConfig); + efitick_t nowNt = getTimeNowNt(); + Engine *engine = &this->engine; + EXPAND_Engine; + LogTriggerTooth(SHAFT_PRIMARY_RISING, nowNt PASS_ENGINE_PARAMETER_SUFFIX); + engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, nowNt, engine, engine->engineConfigurationPtr, &persistentConfig); } void EngineTestHelper::fireFall(float delayMs) { @@ -107,7 +126,11 @@ void EngineTestHelper::fireFall(float delayMs) { } void EngineTestHelper::firePrimaryTriggerFall() { - engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, getTimeNowNt(), &engine, engine.engineConfigurationPtr, &persistentConfig); + efitick_t nowNt = getTimeNowNt(); + Engine *engine = &this->engine; + EXPAND_Engine; + LogTriggerTooth(SHAFT_PRIMARY_FALLING, nowNt PASS_ENGINE_PARAMETER_SUFFIX); + engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, nowNt, engine, engine->engineConfigurationPtr, &persistentConfig); } void EngineTestHelper::fireTriggerEventsWithDuration(float durationMs) { diff --git a/unit_tests/engine_test_helper.h b/unit_tests/engine_test_helper.h index d2a27291a1..494c533907 100644 --- a/unit_tests/engine_test_helper.h +++ b/unit_tests/engine_test_helper.h @@ -68,6 +68,8 @@ public: void moveTimeForwardUs(int deltaTimeUs); efitimeus_t getTimeNowUs(void); + void writeEvents(const char *fileName); + Engine engine; persistent_config_s persistentConfig; }; diff --git a/unit_tests/logicdata_sandbox.cpp b/unit_tests/logicdata_sandbox.cpp index 02e303b564..57a871d577 100644 --- a/unit_tests/logicdata_sandbox.cpp +++ b/unit_tests/logicdata_sandbox.cpp @@ -1,3 +1,7 @@ +/** + * @file logicdata_sandbox.cpp + * + */ #include #include "logicdata.h" diff --git a/unit_tests/tests/ignition_injection/injection_mode_transition.cpp b/unit_tests/tests/ignition_injection/injection_mode_transition.cpp index 221c8f7f67..31894e7583 100644 --- a/unit_tests/tests/ignition_injection/injection_mode_transition.cpp +++ b/unit_tests/tests/ignition_injection/injection_mode_transition.cpp @@ -35,6 +35,9 @@ TEST(fuelControl, transitionIssue1592) { ASSERT_EQ(IM_SIMULTANEOUS, ENGINE(getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE))); + + eth.writeEvents("transitionIssue1592.logicdata"); + }