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

examples: Add example on how to use mavsdk_server lib #2473

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

julianoes
Copy link
Collaborator

This just shows how to use the C API to instantiate the gRPC server.

mavsdk_server_init(&mavsdk_server);
mavsdk_server_run(mavsdk_server, argv[1], 50051);

mavsdk_server_destroy(mavsdk_server);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't you mavsdk_server_stop before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mavsdk_server_stop is done in the signal handler.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But then shouldn't you call mavsdk_server_attach() before? Maybe I'm misremembering it, but here it feels like it will destroy as soon as the autopilot is detected and mavsdk_server_run returns 🤔

return 1;
}

signal(SIGUSR1, signal_handler);
Copy link
Collaborator

Choose a reason for hiding this comment

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

How is SIGUSR1 triggered? I thought it would have to come programmatically, but in this example nothing sends it 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I should change it to the signal you get with Ctrl+C and catch that nicely.

Copy link

@julianoes
Copy link
Collaborator Author

CI is unrelated, merging.

@julianoes julianoes merged commit f09fa8d into main Dec 18, 2024
32 of 40 checks passed
@julianoes julianoes deleted the pr-server-example branch December 18, 2024 21:25
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