auto-sync

This commit is contained in:
rusEfi 2016-03-14 23:01:43 -04:00
parent 4923f5b270
commit ee444e15ea
5 changed files with 42 additions and 37 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_ */

View File

@ -1235,22 +1235,22 @@ fileVersion = { 20160122 }
; and may create error messages. ; and may create error messages.
; It is expected that these commands would not typically alter any ram mapped to a Constant. ; It is expected that these commands would not typically alter any ram mapped to a Constant.
cmd_test_spk1 = "w\x00\x00\x00\x00" cmd_test_spk1 = "w\x00\x12\x00\x00"
cmd_test_ppk2 = "w\x00\x00\x00\x01" cmd_test_spk2 = "w\x00\x12\x00\x01"
cmd_test_ppk3 = "w\x00\x00\x00\x02" cmd_test_spk3 = "w\x00\x12\x00\x02"
cmd_test_ppk4 = "w\x00\x00\x00\x03" cmd_test_spk4 = "w\x00\x12\x00\x03"
cmd_test_ppk5 = "w\x00\x00\x00\x04" cmd_test_spk5 = "w\x00\x12\x00\x04"
cmd_test_ppk6 = "w\x00\x00\x00\x05" cmd_test_spk6 = "w\x00\x12\x00\x05"
cmd_test_ppk7 = "w\x00\x00\x00\x06" cmd_test_spk7 = "w\x00\x12\x00\x06"
cmd_test_ppk8 = "w\x00\x00\x00\x07" cmd_test_spk8 = "w\x00\x12\x00\x07"
cmd_test_ppk9 = "w\x00\x00\x00\x08" cmd_test_spk9 = "w\x00\x12\x00\x08"
cmd_test_ppk10 = "w\x00\x00\x00\x09" cmd_test_spk10 = "w\x00\x12\x00\x09"
cmd_test_ppk11 = "w\x00\x00\x00\x0a" cmd_test_spk11 = "w\x00\x12\x00\x0a"
cmd_test_ppk12 = "w\x00\x00\x00\x0b" cmd_test_spk12 = "w\x00\x12\x00\x0b"
cmd_test_ppk13 = "w\x00\x00\x00\x0c" cmd_test_spk13 = "w\x00\x12\x00\x0c"
cmd_test_ppk14 = "w\x00\x00\x00\x0d" cmd_test_spk14 = "w\x00\x12\x00\x0d"
cmd_test_ppk15 = "w\x00\x00\x00\x0e" cmd_test_spk15 = "w\x00\x12\x00\x0e"
cmd_test_ppk16 = "w\x00\x00\x00\x0f" cmd_test_spk16 = "w\x00\x12\x00\x0f"
[UserDefined] [UserDefined]