Skip to content

Obd2Ecu Fix transition to ON and retry if it fails#1350

Draft
frogonwheels wants to merge 2 commits intoopenvehicles:masterfrom
frogonwheels:ecu-retry
Draft

Obd2Ecu Fix transition to ON and retry if it fails#1350
frogonwheels wants to merge 2 commits intoopenvehicles:masterfrom
frogonwheels:ecu-retry

Conversation

@frogonwheels
Copy link
Copy Markdown
Contributor

Some logic of changing the state was not quite matched up.

Make sure that the obd started event only happens AFTER and IF the ecu has actually turned on.

Retries every second to restart OBD CAN if it doesn't turn on. At the moment it does NOT give up.

@dexterbg
Copy link
Copy Markdown
Member

Codewise, calling pcp::SetPowerMode() needs to be added to the default case in mcp2515::SetPowerMode() to keep support for the other power modes (even if not yet implemented in mcp2515).

The changes to obd2ecu look OK to me, but I have no device to test these with.

It's a bit concerning this doesn't address the assumed underlying issue in mcp2515 but makes coping with the issue / applying the workaround the application's job. Start() generally may fail, but if retrying is sometimes necessary just due to a hardware or driver bug, maybe it's rather the driver that should take care of retrying.

mcp2515::Start() tries to detect error conditions, was this the case, did you see some logs of that kind?

@frogonwheels
Copy link
Copy Markdown
Contributor Author

frogonwheels commented Mar 14, 2026 via email

@frogonwheels
Copy link
Copy Markdown
Contributor Author

frogonwheels commented Mar 14, 2026 via email

@dexterbg
Copy link
Copy Markdown
Member

Those are user events, i.e. meant for scripting, there is no default listener in the firmware. The user guide documents these as being related to the OBD2ECU process (task) state, if your new logic still fits that usage, it should be fine. If scripts would need to be changed, you should rather introduce new events.

@frogonwheels
Copy link
Copy Markdown
Contributor Author

frogonwheels commented Mar 15, 2026 via email

@dexterbg
Copy link
Copy Markdown
Member

The PCP framework's primary intention is to provide a standard API & user interface to controlling the basic operational states of components. It does not require any specific semantics of the "on" state, "on" simply means "can be switched off or possibly put into sleep / deep sleep".

Wether powering on can fail, keeping the previous PCP state, is up to the component, as is the general mapping of the states. Ideally, power state "on" means anything has been started or initialized that's actually using resources of any kind. "Sleep" mode then means telling the component to reduce resource usage if possible, "deep sleep" to minimize resource usage as far as possible, "off" means free all resources.

While powering on may not be a sufficient initial operation without parameters for certain components (like the CAN buses), the PCP system may still be used to provide the standard shutdown/sleep operation API. After sleeping, powering on should ideally restore the pre-sleep state.

Also what is the mess that is iterating through the values of m_mappm to
find the key which is the name of the state?

Well… could be solved otherwise, but as the map is already there and carrying a 1:1 relation, why not use it?

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.

2 participants