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

Running out of free Mobs #7

Open
astrand opened this issue May 14, 2020 · 1 comment · May be fixed by #8
Open

Running out of free Mobs #7

astrand opened this issue May 14, 2020 · 1 comment · May be fixed by #8

Comments

@astrand
Copy link

astrand commented May 14, 2020

I'm using the SparkFun CAN485 in vehicles. After a few days, the CAN transmission stops working. I have determined that this is because there are no more free Mobs.

In my application, I'm sending 3 different CAN frames. For sending, I have created a helper:

void canTx(st_cmd_t* cmd) {
    switch (cmd->status) {
    case MOB_TX_COMPLETED:
    case STATUS_CLEARED:
        break;

    default:
        Serial.print(F("CAN TX error: "));
        Serial.println(cmd->status);
        break;
    }

    /* Send to CAN */
    cmd->ctrl.rtr = 0;                  // Set rtr bit
    cmd->cmd = CMD_TX_DATA;
    // The command will not be accepted if no free MObs.
    // cmd->status = MOB_NOT_REACHED, and we will retry next time
    if (can_cmd(cmd) != CAN_CMD_ACCEPTED) {
        Serial.println(F("CAN TX command refused"));
    }
}

For all 3 frames, sending is then done as:

        switch (can_get_status(&NmtTX)) {
        case CAN_STATUS_COMPLETED:
        case CAN_STATUS_ERROR:
            canTx(&NmtTX);
        }

I'm sending once every 4 seconds, and in the log I'm looking at right now, the first MOB was "lost" after 125 minutes, or about after ~1900 transmissions. The second MOB was lost after additional 655 minutes. So it is fairly rare, but apparently there is some kind of race condition or cornercase. Any ideas?

@astrand
Copy link
Author

astrand commented May 21, 2020

astrand added a commit to astrand/AST_CAN_Arduino_Library that referenced this issue May 29, 2020
Using CANCDMOB is subject to race conditions, for example when no
nodes are ACKing.

Fixes Atlantis-Specialist-Technologies#7.
@astrand astrand linked a pull request May 29, 2020 that will close this issue
astrand added a commit to astrand/AST_CAN_Arduino_Library that referenced this issue Jun 5, 2020
Using only CANCDMOB is subject to race conditions, for example when no
nodes are ACKing.

Fixes Atlantis-Specialist-Technologies#7.
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 a pull request may close this issue.

1 participant