auto-sync

This commit is contained in:
rusEfi 2014-12-21 11:03:35 -06:00
parent e8a5a2a972
commit 109eb90523
6 changed files with 31 additions and 29 deletions

View File

@ -319,7 +319,7 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat
boardConfiguration->canRxPin = GPIOB_12;
engineConfiguration->canWriteEnabled = true;
engineConfiguration->canReadEnabled = false;
engineConfiguration->can_nbc_type = CAN_BUS_NBC_BMW;
engineConfiguration->canNbcType = CAN_BUS_NBC_BMW;
// engineConfiguration->can_nbc_type = CAN_BUS_MAZDA_RX8;
}

View File

@ -267,8 +267,8 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
engineConfiguration->tpsErrorLowValue = convertVoltageTo10bitADC(0.2);
engineConfiguration->tpsErrorHighValue = convertVoltageTo10bitADC(6);
engineConfiguration->can_nbc_type = CAN_BUS_NBC_BMW;
engineConfiguration->can_sleep_period = 50;
engineConfiguration->canNbcType = CAN_BUS_NBC_BMW;
engineConfiguration->canSleepPeriod = 50;
engineConfiguration->canReadEnabled = TRUE;
engineConfiguration->canWriteEnabled = false;

View File

@ -400,8 +400,9 @@ typedef struct {
int canReadEnabled;
int canWriteEnabled;
// offset 968
can_nbc_e can_nbc_type;
int can_sleep_period;
can_nbc_e canNbcType;
// offset 972
int canSleepPeriod;
int cylindersCount;

View File

@ -88,7 +88,7 @@ static void commonTxInit(int eid) {
static void sendMessage2(int size) {
txmsg.DLC = size;
msg_t result = canTransmit(&EFI_CAN_DEVICE, CAN_ANY_MAILBOX, &txmsg, TIME_INFINITE);
if(result==RDY_OK) {
if (result == RDY_OK) {
can_write_ok++;
} else {
can_write_not_ok++;
@ -120,30 +120,28 @@ static void canMazdaRX8(void) {
commonTxInit(0x300);
sendMessage2(0);
commonTxInit(CAN_MAZDA_RX_RPM_SPEED);
setShortValue(&txmsg, engine_rpm * 4, 1);
setShortValue(&txmsg, 0xFFFF, 3);
setShortValue(&txmsg, 123+10000, 5);
setShortValue(&txmsg, 123 + 10000, 5);
setShortValue(&txmsg, 0, 7);
sendMessage();
commonTxInit(CAN_MAZDA_RX_STATUS_1);
setShortValue(&txmsg, engine_rpm * 4, 1);
setShortValue(&txmsg, 0xFFFF, 3);
setShortValue(&txmsg, 123+10000, 5);
setShortValue(&txmsg, 123 + 10000, 5);
setShortValue(&txmsg, 0, 7);
sendMessage2(7);
commonTxInit(CAN_MAZDA_RX_STATUS_1);
setShortValue(&txmsg, engine_rpm * 4, 1);
setShortValue(&txmsg, 0xFFFF, 3);
setShortValue(&txmsg, 123+10000, 5);
setShortValue(&txmsg, 123 + 10000, 5);
setShortValue(&txmsg, 0, 7);
sendMessage2(7);
// my_data[0] = (RPM * 4) / 256; // rpm
// my_data[1] = (RPM * 4) % 256; // rpm
// my_data[2] = 0xFF; // Unknown, 0xFF from 'live'.
@ -203,9 +201,9 @@ static void canRead(void) {
static void writeStateToCan(void) {
engine_rpm = getRpm();
engine_clt = 123;//getCoolantTemperature(engine);
engine_clt = 123; //getCoolantTemperature(engine);
canInfoNBCBroadcast(engineConfiguration->can_nbc_type);
canInfoNBCBroadcast(engineConfiguration->canNbcType);
}
static msg_t canThread(void *arg) {
@ -217,7 +215,12 @@ static msg_t canThread(void *arg) {
if (engineConfiguration->canReadEnabled)
canRead(); // todo: since this is a blocking operation, do we need a separate thread for 'write'?
chThdSleepMilliseconds(engineConfiguration->can_sleep_period);
if (engineConfiguration->canSleepPeriod < 10) {
warning(OBD_PCM_Processor_Fault, "%d too low CAN", engineConfiguration->canSleepPeriod);
engineConfiguration->canSleepPeriod = 50;
}
chThdSleepMilliseconds(engineConfiguration->canSleepPeriod);
}
#if defined __GNUC__
return -1;
@ -227,13 +230,11 @@ static msg_t canThread(void *arg) {
static void canInfo(void) {
scheduleMsg(&logger, "CAN TX %s", hwPortname(boardConfiguration->canTxPin));
scheduleMsg(&logger, "CAN RX %s", hwPortname(boardConfiguration->canRxPin));
scheduleMsg(&logger, "type=%d canReadEnabled=%s canWriteEnabled=%s",
engineConfiguration->can_nbc_type,
boolToString(engineConfiguration->canReadEnabled),
boolToString(engineConfiguration->canWriteEnabled));
scheduleMsg(&logger, "type=%d canReadEnabled=%s canWriteEnabled=%s period=%d", engineConfiguration->canNbcType,
boolToString(engineConfiguration->canReadEnabled), boolToString(engineConfiguration->canWriteEnabled),
engineConfiguration->canSleepPeriod);
scheduleMsg(&logger, "CAN rx count %d/tx ok %d/tx not ok %d", canReadCounter,
can_write_ok, can_write_not_ok);
scheduleMsg(&logger, "CAN rx count %d/tx ok %d/tx not ok %d", canReadCounter, can_write_ok, can_write_not_ok);
}
void initCan(void) {

View File

@ -265,5 +265,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 20141219;
return 20141221;
}

View File

@ -118,10 +118,10 @@ enable2ndByteCanID = false
VBattDividerCoefficient = scalar, F32, 948, "coef", 1, 0, 0.01, 20.0, 2 ; size 4
FanONTemperature = scalar, F32, 952, "°C", 1, 0, 0, 1000.0, 2 ; size 4
FanOffTemperature = scalar, F32, 956, "°C", 1, 0, 0, 1000.0, 2 ; size 4
CanReadEnabled = bits, U32, 960, [0:0], "false", "true"
CanWriteEnabled = bits, U32, 964, [0:0], "false", "true"
; CanNbcType = bits, U32, 968, [0:1], "BMW", "FIAT", "VAG" , "INVALID"
CanSleepPeriod = scalar, F32, 972, "RPM", 1, 0, 0, 1000.0, 2 ; size 4
canReadEnabled = bits, U32, 960, [0:0], "false", "true"
canWriteEnabled = bits, U32, 964, [0:0], "false", "true"
; canNbcType = bits, U32, 968, [0:1], "BMW", "FIAT", "VAG" , "INVALID"
canSleepPeriod = scalar, F32, 972, "RPM", 1, 0, 0, 1000.0, 2 ; size 4
nCylinders = bits, U32, 976, [0:3], "INVALID", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, "INVALID", "INVALID", "INVALID"
IgnitionMode = bits, U32, 980, [0:1], "One coil", "Individual Coils", "Wasted", "INVALID"
FiringOrder = bits, U32, 984, [0:2], "One Cylinder", "1-3-4-2", "1-2-4-3", "1-3-2-4", "1-5-3-6-2-4", "1-8-4-3-6-5-7-2", "INVALID", "INVALID"
@ -922,10 +922,10 @@ fileVersion = { 20141103 }
; Board->Connection
dialog = canBus, "CAN Bus"
field = "Can Read Enabled", CanReadEnabled
field = "Can Write Enabled", CanWriteEnabled
; field = "Can Nbc Type", CanNbcType
field = "Can Sleep Period", CanSleepPeriod
field = "Can Read Enabled", canReadEnabled
field = "Can Write Enabled", canWriteEnabled
; field = "Can Nbc Type", canNbcType
field = "Can Sleep Period", canSleepPeriod
dialog = sdCard, "SD Card Logger"
field = "SdCard", isSdCardEnabled