Since the PX4 code uses both px4_task and pthread APIs,
px4_getpid() must be save to call from either context.
On posix, this means we have to always return the pthread ID.
Reverted simulator change of pthread to px4_task
There may have been side effects if this was build for a target that
has process/task scoped file descriptors. It is now safe to call
px4_getpid() from this pthread context with this change for the
posix build for px4_getpid().
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
In nuttx the mode parameter to open is not required but in Linux,
and per the POSIX spec, mode is required if the O_CREAT flag is
passed.
The mode flags are different for NuttX and Linux so a new set of
PX4 defines was added:
PX4_O_MODE_777 - read, write, execute for user, group and other
PX4_O_MODE_666 - read, and write for user, group and other
PX4_O_MODE_600 - read, and write for user
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
mcu_unique_id() reads registers at an invalid address in non-nuttx builds.
Added ifdef to return a dummy value for non-nuttx builds.
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
The simulator was using pthread APIs directly so calls to px4_getpid()
would fail since the task ID was not known. Changed simulator to use
px4_task_spawn_cmd.
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
If the posix target is run and the rootfs is not created, then
there is an fopen in mavlink without a return value check and then a write
to the fd. When this condition occurs it tries to write to NULL and will
segfault.
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
The default rootfs is now in:
Build/posix_default.build/rootfs/
The subdirs fs/microsd and eeprom are now created if they do not exist.
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Set a default path relative to current dir for the posix target.
Running make posixrun will create the required directoroes and then run
mainapp from its build location.
PX4_ROOTFSDIR is set to nothing for nuttx.
Signed-off-by: Mark Charlebois <charlebm@gmail.com>