mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 18:29:48 +02:00
GPIO allocation errors raise events and print to log
This commit is contained in:
parent
e3de4e546c
commit
824cee1505
7 changed files with 22 additions and 18 deletions
|
@ -714,9 +714,7 @@ void ChademoBattery::handle_chademo_sequence() {
|
|||
* with timers to have higher confidence of certain conditions hitting
|
||||
* a steady state
|
||||
*/
|
||||
#ifdef DEBUG_LOG
|
||||
logging.println("CHADEMO plug is not inserted, cannot connect d2 relay to begin initialization.");
|
||||
#endif
|
||||
LOG_PRINTLN("CHADEMO plug is not inserted, cannot connect d2 relay to begin initialization.");
|
||||
CHADEMO_Status = CHADEMO_IDLE;
|
||||
}
|
||||
break;
|
||||
|
@ -725,9 +723,7 @@ void ChademoBattery::handle_chademo_sequence() {
|
|||
* Used for triggers/error handling elsewhere;
|
||||
* State change to CHADEMO_NEGOTIATE occurs in handle_incoming_can_frame_battery(..)
|
||||
*/
|
||||
#ifdef DEBUG_LOG
|
||||
// logging.println("Awaiting initial vehicle CAN to trigger negotiation");
|
||||
#endif
|
||||
LOG_PRINTLN("Awaiting initial vehicle CAN to trigger negotiation");
|
||||
evse_init();
|
||||
break;
|
||||
case CHADEMO_NEGOTIATE:
|
||||
|
|
|
@ -102,8 +102,6 @@ void VolvoSpaBattery::
|
|||
logging.println(MAX_U);
|
||||
logging.print("Battery minimum voltage limit: ");
|
||||
logging.println(MIN_U);
|
||||
logging.print("Remaining Energy: ");
|
||||
logging.println(remaining_capacity);
|
||||
logging.print("Discharge limit: ");
|
||||
logging.println(HvBattPwrLimDchaSoft);
|
||||
logging.print("Battery Error Indication: ");
|
||||
|
|
|
@ -25,7 +25,7 @@ bool periodic_bms_reset = periodic_bms_reset_default;
|
|||
#ifdef REMOTE_BMS_RESET
|
||||
const bool remote_bms_reset_default = true;
|
||||
#else
|
||||
const bool remote_bms_reset_default = true;
|
||||
const bool remote_bms_reset_default = false;
|
||||
#endif
|
||||
bool remote_bms_reset = remote_bms_reset_default;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <chrono>
|
||||
#include <unordered_map>
|
||||
#include "../../../src/devboard/utils/events.h"
|
||||
#include "../../../src/devboard/utils/logging.h"
|
||||
#include "../../../src/devboard/utils/types.h"
|
||||
|
||||
// Hardware Abstraction Layer base class.
|
||||
|
@ -30,14 +31,13 @@ class Esp32Hal {
|
|||
for (gpio_num_t pin : requested_pins) {
|
||||
if (pin < 0) {
|
||||
set_event(EVENT_GPIO_NOT_DEFINED, (int)pin);
|
||||
// Event: {name} attempted to allocate pin that wasn't defined for the selected HW.
|
||||
LOG_PRINT("%s attempted to allocate pin %d that wasn't defined for the selected HW.\n", name, (int)pin);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto it = allocated_pins.find(pin);
|
||||
if (it != allocated_pins.end()) {
|
||||
// Event: GPIO conflict for pin {pin} between name and it->second.
|
||||
//std::cerr << "Pin " << pin << " already allocated to \"" << it->second << "\".\n";
|
||||
LOG_PRINT("GPIO conflict for pin %d between %s and %s.\n", (int)pin, name, it->second.c_str());
|
||||
set_event(EVENT_GPIO_CONFLICT, (int)pin);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -396,16 +396,12 @@ void update_pause_state() {
|
|||
allowed_to_send_CAN = (!emulator_pause_CAN_send_ON || emulator_pause_status == NORMAL);
|
||||
|
||||
if (previous_allowed_to_send_CAN && !allowed_to_send_CAN) {
|
||||
#ifdef DEBUG_LOG
|
||||
logging.printf("Safety: Pausing CAN sending\n");
|
||||
#endif
|
||||
LOG_PRINT("Safety: Pausing CAN sending\n");
|
||||
//completely force stop the CAN communication
|
||||
stop_can();
|
||||
} else if (!previous_allowed_to_send_CAN && allowed_to_send_CAN) {
|
||||
//resume CAN communication
|
||||
#ifdef DEBUG_LOG
|
||||
logging.printf("Safety: Resuming CAN sending\n");
|
||||
#endif
|
||||
LOG_PRINT("Safety: Resuming CAN sending\n");
|
||||
restart_can();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,17 @@ class Logging : public Print {
|
|||
};
|
||||
|
||||
extern Logging logging;
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
#define LOG_PRINT(fmt, ...) logging.printf(fmt, ##__VA_ARGS__)
|
||||
#define LOG_PRINTLN(str) logging.println(str)
|
||||
#else
|
||||
#define LOG_PRINT(fmt, ...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#define LOG_PRINTLN(str) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif // __LOGGING_H__
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "events_html.h"
|
||||
#include "../../datalayer/datalayer.h"
|
||||
#include "../../devboard/utils/logging.h"
|
||||
|
||||
const char EVENTS_HTML_START[] = R"=====(
|
||||
<style>body{background-color:#000;color:#fff}.event-log{display:flex;flex-direction:column}.event{display:flex;flex-wrap:wrap;border:1px solid #fff;padding:10px}.event>div{flex:1;min-width:100px;max-width:90%;word-break:break-word}</style><div style="background-color:#303e47;padding:10px;margin-bottom:10px;border-radius:25px"><div class="event-log"><div class="event" style="background-color:#1e2c33;font-weight:700"><div>Event Type</div><div>Severity</div><div>Last Event</div><div>Count</div><div>Data</div><div>Message</div></div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue