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

Readme usage example typos/bugs #144

Closed
PetervdPerk-NXP opened this issue Mar 25, 2020 · 0 comments
Closed

Readme usage example typos/bugs #144

PetervdPerk-NXP opened this issue Mar 25, 2020 · 0 comments

Comments

@PetervdPerk-NXP
Copy link

@PetervdPerk-NXP PetervdPerk-NXP commented Mar 25, 2020

In readme.md an example described on how to use libcanard, however in this segment

for (const CanardFrame* txf = NULL; (txf = canardTxPeek(&ins)) != NULL;)  // Look at the top of the TX queue.
{
    if (txf->timestamp_usec < getCurrentMicroseconds())  // Check if the frame has timed out.
    {
        if (!pleaseTransmit(&txf))             // Send the frame. Redundant interfaces may be used here.
        {
            break;                             // If the driver is busy, break and retry later.
        }
    }
    canardTxPop(&ins);                         // Remove the frame from the queue after it's transmitted.
    ins.memory_free(&ins, (CanardFrame*)txf);  // Deallocate the dynamic memory afterwards.
}

There are two bugs, I suppose we want to drop frames when the frame has timed out e.g:

if (txf->timestamp_usec > getCurrentMicroseconds())  // Check if the frame has timed out.

And I suppose we want to have a pointer here instead of a reference.

if (!pleaseTransmit(txf))             // Send the frame. Redundant interfaces may be used here.

Furthermore the example doesn't describe on how to subscribe to the uavcan.node.Heartbeat messages, If that could be added that would be nice.

pavel-kirienko added a commit that referenced this issue Mar 27, 2020
Fix #144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.