added CAN-Debug-Message
This commit is contained in:
parent
ce9f1a2306
commit
c42de4b24c
@ -7,6 +7,7 @@
|
||||
#include "common.h"
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "debugger.h"
|
||||
|
||||
struct can_frame
|
||||
{
|
||||
@ -16,6 +17,7 @@ struct can_frame
|
||||
};
|
||||
|
||||
void Init_CAN();
|
||||
void CAN_Process();
|
||||
uint32_t Process_CAN_WheelSpeed();
|
||||
|
||||
#endif
|
@ -7,6 +7,7 @@
|
||||
#include "common.h"
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "debugger.h"
|
||||
|
||||
void RunLubeApp(uint32_t add_milimeters);
|
||||
void LubePulse();
|
||||
|
@ -16,6 +16,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CAN_DEBUG_MESSAGE
|
||||
#ifndef FEATURE_ENABLE_CAN
|
||||
#error "You cannot enable CAN-Debug-Message without FEATURE_ENABLE_CAN"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ADMIN_PASSWORD
|
||||
#error "You need to define ADMIN_PASSWORD for OTA-Update"
|
||||
#endif
|
||||
|
@ -2,6 +2,9 @@
|
||||
#include "can.h"
|
||||
|
||||
MCP_CAN CAN0(GPIO_CS_CAN);
|
||||
#ifdef CAN_DEBUG_MESSAGE
|
||||
void sendCANDebugMessage();
|
||||
#endif
|
||||
|
||||
void Init_CAN()
|
||||
{
|
||||
@ -16,6 +19,17 @@ void Init_CAN()
|
||||
CAN0.setMode(MCP_NORMAL);
|
||||
}
|
||||
|
||||
void CAN_Process()
|
||||
{
|
||||
static uint32_t previousMillis = 0;
|
||||
|
||||
if (millis() - previousMillis >= 100)
|
||||
{
|
||||
sendCANDebugMessage();
|
||||
previousMillis = millis();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Process_CAN_WheelSpeed()
|
||||
{
|
||||
#define FACTOR_RWP_KMH_890ADV 18 // Divider to convert Raw Data to km/h
|
||||
@ -46,4 +60,55 @@ uint32_t Process_CAN_WheelSpeed()
|
||||
|
||||
return milimeters_to_add;
|
||||
}
|
||||
|
||||
#ifdef CAN_DEBUG_MESSAGE
|
||||
void sendCANDebugMessage()
|
||||
{
|
||||
#define MAX_DEBUG_MULTIPLEXER 6
|
||||
static uint8_t debugMultiplexer = 0;
|
||||
byte data[8] = {debugMultiplexer, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
uint32_t millisValue = millis();
|
||||
|
||||
switch (debugMultiplexer)
|
||||
{
|
||||
case 0:
|
||||
memcpy(&data[1], &millisValue, sizeof(millisValue));
|
||||
memcpy(&data[5], &globals.purgePulses, sizeof(globals.purgePulses));
|
||||
break;
|
||||
case 1:
|
||||
data[1] = (uint8_t)globals.systemStatus;
|
||||
data[2] = (uint8_t)globals.resumeStatus;
|
||||
data[3] = (uint8_t)globals.requestEEAction;
|
||||
data[4] = globals.TankPercentage;
|
||||
data[5] = (0x01 & globals.hasDTC) | ((0x01 & globals.measurementActive) << 1);
|
||||
break;
|
||||
case 2:
|
||||
memcpy(&data[1], &globals.eePersistanceAdress, sizeof(globals.eePersistanceAdress));
|
||||
memcpy(&data[3], &PersistenceData.tankRemain_microL, sizeof(PersistenceData.tankRemain_microL));
|
||||
break;
|
||||
case 3:
|
||||
memcpy(&data[1], &PersistenceData.writeCycleCounter, sizeof(PersistenceData.writeCycleCounter));
|
||||
memcpy(&data[3], &PersistenceData.TravelDistance_highRes_mm, sizeof(PersistenceData.TravelDistance_highRes_mm));
|
||||
break;
|
||||
case 4:
|
||||
memcpy(&data[1], &PersistenceData.odometer_mm, sizeof(PersistenceData.odometer_mm));
|
||||
break;
|
||||
case 5:
|
||||
memcpy(&data[1], &PersistenceData.odometer, sizeof(PersistenceData.odometer));
|
||||
break;
|
||||
case 6:
|
||||
memcpy(&data[1], &PersistenceData.checksum, sizeof(PersistenceData.checksum));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
debugMultiplexer++;
|
||||
debugMultiplexer = debugMultiplexer > MAX_DEBUG_MULTIPLEXER ? 0 : debugMultiplexer;
|
||||
|
||||
byte sndStat = CAN0.sendMsgBuf(0x7FF, 0, 8, data);
|
||||
if (sndStat != CAN_OK)
|
||||
Debug_pushMessage("failed sending CAN-DbgMsg: %d\n", sndStat);
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -96,31 +96,19 @@ void setup()
|
||||
#endif
|
||||
leds.begin();
|
||||
Serial.print("\nLED-Init done");
|
||||
switch (LubeConfig.SpeedSource)
|
||||
{
|
||||
case SOURCE_IMPULSE:
|
||||
pinMode(GPIO_TRIGGER, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(GPIO_TRIGGER), trigger_ISR, FALLING);
|
||||
break;
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
case SOURCE_GPS:
|
||||
Init_GPS();
|
||||
break;
|
||||
#endif
|
||||
#ifdef FEATURE_ENABLE_TIMER
|
||||
case SOURCE_TIME:
|
||||
|
||||
break;
|
||||
pinMode(GPIO_TRIGGER, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(GPIO_TRIGGER), trigger_ISR, FALLING);
|
||||
Serial.print("\nPulse-Input Init done");
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
Init_GPS();
|
||||
Serial.print("\nGPS-Init done");
|
||||
#endif
|
||||
#ifdef FEATURE_ENABLE_CAN
|
||||
case SOURCE_CAN:
|
||||
Init_CAN();
|
||||
break;
|
||||
Init_CAN();
|
||||
Serial.print("\nCAN-Init done");
|
||||
#endif
|
||||
default:
|
||||
Debug_pushMessage("Source Setting N/A");
|
||||
break;
|
||||
}
|
||||
|
||||
Serial.print("\nSource-Init done");
|
||||
pinMode(GPIO_BUTTON, INPUT_PULLUP);
|
||||
pinMode(GPIO_PUMP, OUTPUT);
|
||||
@ -193,6 +181,9 @@ void loop()
|
||||
RunLubeApp(wheelDistance);
|
||||
#ifdef FEATURE_ENABLE_OLED
|
||||
Display_Process();
|
||||
#endif
|
||||
#ifdef FEATURE_ENABLE_CAN
|
||||
CAN_Process();
|
||||
#endif
|
||||
Button_Process();
|
||||
LED_Process();
|
||||
|
Loading…
x
Reference in New Issue
Block a user