auto-sync

This commit is contained in:
rusEfi 2015-01-17 23:04:10 -06:00
parent dc7147cd8c
commit 5cab0baa60
8 changed files with 82 additions and 20 deletions

View File

@ -53,6 +53,7 @@
#include "engine.h"
#include "lcd_controller.h"
#include "settings.h"
#include "rusefi_outputs.h"
#if EFI_PROD_CODE || defined(__DOXYGEN__)
// todo: move this logic to algo folder!
@ -66,6 +67,9 @@
#endif
extern engine_pins_s enginePins;
extern TriggerCentral triggerCentral;
static bool_t subscription[(int) RO_LAST_ELEMENT];
// this 'true' value is needed for simulator
static volatile bool fullLog = true;
@ -181,7 +185,8 @@ void printSensors(Logging *log, bool fileFormat, Engine *engine) {
}
EXTERN_ENGINE;
EXTERN_ENGINE
;
void writeLogLine(void) {
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
@ -196,14 +201,17 @@ void writeLogLine(void) {
#endif /* EFI_FILE_LOGGING */
}
void printState(Engine *engine, int currentCkpEventCounter) {
static void printState(Engine *engine) {
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
printSensors(&logger, false, engine);
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
int rpm = getRpmE(engine);
debugInt(&logger, "ckp_c", currentCkpEventCounter);
if (subscription[(int) RO_TOTAL_REVOLUTION_COUNTER])
debugInt(&logger, "ckp_c", getCrankEventCounter());
if (subscription[(int) RO_RUNNING_REVOLUTION_COUNTER])
debugInt(&logger, "ckp_r", triggerCentral.triggerState.runningRevolutionCounter);
// debugInt(&logger, "idl", getIdleSwitch());
@ -326,7 +334,7 @@ void updateDevConsoleState(Engine *engine) {
prevCkpEventCounter = currentCkpEventCounter;
printState(engine, currentCkpEventCounter);
printState(engine);
#if EFI_WAVE_ANALYZER
printWave(&logger);
@ -550,6 +558,14 @@ static void tsStatusThread(Engine *engine) {
}
}
static void subscribe(int outputOrdinal) {
subscription[outputOrdinal] = true;
}
static void unsubscribe(int outputOrdinal) {
subscription[outputOrdinal] = false;
}
void initStatusLoop(Engine *engine) {
#if EFI_PROD_CODE || EFI_SIMULATOR
initLoggingExt(&logger, "status loop", LOGGING_BUFFER, sizeof(LOGGING_BUFFER));
@ -565,6 +581,16 @@ void initStatusLoop(Engine *engine) {
addConsoleActionFFP("fuelinfo2", (VoidFloatFloatVoidPtr) showFuelInfo2, engine);
addConsoleActionP("fuelinfo", (VoidPtr) showFuelInfo, engine);
subscription[(int) RO_TRG1_DUTY] = true;
subscription[(int) RO_TRG2_DUTY] = true;
subscription[(int) RO_TRG3_DUTY] = false;
subscription[(int) RO_TRG4_DUTY] = false;
subscription[(int) RO_TOTAL_REVOLUTION_COUNTER] = true;
subscription[(int) RO_RUNNING_REVOLUTION_COUNTER] = false;
addConsoleActionI("subscribe", subscribe);
addConsoleActionI("unsubscribe", unsubscribe);
addConsoleAction("status", printStatus);
#endif /* EFI_PROD_CODE */

View File

@ -8,27 +8,13 @@
#ifndef CONSOLE_LOOP_H_
#define CONSOLE_LOOP_H_
#ifdef __cplusplus
#include "engine.h"
void updateDevConsoleState(Engine *engine);
void printSensors(Engine *engine);
void printState(Engine *engine, int currentCkpEventCounter);
void startStatusThreads(Engine *engine);
void initStatusLoop(Engine *engine);
#endif /* __cplusplus */
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void writeLogLine(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
bool getFullLog(void);
void setFullLog(int value);

View File

@ -0,0 +1,40 @@
/**
* @file rusefi_outputs.h
*
* rusEfi output channels enum is needed for subscription/un-subscription
*
* @date Jan 17, 2015
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#ifndef CONTROLLERS_ALGO_RUSEFI_OUTPUTS_H_
#define CONTROLLERS_ALGO_RUSEFI_OUTPUTS_H_
/**
* this enum is part of the console protocol API, it should be in sync with ...java
*/
/**
* For example,
* subscribe 10
* unsubscribe 9
*/
typedef enum {
RO_TPS_ADC_VALUE = 0,
RO_MAF = 1,
RO_MAP = 2,
RO_TRG1_DUTY = 3,
RO_TRG2_DUTY = 4,
RO_TRG3_DUTY = 5,
RO_TRG4_DUTY = 6,
RO_INJECTOR_LAG = 7,
RO_VBATT = 8,
RO_TOTAL_REVOLUTION_COUNTER = 9,
RO_RUNNING_REVOLUTION_COUNTER = 10,
RO_LAST_ELEMENT = 11
} rusefi_output_e;
#endif /* CONTROLLERS_ALGO_RUSEFI_OUTPUTS_H_ */

View File

@ -291,6 +291,10 @@ float getTriggerDutyCycle(int index) {
return triggerCentral.triggerState.getTriggerDutyCycle(index);
}
static void resetRunningTriggerCounter() {
triggerCentral.triggerState.runningRevolutionCounter = 0;
}
void initTriggerCentral(Logging *sharedLogger, Engine *engine) {
logger = sharedLogger;
strcpy((char*) shaft_signal_msg_index, "x_");
@ -302,8 +306,11 @@ void initTriggerCentral(Logging *sharedLogger, Engine *engine) {
#if EFI_PROD_CODE || EFI_SIMULATOR
addConsoleActionP("triggerinfo", (VoidPtr) triggerInfo, engine);
addConsoleActionP("triggershapeinfo", (VoidPtr) triggerShapeInfo, engine);
addConsoleAction("reset_running_trigger_counter", resetRunningTriggerCounter);
#endif
#if EFI_HISTOGRAMS
initHistogram(&triggerCallback, "all callbacks");
#endif /* EFI_HISTOGRAMS */

View File

@ -94,6 +94,7 @@ static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW
startOfCycleNt = nowNt; \
clear(); \
totalRevolutionCounter++; \
runningRevolutionCounter++; \
totalEventCountBase += TRIGGER_SHAPE(size); \
}

View File

@ -55,6 +55,7 @@ public:
* index within trigger revolution, from 0 to trigger event count
*/
uint32_t current_index;
uint32_t runningRevolutionCounter;
private:
void clear();
/**

View File

@ -115,6 +115,7 @@ TriggerState::TriggerState() {
toothed_previous_time = 0;
toothed_previous_duration = 0;
totalRevolutionCounter = 0;
runningRevolutionCounter = 0;
totalTriggerErrorCounter = 0;
clear();
memset(expectedTotalTime, 0, sizeof(expectedTotalTime));

View File

@ -262,5 +262,5 @@ int getRusEfiVersion(void) {
return 1; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE == 0)
return 1; // this is here to make the compiler happy about the unused array
return 20150116;
return 20150117;
}