Merge remote-tracking branch 'origin/master' into reset-overlap

This commit is contained in:
Matthew Kennedy 2020-07-20 00:07:04 -07:00
commit b96f57596d
21 changed files with 200 additions and 70 deletions

View File

@ -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-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-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-artifact@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

View File

@ -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);
@ -156,11 +175,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 +192,9 @@ void EnableToothLoggerIfNotEnabled() {
void DisableToothLogger() {
ToothLoggerEnabled = false;
#if EFI_TUNER_STUDIO
tsOutputChannels.toothLogReady = false;
#endif // EFI_TUNER_STUDIO
}
ToothLoggerBuffer GetToothLoggerBuffer() {

View File

@ -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();

View File

@ -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 \

View File

@ -1,2 +1,2 @@
#pragma once
#define VCS_DATE 20200719
#define VCS_DATE 20200720

View File

@ -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--;
@ -152,7 +156,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
@ -163,10 +172,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));
}

View File

@ -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

View File

@ -1,12 +1,12 @@
// This file was generated by Version2Header
// Sun Jul 19 01:43:06 EDT 2020
// Sun Jul 19 18:34:45 EDT 2020
#ifndef GIT_HASH
#define GIT_HASH "5e39d1ff305f1d5e2fe176e82bf2e1860723af98"
#define GIT_HASH "f96e4c88e0b38256ceec956e48c22b9f0e63b2ed"
#endif
#ifndef VCS_VERSION
#define VCS_VERSION "24365"
#define VCS_VERSION "24397"
#endif

View File

@ -47,6 +47,7 @@ public class LogicdataStreamFile extends StreamFile {
private final String fileName;
private final List<CompositeEvent> 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);
@ -185,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) {
@ -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);
@ -405,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);
@ -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) {
@ -479,18 +485,18 @@ public class LogicdataStreamFile extends StreamFile {
}
}
private void write(double value) throws IOException {
private void writeDouble(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);
}
}
}

View File

@ -142,7 +142,9 @@ 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/tooth_logger.cpp \
$(PROJECT_DIR)/console/binary_log/log_field.cpp \

View File

@ -17,6 +17,8 @@
#define ENABLE_PERF_TRACE FALSE
#define EFI_TOOTH_LOGGER TRUE
#define EFI_LAUNCH_CONTROL TRUE
#define EFI_BOOST_CONTROL TRUE

View File

@ -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) {

View File

@ -68,6 +68,8 @@ public:
void moveTimeForwardUs(int deltaTimeUs);
efitimeus_t getTimeNowUs(void);
void writeEvents(const char *fileName);
Engine engine;
persistent_config_s persistentConfig;
};

View File

@ -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);
@ -387,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];
@ -417,9 +432,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 +473,7 @@ static void writeFooter() {
write(BLOCK);
write(0);
write(1.0);
writeDouble(1.0);
write(SUB);
write(0, 6);
write(1);
@ -471,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);

View File

@ -17,4 +17,4 @@ struct CompositeEvent {
bool injector;
};
void writeFile(CompositeEvent *events, int count);
void writeFile(const char * fileName, CompositeEvent *events, int count);

View File

@ -1,3 +1,7 @@
/**
* @file logicdata_sandbox.cpp
*
*/
#include <cstdio>
#include "logicdata.h"
@ -9,9 +13,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");
@ -22,7 +31,11 @@ int main(int argc, char **argv) {
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");
}
int main(int argc, char **argv) {
runLogicdataSandbox();
}

View File

@ -35,6 +35,9 @@ TEST(fuelControl, transitionIssue1592) {
ASSERT_EQ(IM_SIMULTANEOUS, ENGINE(getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)));
eth.writeEvents("transitionIssue1592.logicdata");
}

View File

@ -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
{

View File

@ -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();
}

View File

@ -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 \

View File

@ -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