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

Optionally remove OS dependencies #28

Closed
wants to merge 3 commits into from

Conversation

Sympatron
Copy link
Contributor

@Sympatron Sympatron commented Oct 30, 2024

In an effort to make it easier to port LibOSDP to embedded devices, I introduced the NO_OS flag (name is up for debate).
If this flag is set, no calls to system functions like printf, puts or gettimeofday will be made.

Instead the user is expected to set a either a custom logger->puts function or a logging callback.
For time keeping the user is expected to provide a usecs_now function, which is way easier and more useful on embedded devices.

Asserts are redirected to the global logger instead of printf.

Fixes #27

@Sympatron
Copy link
Contributor Author

An alternative approach would be automatically detect the absence of an OS if neither the Linux nor the Windows defines are set.

I am very open for debate if you don't like this specific implementation.

@sidcha
Copy link
Member

sidcha commented Nov 7, 2024

@Sympatron As always, thanks for the PR. I need to take a closer look at this problem before I can respond here. Will do so as soon as I get some spare cycles :).

@sidcha
Copy link
Member

sidcha commented Nov 9, 2024

Okay, just had a look at this. The way I see it, when LibOSDP is built for bare metal targets, the app should provide a strong reference to a osdp_millis_now which would solve the gettimeofday issue. Perhaps I'm missing something?

For puts and printf, my rationale was to provide a reasonable default. Many embedded SDKs have putchar redirection means into a uart device which would allow those functions to either log to uart or become NOPs. But if they cause issues, we can remove the defaults and expect callers to set something explicitly.

Edit: Okay, I think I see what you mean: libosdp itself doesn't need it but the compilation units force the need to build utils.c which has this problem. Let me think more about this.

sidcha added a commit that referenced this pull request Nov 10, 2024
This flag should be defined when c-utils is built for bare metal
(embedded) targets. This change is not exhaustive; more code needs to be
moved into this section as and when discovered.

The idea was suggested in #28; this commit is just small variation to
the proposed change there.

Signed-off-by: Siddharth Chandrasekaran <[email protected]>
@Sympatron
Copy link
Contributor Author

Closed in favor of #29.

@Sympatron Sympatron closed this Nov 11, 2024
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.

Embedded platforms currently not supported in libOSDP
2 participants