mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Merge pull request #1503 from dalathegreat/bugfix/logging-unreliable
Bugfix: Make setup() unable to return early
This commit is contained in:
commit
c6ad1f8afe
6 changed files with 19 additions and 32 deletions
|
@ -74,6 +74,7 @@ bool init_contactors() {
|
|||
auto precPin = esp32hal->PRECHARGE_PIN();
|
||||
|
||||
if (!esp32hal->alloc_pins(contactors, posPin, negPin, precPin)) {
|
||||
DEBUG_PRINTF("GPIO controlled contactor setup failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -97,6 +98,7 @@ bool init_contactors() {
|
|||
if (contactor_control_enabled_double_battery) {
|
||||
auto second_contactors = esp32hal->SECOND_BATTERY_CONTACTORS_PIN();
|
||||
if (!esp32hal->alloc_pins(contactors, second_contactors)) {
|
||||
DEBUG_PRINTF("Secondary battery contactor control setup failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -108,6 +110,7 @@ bool init_contactors() {
|
|||
if (periodic_bms_reset || remote_bms_reset || esp32hal->always_enable_bms_power()) {
|
||||
auto pin = esp32hal->BMS_POWER();
|
||||
if (!esp32hal->alloc_pins("BMS power", pin)) {
|
||||
DEBUG_PRINTF("BMS power setup failed\n");
|
||||
return false;
|
||||
}
|
||||
pinMode(pin, OUTPUT);
|
||||
|
|
|
@ -31,13 +31,11 @@ bool init_precharge_control() {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Setup PWM Channel Frequency and Resolution
|
||||
logging.printf("Precharge control initialised\n");
|
||||
|
||||
auto hia4v1_pin = esp32hal->HIA4V1_PIN();
|
||||
auto inverter_disconnect_contactor_pin = esp32hal->INVERTER_DISCONNECT_CONTACTOR_PIN();
|
||||
|
||||
if (!esp32hal->alloc_pins("Precharge control", hia4v1_pin, inverter_disconnect_contactor_pin)) {
|
||||
DEBUG_PRINTF("Precharge control setup failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -46,6 +44,7 @@ bool init_precharge_control() {
|
|||
pinMode(inverter_disconnect_contactor_pin, OUTPUT);
|
||||
digitalWrite(inverter_disconnect_contactor_pin, LOW);
|
||||
|
||||
DEBUG_PRINTF("Precharge control setup successful\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ bool init_rs485() {
|
|||
auto pin_5v_en = esp32hal->PIN_5V_EN();
|
||||
|
||||
if (!esp32hal->alloc_pins_ignore_unused("RS485", en_pin, se_pin, pin_5v_en)) {
|
||||
return false;
|
||||
DEBUG_PRINTF("Modbus failed to allocate pins\n");
|
||||
return true; //Early return, we do not set the pins
|
||||
}
|
||||
|
||||
if (en_pin != GPIO_NUM_NC) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* @param[in] void
|
||||
*
|
||||
* @return true if init was successful, false otherwise.
|
||||
* @return Safe to call even if rs485 is not used
|
||||
*/
|
||||
bool init_rs485();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ static LED* led;
|
|||
|
||||
bool led_init(void) {
|
||||
if (!esp32hal->alloc_pins("LED", esp32hal->LED_PIN())) {
|
||||
DEBUG_PRINTF("LED setup failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue