Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into custom-chrono
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed May 12, 2024
2 parents e22b76c + b322321 commit bb2f0ca
Showing 45 changed files with 1,101 additions and 1,068 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-firmware.yaml
Original file line number Diff line number Diff line change
@@ -303,6 +303,10 @@ jobs:
- name: Build Firmware
run: bash misc/jenkins/compile_other_versions/compile.sh ${{matrix.folder}} ${{matrix.build-target}}

- name: Check for illegal time conversions
working-directory: ./firmware/
run: bash check_illegal_conversion.sh

# Build rusEFI console
- name: Build console
if: ${{ env.full == 'true' }}
16 changes: 16 additions & 0 deletions firmware/check_illegal_conversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/bash

# Trying to convert float -> long suggests you're probably trying to compute a
# time period in float, then add it to a timestamp to get some time in the future.
# If you do this naively, it'll try and do
# float offset;
# int64_t stamp;
# int64_t result = (int64_t)((float)stamp + offset);
# The resulting loss of precision is unacceptable.

set -euo pipefail

if grep "bl.*<__aeabi_f2lz>" build/fome.list; then
echo "Illegal float-to-long conversion detected!"
exit 1
fi
2 changes: 1 addition & 1 deletion firmware/console/binary_log/binary_logging.cpp
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ void writeSdBlock(Writer& outBuffer) {
// todo: add a log field for SD card period
// prevSdCardLineTime = nowUs;

packedTime = getTimeNowUs() * 1e-3 / TIME_PRECISION;
packedTime = (uint32_t)(getTimeNowUs() / (1000 * TIME_PRECISION));

uint8_t sum = 0;
for (size_t fieldIndex = 0; fieldIndex < efi::size(fields); fieldIndex++) {
4 changes: 4 additions & 0 deletions firmware/controllers/actuators/gppwm/gppwm_channel.cpp
Original file line number Diff line number Diff line change
@@ -70,6 +70,10 @@ expected<float> readGppwmChannel(gppwm_channel_e channel) {
return Sensor::get(SensorType::DetectedGear);
case GPPWM_BaroPressure:
return Sensor::get(SensorType::BarometricPressure);
case GPPWM_Egt1:
return Sensor::get(SensorType::EGT1);
case GPPWM_Egt2:
return Sensor::get(SensorType::EGT2);
}

return unexpected;
2 changes: 1 addition & 1 deletion firmware/controllers/actuators/idle_thread.cpp
Original file line number Diff line number Diff line change
@@ -256,7 +256,7 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos,
}
// increase the errorAmpCoef slowly to restore the process correctly after the PID reset
// todo: move restoreAfterPidResetTimeUs to idle?
efitimeus_t timeSincePidResetUs = nowUs - restoreAfterPidResetTimeUs;
int32_t timeSincePidResetUs = nowUs - restoreAfterPidResetTimeUs;
// todo: add 'pidAfterResetDampingPeriodMs' setting
errorAmpCoef = interpolateClamped(0, 0, MS2US(/*engineConfiguration->pidAfterResetDampingPeriodMs*/1000), errorAmpCoef, timeSincePidResetUs);
// If errorAmpCoef > 1.0, then PID thinks that RPM is lower than it is, and controls IAC more aggressively
4 changes: 4 additions & 0 deletions firmware/controllers/algo/auto_generated_commonenum.cpp
Original file line number Diff line number Diff line change
@@ -343,6 +343,10 @@ case GPPWM_Clt:
return "GPPWM_Clt";
case GPPWM_DetectedGear:
return "GPPWM_DetectedGear";
case GPPWM_Egt1:
return "GPPWM_Egt1";
case GPPWM_Egt2:
return "GPPWM_Egt2";
case GPPWM_EthanolPercent:
return "GPPWM_EthanolPercent";
case GPPWM_FuelLoad:
2 changes: 1 addition & 1 deletion firmware/controllers/algo/dynoview.cpp
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ void DynoView::update(vssSrc src) {
*/
void DynoView::updateAcceleration(efitimeus_t deltaTime, float deltaSpeed) {
if (deltaSpeed != 0.0) {
acceleration = ((deltaSpeed / 3.6) / (deltaTime / US_PER_SECOND_F));
acceleration = ((deltaSpeed / 3.6) / ((uint32_t)deltaTime / US_PER_SECOND_F));
if (direction) {
//decceleration
acceleration *= -1;
2 changes: 2 additions & 0 deletions firmware/controllers/algo/rusefi_enums.h
Original file line number Diff line number Diff line change
@@ -523,6 +523,8 @@ typedef enum __attribute__ ((__packed__)) {
GPPWM_Rpm = 24,
GPPWM_DetectedGear = 25,
GPPWM_BaroPressure = 26,
GPPWM_Egt1 = 27,
GPPWM_Egt2 = 28,
} gppwm_channel_e;

typedef enum __attribute__ ((__packed__)) {
5 changes: 3 additions & 2 deletions firmware/controllers/can/can_verbose.cpp
Original file line number Diff line number Diff line change
@@ -210,8 +210,9 @@ struct Egts {
uint8_t egt[8];
};

static void populateFrame(Egts&) {
// TODO: https://github.com/FOME-Tech/fome-fw/issues/398
static void populateFrame(Egts& msg) {
msg.egt[0] = Sensor::getOrZero(SensorType::EGT1) / 5;
msg.egt[1] = Sensor::getOrZero(SensorType::EGT2) / 5;
}

void sendCanVerbose() {
2 changes: 1 addition & 1 deletion firmware/controllers/date_stamp.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#pragma once
#define VCS_DATE 20240503
#define VCS_DATE 20240512
6 changes: 3 additions & 3 deletions firmware/controllers/engine_cycle/prime_injection.cpp
Original file line number Diff line number Diff line change
@@ -57,9 +57,9 @@ void PrimeController::onIgnitionStateChanged(bool ignitionOn) {

// start prime injection if this is a 'fresh start'
if (ignSwitchCounter == 0) {
auto primeDelayMs = engineConfiguration->primingDelay * 1000;
uint32_t primeDelayNt = MSF2NT(engineConfiguration->primingDelay * 1000);

auto startTime = getTimeNowNt() + MS2NT(primeDelayMs);
auto startTime = getTimeNowNt() + primeDelayNt;
getExecutorInterface()->scheduleByTimestampNt("prime", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
} else {
efiPrintf("Skipped priming pulse since ignSwitchCounter = %d", ignSwitchCounter);
@@ -96,7 +96,7 @@ void PrimeController::onPrimeStart() {

efiPrintf("Firing priming pulse of %.2f ms", durationMs);

auto endTime = getTimeNowNt() + MS2NT(durationMs);
auto endTime = getTimeNowNt() + (uint32_t)MSF2NT(durationMs);

// Open all injectors, schedule closing later
m_isPriming = true;
2 changes: 1 addition & 1 deletion firmware/controllers/trigger/decoders/trigger_structure.h
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
#define TRIGGER_GAP_DEVIATION_HIGH (1.0f + TRIGGER_GAP_DEVIATION)

#if EFI_ENABLE_ASSERTS
#define assertAngleRange(angle, msg, code) if (angle > 10000000 || angle < -10000000) { firmwareError(code, "angle range %s %.2f", msg, angle);angle = 0;}
#define assertAngleRange(angle, msg, code) if (angle > 10000000 || angle < -10000000) { firmwareError(code, "angle range %s %d", msg, (int)angle);angle = 0;}
#else
#define assertAngleRange(angle, msg, code) {}
#endif
2 changes: 1 addition & 1 deletion firmware/integration/rusefi_config.txt
Original file line number Diff line number Diff line change
@@ -302,7 +302,7 @@ custom pin_output_mode_e 1 bits, U08, @OFFSET@, [0:1], @@pin_output_mode_e_enum@
#define pin_input_mode_e_enum "DEFAULT", "PULLUP", "PULLDOWN"
custom pin_input_mode_e 1 bits, U08, @OFFSET@, [0:1], @@pin_input_mode_e_enum@@

#define gppwm_channel_e_enum "Zero", "TPS", "MAP", "CLT", "IAT", "Fuel Load", "Ignition Load", "Aux Temp 1", "Aux Temp 2", "Accel Pedal", "Battery Voltage", "VVT 1 I", "VVT 1 E", "VVT 2 I", "VVT 2 E", "Ethanol (Flex) %", "Aux Linear 1", "Aux Linear 2", "GPPWM Output 1", "GPPWM Output 2", "GPPWM Output 3", "GPPWM Output 4", "Lua Gauge 1", "Lua Gauge 2", "RPM", "Gear (detected)", "Baro pressure"
#define gppwm_channel_e_enum "Zero", "TPS", "MAP", "CLT", "IAT", "Fuel Load", "Ignition Load", "Aux Temp 1", "Aux Temp 2", "Accel Pedal", "Battery Voltage", "VVT 1 I", "VVT 1 E", "VVT 2 I", "VVT 2 E", "Ethanol (Flex) %", "Aux Linear 1", "Aux Linear 2", "GPPWM Output 1", "GPPWM Output 2", "GPPWM Output 3", "GPPWM Output 4", "Lua Gauge 1", "Lua Gauge 2", "RPM", "Gear (detected)", "Baro pressure", "EGT 1", "EGT 2"
custom gppwm_channel_e 1 bits, U08, @OFFSET@, [0:4], @@gppwm_channel_e_enum@@

struct gppwm_channel
Loading

0 comments on commit bb2f0ca

Please sign in to comment.