From c7c101bb1c36a32e22586a412b2d8273d7dece95 Mon Sep 17 00:00:00 2001 From: uhi22 Date: Tue, 12 Dec 2023 10:03:16 +0100 Subject: [PATCH] features: default logging of TCP traffic in both directions. Logging of voltages during precharge. --- ccs/ccs32_globals.h | 1 + ccs/myHelpers.h | 18 +++++------------- ccs/myLogging.h | 23 +++++++++++++++++++++++ ccs/pevStateMachine.cpp | 3 +++ ccs/tcp.cpp | 18 +++++++++++++----- include/param_prj.h | 6 ++++-- 6 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 ccs/myLogging.h diff --git a/ccs/ccs32_globals.h b/ccs/ccs32_globals.h index 28d77c2..d53c137 100644 --- a/ccs/ccs32_globals.h +++ b/ccs/ccs32_globals.h @@ -10,6 +10,7 @@ #include #include #include +#include "myLogging.h" #include "configuration.h" #include "printf.h" #include "connMgr.h" diff --git a/ccs/myHelpers.h b/ccs/myHelpers.h index b8d0cef..644974b 100644 --- a/ccs/myHelpers.h +++ b/ccs/myHelpers.h @@ -1,24 +1,14 @@ /* Interface header for myHelpers.c */ +#ifndef MY_HELPERS_H +#define MY_HELPERS_H + /* Global Defines */ #define STR_TMP_SIZE 400 #define MY_SERIAL_PRINTBUFFERLEN 400 -enum Module -{ - MOD_CONNMGR = 1, - MOD_HWIF = 2, - MOD_HOMEPLUG = 4, - MOD_PEV = 8, - MOD_QCA = 16, - MOD_TCP = 32, - MOD_TCPTRAFFIC = 64, - MOD_IPV6 = 128, - MOD_MODEMFINDER = 256 -}; - extern uint16_t checkpointNumber; /* Global Functions */ @@ -28,3 +18,5 @@ extern void showAsHex(uint8_t *data, uint16_t len, const char *description); extern void sanityCheck(const char *hint); extern void mySerialPrint(void); extern void setCheckpoint(uint16_t newcheckpoint); + +#endif \ No newline at end of file diff --git a/ccs/myLogging.h b/ccs/myLogging.h new file mode 100644 index 0000000..b5dc659 --- /dev/null +++ b/ccs/myLogging.h @@ -0,0 +1,23 @@ + +/* definitions for logging */ + +#ifndef MY_LOGGING_H +#define MY_LOGGING_H + +enum Module +{ + MOD_CONNMGR = 1, + MOD_HWIF = 2, + MOD_HOMEPLUG = 4, + MOD_PEV = 8, + MOD_QCA = 16, + MOD_TCP = 32, + MOD_TCPTRAFFIC = 64, + MOD_IPV6 = 128, + MOD_MODEMFINDER = 256 +}; + +/* Here we define, which logging data is produced after power-on */ +#define DEFAULT_LOGGINGMASK (MOD_TCPTRAFFIC | MOD_HOMEPLUG | MOD_PEV) + +#endif \ No newline at end of file diff --git a/ccs/pevStateMachine.cpp b/ccs/pevStateMachine.cpp index d6b74b0..39f2f6a 100644 --- a/ccs/pevStateMachine.cpp +++ b/ccs/pevStateMachine.cpp @@ -693,6 +693,9 @@ void stateFunctionWaitForPreChargeResponse(void) dinDocDec.V2G_Message.Body.PreChargeRes.EVSEPresentVoltage.Multiplier); Param::SetInt(Param::evsevtg, EVSEPresentVoltage); u = hardwareInterface_getInletVoltage(); + if (Param::GetInt(Param::logging) & MOD_PEV) { + printf("Inlet %dV, accu %dV\r\n", u, hardwareInterface_getAccuVoltage()); + } if (ABS(u-hardwareInterface_getAccuVoltage()) < PARAM_U_DELTA_MAX_FOR_END_OF_PRECHARGE) { addToTrace(MOD_PEV, "Difference between accu voltage and inlet voltage is small. Sending PowerDeliveryReq."); diff --git a/ccs/tcp.cpp b/ccs/tcp.cpp index 186701e..0c44975 100644 --- a/ccs/tcp.cpp +++ b/ccs/tcp.cpp @@ -200,11 +200,19 @@ void tcp_transmit(void) tcpHeaderLen = 20; /* 20 bytes normal header, no options */ if (tcpPayloadLen+tcpHeaderLen