Merge remote-tracking branch 'origin/master' into master
This commit is contained in:
commit
1133b44fe4
|
@ -211,6 +211,10 @@ static void sendErrorCode(ts_channel_s *tsChannel, uint8_t code) {
|
|||
sr5WriteCrcPacket(tsChannel, code, nullptr, 0);
|
||||
}
|
||||
|
||||
void TunerStudio::sendErrorCode(ts_channel_s* tsChannel, uint8_t code) {
|
||||
::sendErrorCode(tsChannel, code);
|
||||
}
|
||||
|
||||
static void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode) {
|
||||
tsState.pageCommandCounter++;
|
||||
|
||||
|
@ -460,7 +464,7 @@ static bool isKnownCommand(char command) {
|
|||
|| command == TS_GET_CONFIG_ERROR;
|
||||
}
|
||||
|
||||
TunerStudioBase tsInstance;
|
||||
TunerStudio tsInstance(&tsLogger);
|
||||
|
||||
static void tsProcessOne(ts_channel_s* tsChannel) {
|
||||
validateStack("communication", STACK_USAGE_COMMUNICATION, 128);
|
||||
|
@ -616,24 +620,6 @@ void handleQueryCommand(ts_channel_s *tsChannel, ts_response_format_e mode) {
|
|||
sr5SendResponse(tsChannel, mode, (const uint8_t *)signature, strlen(signature) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 'Output' command sends out a snapshot of current values
|
||||
* Gauges refresh
|
||||
*/
|
||||
static void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count) {
|
||||
if (offset + count > sizeof(TunerStudioOutputChannels)) {
|
||||
scheduleMsg(&tsLogger, "TS: Version Mismatch? Too much outputs requested %d/%d/%d", offset, count,
|
||||
sizeof(TunerStudioOutputChannels));
|
||||
sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
tsState.outputChannelsCommandCounter++;
|
||||
prepareTunerStudioOutputs();
|
||||
// this method is invoked too often to print any debug information
|
||||
sr5SendResponse(tsChannel, mode, ((const uint8_t *) &tsOutputChannels) + offset, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* rusEfi own test command
|
||||
*/
|
||||
|
@ -659,10 +645,10 @@ static void handleTestCommand(ts_channel_s *tsChannel) {
|
|||
|
||||
extern CommandHandler console_line_callback;
|
||||
|
||||
static void handleGetVersion(ts_channel_s *tsChannel, ts_response_format_e mode) {
|
||||
static void handleGetVersion(ts_channel_s *tsChannel) {
|
||||
static char versionBuffer[32];
|
||||
chsnprintf(versionBuffer, sizeof(versionBuffer), "rusEFI v%d@%s", getRusEfiVersion(), VCS_VERSION);
|
||||
sr5SendResponse(tsChannel, mode, (const uint8_t *) versionBuffer, strlen(versionBuffer) + 1);
|
||||
sr5SendResponse(tsChannel, TS_CRC, (const uint8_t *) versionBuffer, strlen(versionBuffer) + 1);
|
||||
}
|
||||
|
||||
static void handleGetText(ts_channel_s *tsChannel) {
|
||||
|
@ -743,14 +729,14 @@ int TunerStudioBase::handleCrcCommand(ts_channel_s *tsChannel, char *data, int i
|
|||
switch(command)
|
||||
{
|
||||
case TS_OUTPUT_COMMAND:
|
||||
handleOutputChannelsCommand(tsChannel, TS_CRC, offset, count);
|
||||
cmdOutputChannels(tsChannel, offset, count);
|
||||
break;
|
||||
case TS_HELLO_COMMAND:
|
||||
tunerStudioDebug("got Query command");
|
||||
handleQueryCommand(tsChannel, TS_CRC);
|
||||
break;
|
||||
case TS_GET_FIRMWARE_VERSION:
|
||||
handleGetVersion(tsChannel, TS_CRC);
|
||||
handleGetVersion(tsChannel);
|
||||
break;
|
||||
#if EFI_FILE_LOGGING || EFI_SIMULATOR
|
||||
case TS_SD_R_COMMAND:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
TUNERSTUDIO_SRC_CPP = $(PROJECT_DIR)/console/binary/tunerstudio_io.cpp \
|
||||
$(PROJECT_DIR)/console/binary/tunerstudio.cpp \
|
||||
$(PROJECT_DIR)/console/binary/tunerstudio_commands.cpp \
|
||||
$(PROJECT_DIR)/console/binary/bluetooth.cpp \
|
||||
$(PROJECT_DIR)/console/binary/signature.cpp
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#include "global.h"
|
||||
|
||||
#include "tunerstudio_impl.h"
|
||||
#include "tunerstudio.h"
|
||||
#include "tunerstudio_io.h"
|
||||
|
||||
#include "status_loop.h"
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
|
||||
/**
|
||||
* @brief 'Output' command sends out a snapshot of current values
|
||||
* Gauges refresh
|
||||
*/
|
||||
void TunerStudio::cmdOutputChannels(ts_channel_s *tsChannel, uint16_t offset, uint16_t count) {
|
||||
if (offset + count > sizeof(TunerStudioOutputChannels)) {
|
||||
scheduleMsg(tsLogger, "TS: Version Mismatch? Too much outputs requested %d/%d/%d", offset, count,
|
||||
sizeof(TunerStudioOutputChannels));
|
||||
sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
tsState.outputChannelsCommandCounter++;
|
||||
prepareTunerStudioOutputs();
|
||||
// this method is invoked too often to print any debug information
|
||||
sr5SendResponse(tsChannel, TS_CRC, ((const uint8_t *) &tsOutputChannels) + offset, count);
|
||||
}
|
||||
|
||||
#endif // EFI_TUNER_STUDIO
|
|
@ -1,8 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class ts_channel_s;
|
||||
|
||||
class TunerStudioBase {
|
||||
public:
|
||||
int handleCrcCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize);
|
||||
|
||||
protected:
|
||||
virtual void cmdOutputChannels(ts_channel_s *tsChannel, uint16_t offset, uint16_t count) = 0;
|
||||
};
|
||||
|
||||
class TunerStudio : public TunerStudioBase {
|
||||
public:
|
||||
TunerStudio(Logging* logger)
|
||||
: tsLogger(logger)
|
||||
{
|
||||
}
|
||||
|
||||
void cmdOutputChannels(ts_channel_s *tsChannel, uint16_t offset, uint16_t count) override;
|
||||
|
||||
private:
|
||||
void sendErrorCode(ts_channel_s* tsChannel, uint8_t code);
|
||||
|
||||
Logging* tsLogger;
|
||||
};
|
||||
|
|
|
@ -598,7 +598,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
// Low pressure is directly in kpa
|
||||
tsOutputChannels->lowFuelPressure = Sensor::get(SensorType::FuelPressureLow).Value;
|
||||
// High pressure is in bar, aka 100 kpa
|
||||
tsOutputChannels->highFuelPressure = Sensor::get(SensorType::FuelPressureHigh).Value * 0.01f;
|
||||
tsOutputChannels->highFuelPressure = KPA2BAR(Sensor::get(SensorType::FuelPressureHigh).Value);
|
||||
|
||||
// 288
|
||||
tsOutputChannels->injectionOffset = engine->engineState.injectionOffset;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "high_pressure_fuel_pump.h"
|
||||
#include "spark_logic.h"
|
||||
#include "map.h"
|
||||
|
||||
#if EFI_HPFP
|
||||
|
||||
|
@ -58,7 +59,11 @@ static void scheduleNextCycle(HpfpActor *actor) {
|
|||
|
||||
void hpfpPlainPinTurnOn(HpfpActor *current) {
|
||||
RegisteredNamedOutputPin *output = &enginePins.hpfpValve;
|
||||
output->setHigh();
|
||||
int highPressureKpa = Sensor::get(SensorType::FuelPressureHigh).Value;
|
||||
// very basic control strategy
|
||||
if (highPressureKpa < BAR2KPA(50)) {
|
||||
output->setHigh();
|
||||
}
|
||||
scheduleNextCycle(current);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,11 @@ float validateMap(float mapKPa DECLARE_ENGINE_PARAMETER_SUFFIX);
|
|||
#define PSI2KPA(psi) (KPA_PER_PSI * (psi))
|
||||
|
||||
#define BAR2KPA(bar) (100 * (bar))
|
||||
#define KPA2BAR(kpa) (0.01f * (kpa))
|
||||
|
||||
// PSI (relative to atmosphere) to kPa (relative to vacuum)
|
||||
#define PSI2KPA_RELATIVE(psi) (101.32500411216164f + PSI2KPA(psi))
|
||||
|
||||
#define INHG2KPA(inhg) ((inhg) * 3.386375)
|
||||
#define KPA2INHG(kpa) ((kpa) / 3.386375)
|
||||
#define INHG2KPA(inhg) ((inhg) * 3.386375f)
|
||||
#define KPA2INHG(kpa) ((kpa) / 3.386375f)
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ enum class SensorType : unsigned char {
|
|||
|
||||
OilPressure,
|
||||
|
||||
FuelPressureLow,
|
||||
FuelPressureHigh,
|
||||
FuelPressureLow, // in kPa
|
||||
FuelPressureHigh, // in kPa
|
||||
FuelPressureInjector,
|
||||
|
||||
// This is the "resolved" position, potentially composited out of the following two
|
||||
|
|
Loading…
Reference in New Issue