Skip to content

Introduce CbGPIOSMITH module#65

Open
mhei wants to merge 1 commit into
mainfrom
feature/CbGPIOSMITH
Open

Introduce CbGPIOSMITH module#65
mhei wants to merge 1 commit into
mainfrom
feature/CbGPIOSMITH

Conversation

@mhei

@mhei mhei commented Jun 18, 2026

Copy link
Copy Markdown
Member

This PR introduces a tiny module which observes for contactor errors. When some BSP module raises such an error, then this module triggers a GPIO output with the goal that the power path is turned off - this might also result in a power cut of the charger electronics itself, so the module tries to ensure that at least the logs are saved to disk before.

@barsnick barsnick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay. One typo, one question.

Comment thread modules/CbGPIOSMITH/CbGPIOSMITH.cpp
Comment thread modules/CbGPIOSMITH/manifest.yaml Outdated
config:
gpio_line_name:
description: >-
The GPIO line name to use as 'gun''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate ''.

Suggested change
The GPIO line name to use as 'gun''
The GPIO line name to use as 'gun'

@FaHaGit FaHaGit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions. Otherwise, it looks good.

Comment thread modules/CbGPIOSMITH/CbGPIOSMITH.cpp Outdated
}
});
}
// special case: no linked EVSE Managers -> we cannot see such events -> always trigger immediately

@FaHaGit FaHaGit Jun 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we log a warning in case an EvseManager wasn't connected by mistake? It's actually not recommended to leave the EvseManager unconnected, due to the risk of a direct shutdown.

EVLOG_warning << "PID of systemd-journald not found";
}

std::this_thread::sleep_for(std::chrono::seconds(1));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a one-second sleep sufficient to meet the timing requirements for turning off the power?

This module triggers on contactor errors and switches a GPIO.
Before, it tries to ensure that the logs are flushed and synced to disk.

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
@mhei mhei force-pushed the feature/CbGPIOSMITH branch from b74c84e to 8ceecc2 Compare June 19, 2026 10:39
if (error.type == "evse_board_support/MREC17EVSEContactorFault") {
if (this->charging_started_seen) {
EVLOG_info << "Contactor Error Detected - Triggering Fallback Safety Circuit";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this similar to Fabians comment: Maybe we should add a TODO, that this module informs the charging stack of the shutdown or the contactor error is translated into a shutdown notification at the first place?


flush_journald_and_filesystems();

this->gpio->set_value(this->gpio->offsets()[0], gpiod::line::value::ACTIVE);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our case this should be fine, but maybe this is helpful for integrator to verify the GPIO value and provide a warning in case the value is unexpected.

Additional does it make to add a comment that in "good case" everything beyond set_value is "unreachable" code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants