API Documentation v0.0.1
|
This manual is about writing software for the OpenHornet project. It shows how to write, document and test your software.
The starting point of every new software sketch is the OHSketchTemplate folder. Please copy the whole folder. There is a Makefile included which defines the target board and libraries needed for your sketch. Once copied delete the sample function from the OHSketchTemplate.ino. Then change all the @tags with your own information.
The Sketches are named according to the reference designator found in the OH-INTERCONNECT document. The first part of the name is the OH No. found in the drawing. It is the number beneath the Board type.
e.g: 1A2 for the Master Arm Panel.
The No. is followed by a minus sign "-" (without space). Then the name of the component the sketch is for. The name is written in uppercase and with underscores "\_" instead of spaces.
e.g: 1A2-MASTER_ARM_PANEL for the Master Arm Panel.
If the Sketch is for more than one component. Meaning that the board controls more than one component, use the name of the first component the sketch is for.
It is imperative that all the code you write is documented. We use doxygen as API documentation generator. So all the comments have to be doxygen compatible. Otherwise they will not show up in the documentation.
We use Javadoc style comment markup. Since it is the easiest to read for humans.
The following is an example of how to document code:
This is the standard file header of OH. It has to be used as is in every sketch written for the OH Software.
The Sketch summary comments should be on top of the file, right after the Header and looks like this:
The elements in the summary are the following:
The @file has to have the exact same name as the filename. Including the file extension.
The author of the Sketch. If more than one person was working on the sketch, the authors shall be listed in a comma separated list. With the original author at first place.
The date the sketch was last modified.
The version of the sketch. To see how the versioning of sketches works, see "Versioning" in this document.
Every untested sketch has to have a "This sketch is based on a wiring diagram, and was not yet tested on hardware" warning.
A brief description of the sketch.
A more detailed description of the sketch
This is the hardware that this sketch is intended to run on.
A quick reference showing connections to this PCB, for ease of reference when reading this code.
Function documentations should look like this:
Doxygen then takes this and generates a Function documentation looking like this:
Functions should be commented as seen above. It is important that every function you write is commented like this. Otherwise it will not show up in the API documentation. The comment structure is as followed:
The comment has to start with /**
and then a new line with a single *
. Then you write a very short description of what the function will do. The short description has to end with a dot .
or a blank like.
This is the main description of your function. Write in detail what your function does.
Each parameter the function uses is documented with a @param
tag. After the tag there is a space and then the name of the parameter. Then another space and then the description of the parameter.
The return parameter, if there is any, is documented with a @returns
parameter. The return parameter needs no name. So after a space you can write the description of the parameter.
The insides of a function are a black box to doxygen. It is important that you comment the code inside a function nevertheless. This has to be done for other coders who might have to work with your code. Comments inside a function are done with a simple //
before the comment.
All sketches who run as slave on the RS485 bus have to have a slave ID (DCSBIOS_RS485_SLAVE). That slave ID has to be unique on the RS485 bus the sketch runs on. But they can be the same for different buses (Every RS485 master has it's own bus). The slave ID is given according to the BUS ADDR in the interconnect.
e.g 1A2A (Master Arm Panel) shall be Bus Address 1
The version number consists of three digits.
eg: 1.4.2
Those three numbers are release.feature.change
Sketches who are untested have to have a leading "u" before the version number and "(untested)" behind the version no.
eg: u.1.4.2 (untested)
Since the OpenHornet project targets multiple Arduino boards and libraries, the Makefile
located in each sketch directory is necessary to determine which specific Arduino board and libraries are needed for each component.
LIBRARIES
is a space-separated list of libraries to include in your sketch. These must first be added as a git sub-module in the /libraries
folder of the project. See Arduino Libraries
The appropriate board Makefile must be included at the end of the file. Valid options are:
The Makefile will be used by Github Actions to verify that code will compile without errors. Once successful, a downloadable zip file will be created with the compiled firmware which can be flashed to the desired board.
Before you upload anything, please check if your sketch compiles in your Arduino editor. If it does, check if doxygen compiles with your local doxygen installation.
Once those local tests are successfully, open a PR to the OpenHornet-Software repo's develop branch and see if the CI/Doxygen tests are successful. If they are, then request your PR to be reviewed.
Github Actions is a continuous integration testing engine. It is connected with the OpenHornet Github repository. When a Pull request is opened or merged, Github Actions will checkout the git repo and attempt to compile the code. If the code compiles successfully and there where no errors detected, it automatically updates the Doxygen documentation and uploads it back to the repo.
The OpenHornet software projects makes use of git submodules to include and link to other software libraries which are used in Arduino sketches to provide additional functionality. Most git frontends and tools support git submodules although options differ between each.
Arduino Libraries which are included in your sketch need to be added as a (git submodule)[#Git-Submodules] to the repository and then referenced in the Makefile for the sketch. You can find a list of already included libraries in the "Supported Software" section of this manual. If you need another library, please add it using git submodule add https://github.com/<organization>/<project>.git
under the /libraries
directory.
Libraries are downloaded during each Github Actions run and made available to the sketch when compiling. Ensure that the libraries are referenced in the Makefile using the same name that they exist in the /libraries
folder.