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

libsbp C headers and test stubs. #32

Merged
merged 2 commits into from
Mar 19, 2015
Merged

libsbp C headers and test stubs. #32

merged 2 commits into from
Mar 19, 2015

Conversation

mookerji
Copy link
Contributor

First pass at libsbp C headers for inclusion in libswiftnav and
piksi_firmware. Will fix formatting issues later, but need comments
for integration, etc.

/cc @fnoble @gsmcmullin @mfine @cbeighley

#define SBP_MSG_OBS 0x0045
typedef struct __attribute__((packed)) {
observation_header_t header; /**< Header of a GPS observation message */
packed_obs_content_t* obs; /**< Observations */
Copy link
Contributor

Choose a reason for hiding this comment

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

This is incorrect because pointers and arrays are not really the same. You can do something similar to this but unfortunately in C you can only express a variable length array if it is the last element of the struct (google C99 flexible array member) :(

We should probably think hard about how to deal with these kinds of constructs.

@fnoble
Copy link
Contributor

fnoble commented Mar 16, 2015

Looks good, a few thoughts:

  • Our YAML schema no longer maps onto C structs, need to think about what to do about this:
    • Generate C pack/unpack functions instead, could get messy?
  • What is going to go in the test stubs?

First pass at libsbp C headers for inclusion in libswiftnav and
piksi_firmware. Will fix formatting issues later, but need comments
for integration, etc.

/cc @fnoble
In the rare instances we're using variable-length arrays, use a
0-length array. It seems we can't use the C99 flexible array
declaration in the case where the flexible array is the only element
in the struct.
@mookerji
Copy link
Contributor Author

An update:

  1. I think this is probably good to go for testing integration.
  2. We ought to limit flexible array structs to the last element of a struct, and can check for this in the generator.
  3. I'm going to follow-up with a text specification of unit tests in the top level specs/, which we can just import into the test suite here.

@mookerji
Copy link
Contributor Author

Twenty years from now you will be more disappointed by the things you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover.

Mark Twain

mookerji added a commit that referenced this pull request Mar 19, 2015
libsbp C headers and test stubs.
@mookerji mookerji merged commit a187f0e into swift-nav:master Mar 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants