auto-sync

This commit is contained in:
rusEfi 2016-03-14 23:01:43 -04:00
parent 395abf9f15
commit bd3f42802d
4 changed files with 26 additions and 21 deletions

View File

@ -75,6 +75,7 @@
#include <string.h> #include <string.h>
#include "engine_configuration.h" #include "engine_configuration.h"
#include "injector_central.h"
#include "svnversion.h" #include "svnversion.h"
#include "loggingcentral.h" #include "loggingcentral.h"
#include "status_loop.h" #include "status_loop.h"
@ -695,9 +696,6 @@ bool handlePlainCommand(ts_channel_s *tsChannel, uint8_t command) {
} }
} }
static void testIoCommand(void) {
}
int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize) { int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize) {
char command = data[0]; char command = data[0];
@ -754,11 +752,11 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin
* Currently on some firmware versions the F command is not used and is just ignored by the firmware as a unknown command." * Currently on some firmware versions the F command is not used and is just ignored by the firmware as a unknown command."
*/ */
} else if (command == TS_IO_TEST_COMMAND) { } else if (command == TS_IO_TEST_COMMAND) {
int subsystem = data[3]; uint16_t subsystem = SWAP_UINT16(*(short*)&data[0]);
int index = *(short*)&data[0]; uint16_t index = SWAP_UINT16(*(short*)&data[2]);
runIoTest(subsystem, index);
scheduleMsg(&tsLogger, "IO test %d %d %d", incomingPacketSize, subsystem, index);
testIoCommand();
} else { } else {
tunerStudioError("ERROR: ignoring unexpected command"); tunerStudioError("ERROR: ignoring unexpected command");
return false; return false;

View File

@ -591,7 +591,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) {
chThdCreateStatic(csThreadStack, sizeof(csThreadStack), LOWPRIO, (tfunc_t) csThread, NULL); chThdCreateStatic(csThreadStack, sizeof(csThreadStack), LOWPRIO, (tfunc_t) csThread, NULL);
#if (EFI_PROD_CODE && EFI_ENGINE_CONTROL) || defined(__DOXYGEN__) #if (EFI_PROD_CODE && EFI_ENGINE_CONTROL) || defined(__DOXYGEN__)
initInjectorCentral(); initInjectorCentral(sharedLogger);
/** /**
* This has to go after 'initInjectorCentral' and 'initInjectorCentral' in order to * This has to go after 'initInjectorCentral' and 'initInjectorCentral' in order to
* properly detect un-assigned output pins * properly detect un-assigned output pins

View File

@ -33,10 +33,10 @@
#include "pin_repository.h" #include "pin_repository.h"
#include "efiGpio.h" #include "efiGpio.h"
static LoggingWithStorage logger("InjectorCentral");
EXTERN_ENGINE EXTERN_ENGINE
; ;
static Logging * logger;
static bool isRunningBench = false; static bool isRunningBench = false;
static int is_injector_enabled[MAX_INJECTOR_COUNT]; static int is_injector_enabled[MAX_INJECTOR_COUNT];
@ -67,7 +67,7 @@ int isInjectorEnabled(int cylinderId) {
static void printStatus(void) { static void printStatus(void) {
for (int id = 1; id <= engineConfiguration->specs.cylindersCount; id++) { for (int id = 1; id <= engineConfiguration->specs.cylindersCount; id++) {
scheduleMsg(&logger, "injector_%d_%d", isInjectorEnabled(id)); scheduleMsg(logger, "injector_%d_%d", isInjectorEnabled(id));
} }
} }
@ -83,19 +83,19 @@ static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, flo
int onTimeSt = MS2ST(onTimeMs); int onTimeSt = MS2ST(onTimeMs);
int offTimeSt = MS2ST(offTimeMs); int offTimeSt = MS2ST(offTimeMs);
if (delaySt < 0) { if (delaySt < 0) {
scheduleMsg(&logger, "Invalid delay %f", delayMs); scheduleMsg(logger, "Invalid delay %f", delayMs);
return; return;
} }
if (onTimeSt <= 0) { if (onTimeSt <= 0) {
scheduleMsg(&logger, "Invalid onTime %f", onTimeMs); scheduleMsg(logger, "Invalid onTime %f", onTimeMs);
return; return;
} }
if (offTimeSt <= 0) { if (offTimeSt <= 0) {
scheduleMsg(&logger, "Invalid offTime %f", offTimeMs); scheduleMsg(logger, "Invalid offTime %f", offTimeMs);
return; return;
} }
scheduleMsg(&logger, "Running bench: ON_TIME=%f ms OFF_TIME=%fms Counter=%d", onTimeMs, offTimeMs, count); scheduleMsg(logger, "Running bench: ON_TIME=%f ms OFF_TIME=%fms Counter=%d", onTimeMs, offTimeMs, count);
scheduleMsg(&logger, "output on %s", hwPortname(brainPin)); scheduleMsg(logger, "output on %s", hwPortname(brainPin));
if (delaySt != 0) { if (delaySt != 0) {
chThdSleep(delaySt); chThdSleep(delaySt);
@ -108,7 +108,7 @@ static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, flo
output->setValue(false); output->setValue(false);
chThdSleep(offTimeSt); chThdSleep(offTimeSt);
} }
scheduleMsg(&logger, "Done!"); scheduleMsg(logger, "Done!");
isRunningBench = false; isRunningBench = false;
} }
@ -140,7 +140,7 @@ static void fuelbench2(const char *delayStr, const char *indexStr, const char *
const char *countStr) { const char *countStr) {
int index = atoi(indexStr); int index = atoi(indexStr);
if (index < 1 || index > engineConfiguration->specs.cylindersCount) { if (index < 1 || index > engineConfiguration->specs.cylindersCount) {
scheduleMsg(&logger, "Invalid index: %d", index); scheduleMsg(logger, "Invalid index: %d", index);
return; return;
} }
brain_pin_e b = boardConfiguration->injectionPins[index - 1]; brain_pin_e b = boardConfiguration->injectionPins[index - 1];
@ -177,7 +177,7 @@ static void sparkbench2(const char *delayStr, const char *indexStr, const char *
const char *countStr) { const char *countStr) {
int index = atoi(indexStr); int index = atoi(indexStr);
if (index < 1 || index > engineConfiguration->specs.cylindersCount) { if (index < 1 || index > engineConfiguration->specs.cylindersCount) {
scheduleMsg(&logger, "Invalid index: %d", index); scheduleMsg(logger, "Invalid index: %d", index);
return; return;
} }
brain_pin_e b = boardConfiguration->ignitionPins[index - 1]; brain_pin_e b = boardConfiguration->ignitionPins[index - 1];
@ -215,7 +215,7 @@ extern engine_configuration_s activeConfiguration;
static void unregister(brain_pin_e currentPin, OutputPin *output) { static void unregister(brain_pin_e currentPin, OutputPin *output) {
if (currentPin == GPIO_UNASSIGNED) if (currentPin == GPIO_UNASSIGNED)
return; return;
scheduleMsg(&logger, "unregistering %s", hwPortname(currentPin)); scheduleMsg(logger, "unregistering %s", hwPortname(currentPin));
unmarkPin(currentPin); unmarkPin(currentPin);
output->unregister(); output->unregister();
} }
@ -262,7 +262,13 @@ void startInjectionPins(void) {
} }
} }
void initInjectorCentral(void) { void runIoTest(int subsystem, int index) {
scheduleMsg(logger, "IO test subsystem=%d index=%d", subsystem, index);
}
void initInjectorCentral(Logging *sharedLogger) {
logger = sharedLogger;
chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL); chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL);
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {

View File

@ -16,7 +16,7 @@
void fanBench(void); void fanBench(void);
void fuelPumpBench(void); void fuelPumpBench(void);
void initInjectorCentral(void); void initInjectorCentral(Logging *sharedLogger);
bool isRunningBenchTest(void); bool isRunningBenchTest(void);
int isInjectorEnabled(int cylinderId); int isInjectorEnabled(int cylinderId);
void assertCylinderId(int cylinderId, const char *msg); void assertCylinderId(int cylinderId, const char *msg);
@ -26,5 +26,6 @@ void startInjectionPins(void);
void stopIgnitionPins(void); void stopIgnitionPins(void);
void startIgnitionPins(void); void startIgnitionPins(void);
void runIoTest(int subsystem, int index);
#endif /* INJECTOR_CENTRAL_H_ */ #endif /* INJECTOR_CENTRAL_H_ */