Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMS_NORMAL_CLOSE_SECOND_STRING_CONTACTOR BMS substate only exits on timeout #68

Open
GustavVaeridion opened this issue Dec 16, 2024 · 1 comment

Comments

@GustavVaeridion
Copy link

Hello,

After performing some static code analysis on bms.c state machine, I wonder if I found a fatal flaw for general progression inside the "NORMAL" state.
It seems like BMS_NORMAL_CLOSE_SECOND_STRING_CONTACTOR is only able to exit due to timeout, which should never occur due to constant reset in the entrance of the substate. So it seems to me that the whole BMS state machine will get stuck in the "NORMAL" state

else if (bms_state.substate == BMS_NORMAL_CLOSE_SECOND_STRING_CONTACTOR) {
    contactorState = CONT_GetContactorState(nextStringNumber, CONT_MINUS);
    if (contactorState == CONT_SWITCH_ON) {
        /* First string contactor closed. Close second string contactor */
        CONT_CloseContactor(nextStringNumber, CONT_PLUS);
        bms_state.timer    = BMS_WAIT_TIME_AFTER_CLOSING_STRING_CONTACTOR;
        bms_state.substate = BMS_NORMAL_CLOSE_SECOND_STRING_CONTACTOR;
    } else if (bms_state.stringCloseTimeout == 0u) {
        /* String takes too long to close */
        bms_state.timer     = BMS_STATEMACH_SHORTTIME;
        bms_state.state     = BMS_STATEMACH_OPEN_CONTACTORS;
        bms_state.nextstate = BMS_STATEMACH_ERROR;
        bms_state.substate  = BMS_ENTRY;
        break;
    } else {
        /* String minus contactor has not been closed successfully. Re-trigger closing */
        CONT_CloseContactor(nextStringNumber, CONT_MINUS);
        bms_state.timer = BMS_STATEMACH_SHORTTIME;
    }

image

@foxBMS
Copy link
Owner

foxBMS commented Dec 20, 2024

Dear @GustavVaeridion ,

Thank you for your feedback. We will have a look at this.

Best regards,
The foxBMS Team

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

No branches or pull requests

2 participants