Skip to content

Feature/387 gpap protocol#463

Open
TheBakedPotato wants to merge 36 commits intomainfrom
feature/387-gpap-protocol
Open

Feature/387 gpap protocol#463
TheBakedPotato wants to merge 36 commits intomainfrom
feature/387-gpap-protocol

Conversation

@TheBakedPotato
Copy link
Copy Markdown
Collaborator

This is the initial implementation of the GPAP protocol.

This leverages a number of new techniques and tools that may be foreign to some. Extensive use of "return value optimization" or "copy elision" in the new GPAP module. All of the GPAP related code is stuck inside its own library file structure inside the lib/ directory. There is a README in that directory as well which explains some of the foreign concepts used.

As well, this pull request introduces the use of unit tests. The unit tests test just the new GPAP library code. I am free to answer any specific questions about the unit tests but for a good overview and tutorial the official documentation is the best source to learn about PlatformIO's unit testing system. Something that should be explicitly pointed out is the addition of the native environment in the platform.ini file. That is because these specific unit tests are compiled for the host system. They can be compiled for the esp32dev device as well but it was just easier to get it running for the host device. This does require an external C++11 (or newer) compiler on the host system. On *nix based systems this is quite often gcc which is easy enough to install. On Windows this leverages MSVC which I have no experience with getting installed.

- The union in the ProtocolMessage is now const
  - This means the individual fields don't have to be const which makes
    the implementation a lot cleaner
- The fields inside the AlarmCommand are const
  - Now instances of the AlarmCommand don't need to be const, the fields
    are always const, which it should be
  - The contents of an AlarmCommand should never change
- Moving all the constructors to just taking std::array<char, size_t>
- Removing most of the 'deserialize' methods
- Since the Copy constructor is deleted from the AlarmCommand the Move
construcctor must be used
- in the ::buildAlarmMessage() method it was not using std::move so the
returned AlarmMessage was in a invalid state
…e parts

- Since parts of the alarm message, like type designator, are optional,
needed a way to indicate they are possibly present, possibly existent
…ment operators

- Originally the move assignment operators simply returned `*this`
- The operators had to first set the data members inside the operator
and THEN return `*this`
- the portable use of `size_t` is actually `std::size_t`
- the functions `std::isdigit()` and `std::isxdigit()` belong to the
`cctype` library
- including `iostream` greatly increased the size of the binary and ram
usage
- Going back to `Printable` class but now also mocking it so it can be
used in tests
@TheBakedPotato
Copy link
Copy Markdown
Collaborator Author

I also realize now that this PR is something I would consider "quite large". It is ~1.5k LOC which is difficult on reviewers. What I can say is that a lot of it is just "boiler plate" code of defining classes, header guards, etc. So the actual "meat" of the PR is not as large but it is still getting on the side of too big for a PR.

@TheBakedPotato
Copy link
Copy Markdown
Collaborator Author

@RobertLRead I do want to address a point you made once during a discussion that full on unit tests were not entirely necessary. Well, PlatformIO makes it VERY easy to incorporate unit tests into the project and by being able to run the tests on the host system it removes the delay of having to upload a new firmware image to the board and it makes it easier if you wished to debug the code as well.

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.

Make the Krake parse and accept the GPAP protocol (with alarm number and alarm id)

1 participant