Sometimes code paths are crossed when they shouldn't be. This method
can help in the short term if a codepath is calling methods on a
Location when it is not initialised, but generally a vehicle should be
calling position_ok() and other methods rather than this one.
Move attribute definitions all into AP_Common, rather than being split between two files
Remove unused SITL_printf macros
Stop AP_Common including board information
Include AP_Common.h in AP_HAL::Sempahore for WARN_IF_UNUSED; this was the cause of a circular import problem fixed by other commits in this patch.
This has the advantage of telling you what the sizes are
In file included from ../../libraries/AC_AttitudeControl/AC_PosControl.h:3:
../../libraries/AP_Common/AP_Common.h:103:3: fatal error: static_assert failed "wrong size"
static_assert(s == t, "wrong size");
^ ~~~~~~
../../libraries/AP_Common/AP_Common.h:147:52: note: in instantiation of template class 'assert_structure_size<12, 11>' requested here
assert_structure_size<sizeof(struct Location), 11> _assert_location_size;
Let the variable have a random name since we are not going to reference
it. This allows more than one WITH_SEMAPHORE() per context and also to
avoid shadowing if we open inner contexts.
We don't need the specialized one inside WithSemaphore, so use the
abstract one which allows us to more easily convert between current API
and the HAL_Semaphore one.
While at it also remove additional pragma and allow constructor to
receive a pointer for convenience (we will just dereference it).
This rolls back to the simpler version of ARRAY_SIZE. The more complex
one helps catching bugs when we use pointers when we are expecting an
array, but can't stand arrays with 0 elements. I'm not aware of bugs it
actually caught on ArduPilot, although it did for me in other projects.
I think this is better than having a separate "_SIMPLE" version of the
macro and spread its usage... the trend is just to use the simpler
version anyway.
RC_Channel: To nullptr from NULL.
AC_Fence: To nullptr from NULL.
AC_Avoidance: To nullptr from NULL.
AC_PrecLand: To nullptr from NULL.
DataFlash: To nullptr from NULL.
SITL: To nullptr from NULL.
GCS_MAVLink: To nullptr from NULL.
DataFlash: To nullptr from NULL.
AP_Compass: To nullptr from NULL.
Global: To nullptr from NULL.
Global: To nullptr from NULL.
We currently check examples are buildable with waf which doesn't need
the libraries to be specified in a make.inc file. Having the makefiles
there is misleading since people try to build and realize the build is
broken.
Add system's polling infrastructure to be notified whenever a
file descriptor is ready to be read from or written to.
Adds a few classes:
* Poller, as an interface to epoll()
* Pollable, as an interface to a file descriptor
Add DEFINE prefix, since this macro is defining these operators and
remove the parameter since we will always use it to access a
union/struct as a byte array.
Revert these commits:
"AP_Common: gcc 4.9.2 behaves differently from 4.9.3"
"AP_Common: this workaround for missing/cmath is also needed for gcc 4.9.3"
This breaks the build for PX4. The change is related to the libc, not
the compiler version. We have an workaround there based on compiler
version just because it's usual to have a more recent libc version when
you have a recent compiler.
The way the build was fixed for gcc >= 5.3 breaks the build for older
compiler versions on waf. Fix this by ifdef'ing for WAF_BUILD and
checking the compiler version.
The new function can deal with a variable number of function parameters.
Additionally, I renamed the functions to norm(), because this is the
standard name used in several other projects.
This header is used by waf to contain the generated version macros,
particularly using the git hash. For waf it's better to be in a separate
header since it then can keep track of changes on it a trigger
recompilation.
For the make build system, a dummy ap_version.h file has been added in
the missing/ folder so both implementations can co-exist.
Add a cstddef header to allow using std::nullptr_t with those toolchains
that don't provide it. The idea is to make these platforms to use our
wrapper header (see https://gcc.gnu.org/onlinedocs/cpp/Wrapper-Headers.html)
and then we add the missing bits to the header.
Let the warning flag be added by the build system and not when/if the
header AP_Common.h is included. Both waf and make were already updated
to contain these warnings. Besides being in the wrong place, with
clang++ we actually can't add "-Wno-" definitions in build system
because we enable all of the in the header with -Wall.
As commented in 8218140 ("AP_Common: add scanf format macro"), "FORMAT"
was a bad name for this macro since there's also the scanf. Rename to
FMT_PRINTF to follow the scanf name.
Add a macro to annotate functions that act like scanf. Calling the
printf format macro as FORMAT was bad as can be seen now. Later we need
to rename it to FMT_PRINTF.
The PSTR is already define as a NOP for all supported platforms. It's
only needed for AVR so here we remove all the uses throughout the
codebase.
This was automated with a simple python script so it also converts
places which spans to multiple lines, removing the matching parentheses.
AVR-specific places were not changed.
Instead of requiring every program to specify the HAL related modules,
let the build system do it (in practice everything we compiled depended
on HAL anyway). This allow including only the necessary files in the
compilation.
The switching between different AP_HAL was happening by giving different
definitions of AP_HAL_BOARD_DRIVER, and the programs would use it to
instantiate.
A program or library code would have to explicitly include (and depend)
on the concrete implementation of the HAL, even when using it only via
interface.
The proposed change move this dependency to be link time. There is a
AP_HAL::get_HAL() function that is used by the client code. Each
implementation of HAL provides its own definition of this function,
returning the appropriate concrete instance.
Since this replaces the job of AP_HAL_BOARD_DRIVER, the definition was
removed.
The static variables for PX4 and VRBRAIN were named differently to avoid
shadowing the extern symbol 'hal'.
Now that most places in the code use the ARRAY_SIZE macro instead of
coding it by hand, let's use some type safety in its definition. This is
a C++ version of similar macros used in kmod, Linux kernel and the
source of them, ccan.
A C++ version like this is used in V8 (the JS engine) and other open
source projects.
The main benefit of this version is that you get a compile error if you
pass in a variable that's not an array. For example,
Bla y[10];
Bla *y_ptr = y;
void foo(Bla x[])
{
// build error since x[] decay to a pointer in function
// parameter
for (int i = 0; i < ARRAY_SIZE(x); i++) {
...
}
// build error since y_ptr is not an array
for (int i = 0; i < ARRAY_SIZE(y_ptr); i++) {
...
}
}
I added the additional specialization to allow arrays of size 0.
This commit changes the way libraries headers are included in source files:
- If the header is in the same directory the source belongs to, so the
notation '#include ""' is used with the path relative to the directory
containing the source.
- If the header is outside the directory containing the source, then we use
the notation '#include <>' with the path relative to libraries folder.
Some of the advantages of such approach:
- Only one search path for libraries headers.
- OSs like Windows may have a better lookup time.