mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 02:39:57 +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
|
* with timers to have higher confidence of certain conditions hitting
|
||||||
* a steady state
|
* a steady state
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG_LOG
|
LOG_PRINTLN("CHADEMO plug is not inserted, cannot connect d2 relay to begin initialization.");
|
||||||
logging.println("CHADEMO plug is not inserted, cannot connect d2 relay to begin initialization.");
|
|
||||||
#endif
|
|
||||||
CHADEMO_Status = CHADEMO_IDLE;
|
CHADEMO_Status = CHADEMO_IDLE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -725,9 +723,7 @@ void ChademoBattery::handle_chademo_sequence() {
|
||||||
* Used for triggers/error handling elsewhere;
|
* Used for triggers/error handling elsewhere;
|
||||||
* State change to CHADEMO_NEGOTIATE occurs in handle_incoming_can_frame_battery(..)
|
* State change to CHADEMO_NEGOTIATE occurs in handle_incoming_can_frame_battery(..)
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG_LOG
|
LOG_PRINTLN("Awaiting initial vehicle CAN to trigger negotiation");
|
||||||
// logging.println("Awaiting initial vehicle CAN to trigger negotiation");
|
|
||||||
#endif
|
|
||||||
evse_init();
|
evse_init();
|
||||||
break;
|
break;
|
||||||
case CHADEMO_NEGOTIATE:
|
case CHADEMO_NEGOTIATE:
|
||||||
|
|
|
@ -102,8 +102,6 @@ void VolvoSpaBattery::
|
||||||
logging.println(MAX_U);
|
logging.println(MAX_U);
|
||||||
logging.print("Battery minimum voltage limit: ");
|
logging.print("Battery minimum voltage limit: ");
|
||||||
logging.println(MIN_U);
|
logging.println(MIN_U);
|
||||||
logging.print("Remaining Energy: ");
|
|
||||||
logging.println(remaining_capacity);
|
|
||||||
logging.print("Discharge limit: ");
|
logging.print("Discharge limit: ");
|
||||||
logging.println(HvBattPwrLimDchaSoft);
|
logging.println(HvBattPwrLimDchaSoft);
|
||||||
logging.print("Battery Error Indication: ");
|
logging.print("Battery Error Indication: ");
|
||||||
|
|
|
@ -25,7 +25,7 @@ bool periodic_bms_reset = periodic_bms_reset_default;
|
||||||
#ifdef REMOTE_BMS_RESET
|
#ifdef REMOTE_BMS_RESET
|
||||||
const bool remote_bms_reset_default = true;
|
const bool remote_bms_reset_default = true;
|
||||||
#else
|
#else
|
||||||
const bool remote_bms_reset_default = true;
|
const bool remote_bms_reset_default = false;
|
||||||
#endif
|
#endif
|
||||||
bool remote_bms_reset = remote_bms_reset_default;
|
bool remote_bms_reset = remote_bms_reset_default;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "../../../src/devboard/utils/events.h"
|
#include "../../../src/devboard/utils/events.h"
|
||||||
|
#include "../../../src/devboard/utils/logging.h"
|
||||||
#include "../../../src/devboard/utils/types.h"
|
#include "../../../src/devboard/utils/types.h"
|
||||||
|
|
||||||
// Hardware Abstraction Layer base class.
|
// Hardware Abstraction Layer base class.
|
||||||
|
@ -30,14 +31,13 @@ class Esp32Hal {
|
||||||
for (gpio_num_t pin : requested_pins) {
|
for (gpio_num_t pin : requested_pins) {
|
||||||
if (pin < 0) {
|
if (pin < 0) {
|
||||||
set_event(EVENT_GPIO_NOT_DEFINED, (int)pin);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = allocated_pins.find(pin);
|
auto it = allocated_pins.find(pin);
|
||||||
if (it != allocated_pins.end()) {
|
if (it != allocated_pins.end()) {
|
||||||
// Event: GPIO conflict for pin {pin} between name and it->second.
|
LOG_PRINT("GPIO conflict for pin %d between %s and %s.\n", (int)pin, name, it->second.c_str());
|
||||||
//std::cerr << "Pin " << pin << " already allocated to \"" << it->second << "\".\n";
|
|
||||||
set_event(EVENT_GPIO_CONFLICT, (int)pin);
|
set_event(EVENT_GPIO_CONFLICT, (int)pin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,16 +396,12 @@ void update_pause_state() {
|
||||||
allowed_to_send_CAN = (!emulator_pause_CAN_send_ON || emulator_pause_status == NORMAL);
|
allowed_to_send_CAN = (!emulator_pause_CAN_send_ON || emulator_pause_status == NORMAL);
|
||||||
|
|
||||||
if (previous_allowed_to_send_CAN && !allowed_to_send_CAN) {
|
if (previous_allowed_to_send_CAN && !allowed_to_send_CAN) {
|
||||||
#ifdef DEBUG_LOG
|
LOG_PRINT("Safety: Pausing CAN sending\n");
|
||||||
logging.printf("Safety: Pausing CAN sending\n");
|
|
||||||
#endif
|
|
||||||
//completely force stop the CAN communication
|
//completely force stop the CAN communication
|
||||||
stop_can();
|
stop_can();
|
||||||
} else if (!previous_allowed_to_send_CAN && allowed_to_send_CAN) {
|
} else if (!previous_allowed_to_send_CAN && allowed_to_send_CAN) {
|
||||||
//resume CAN communication
|
//resume CAN communication
|
||||||
#ifdef DEBUG_LOG
|
LOG_PRINT("Safety: Resuming CAN sending\n");
|
||||||
logging.printf("Safety: Resuming CAN sending\n");
|
|
||||||
#endif
|
|
||||||
restart_can();
|
restart_can();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,17 @@ class Logging : public Print {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Logging logging;
|
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__
|
#endif // __LOGGING_H__
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "events_html.h"
|
#include "events_html.h"
|
||||||
#include "../../datalayer/datalayer.h"
|
#include "../../datalayer/datalayer.h"
|
||||||
|
#include "../../devboard/utils/logging.h"
|
||||||
|
|
||||||
const char EVENTS_HTML_START[] = R"=====(
|
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>
|
<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