Commit Graph

1005 Commits

Author SHA1 Message Date
Lucas De Marchi 0990fc4400 AP_HAL_Linux: send warning to stderr 2018-09-19 23:21:13 -07:00
Peter Barker 220a3d19bf AP_HAL_Linux: do not attempt to run examples realtime unless root 2018-09-19 22:40:20 -07:00
Peter Barker 43c07259f3 AP_HAL_Linux: break out init_realtime 2018-09-19 22:40:20 -07:00
Lucas De Marchi ad8ab97725 AP_HAL_Linux: SPIDevice: compile out debug stuff
This should at most be behind a flag. If the device is being used by
other process/drivers, it's a problem with that specific user/distro:
don't penalize everybody else. Besides, changing the mode is not atomic
and nothing guarantees the other side doesn't get scheduled and change
it back before we get to run.
2018-09-08 09:47:33 -07:00
Lucas De Marchi 2c6dd64c67 AP_HAL_Linux: create one thread per spi bus rather than device
Do not create one thread per chardev (i.e. bus + kernel's chip select).
Since the shared resources are actually the bus controller and the bus
lines, it makes sense to have 1 thread per bus, otherwise it will just
get locked again on the mutex in the kernel side.
2018-09-08 09:47:33 -07:00
Lucas De Marchi cf4fb09881 AP_HAL_Linux: Remove hole from SPIBus
Also handle a few coding style bikesheds.
2018-09-08 09:47:33 -07:00
Lucas De Marchi 4152b555fd AP_HAL_Linux: replace kernel_cs with subdev
They are the same thing. Using both names however is confusing.
2018-09-08 09:47:33 -07:00
Francisco Ferreira 5b383bae16
AP_HAL_Linux: force Thread stack to have minimum size
Check that Thread stack size is the minimum allowed

Also add 256k to HAL-independent request stack size
2018-09-06 19:07:13 +01:00
Peter Barker 42c711a5b2 AP_HAL_Linux: remove pointless attach_interrupt override 2018-08-31 08:32:08 +10:00
Andrew Tridgell b347027e13 HAL_Linux: added Semaphore_Recursive 2018-08-25 15:44:36 +10:00
Peter Barker 8d5a9ead48 AP_HAL_Linux: attach_interrupt now takes a functor
AP_HAL_Linux: add type-safety for interrupt types
2018-08-21 20:34:01 +09:00
Andrew Tridgell f1e10b0a8f HAL_Linux: make uart writes thread safe 2018-08-16 12:40:10 +10:00
Andrew Tridgell f005e60066 HAL_Linux: added support for HAL_Semaphore type 2018-08-16 12:40:10 +10:00
Lucas De Marchi 5068f2e8fd AP_HAL_Linux: fix log after tonealarm thread removal
../../libraries/AP_HAL_Linux/Scheduler.cpp: In member function ‘void Linux::Scheduler::_debug_stack()’:
../../libraries/AP_HAL_Linux/Scheduler.cpp:127:47: warning: format ‘%zu’ expects a matching ‘size_t’ argument [-Wformat=]
                 _uart_thread.get_stack_usage());
                                               ^
2018-08-12 20:29:35 -07:00
Francisco Ferreira 1d7f3e48a4
AP_HAL_Linux: remove CAN thread management
Also fix comment
2018-08-12 13:35:01 +01:00
Andrew Tridgell 03b7c08be6 HAL_Linux: added duration to toneAlarm_set_buzzer_tone
required for disco
2018-07-30 14:02:12 +10:00
Jonathan Challinger ddf0333a24 AP_HAL_Linux: reflect changes to tonealarm interface 2018-07-30 14:02:12 +10:00
Aaron Wang Shi 1304d37699 AP_HAL_Linux: fix bhat GPS SPI conflict 2018-07-24 11:28:22 -07:00
Aaron Wang Shi 4f2d9c2c4d AP_HAL_Linux: support PWM input for BH hat 2018-07-20 00:32:55 -07:00
Michael du Breuil 2e135f4fc4 AP_HAL_Linux: Remove unused ADC include 2018-07-17 09:29:50 +10:00
Michael du Breuil 0aaa029f9b AP_HAL_Linux: GPIO_RPi: Fix UB when reading a pin
You can't shift by more then the word width
2018-07-11 23:09:52 -07:00
Michael du Breuil 1f7ee55211 AP_HAL_Linux: Remove GPIO::analogPinToDigitalPin() 2018-07-11 23:09:52 -07:00
Andrew Tridgell 1d1af5fd68 HAL_Linux: don't clear buffers on no baud change 2018-07-12 11:41:31 +10:00
Lucas De Marchi d2446e1219 AP_HAL_Linux: use Thread abstraction to create thread
The open coded version has the same problem fixed by Thread abstraction:
the order of the calls matters and it's easy to call in the wrong order.
Here pthread_attr_setschedparam() and pthread_attr_setschedpolicy()
should be swapped, like in 62c2f737d5 (AP_HAL_Linux: fix setting RT priorities.)
2018-07-11 10:00:29 +10:00
Lucas De Marchi e11d268818 AP_HAL_Linux: Thread: allow loose running thread 2018-07-11 10:00:29 +10:00
Jack 4b24a61023 AP_HAL_Linux: fix spelling of generated in panics 2018-07-10 09:55:01 -07:00
Andrew Tridgell 070e3cf37b HAL_Linux: implement I2C bus masks 2018-07-10 15:39:47 +10:00
Andrew Tridgell 492978c0fa HAL_Linux: removed restriction on delay in threads
threads other than the main thread should be able to sleep, but not
call the delay callback
2018-07-09 19:41:18 +10:00
Andrew Tridgell 9918ae3209 HAL_Linux: implement thread_create() 2018-07-09 19:41:18 +10:00
Andrew Tridgell 9ae6734469 HAL_Linux: support uartG 2018-06-29 08:17:38 +10:00
Lucas De Marchi 49d08ba72a Global: remove minlure
Minlure is a port of ArduPilot to Minnow Board connected to daughter
board. Very few of those were produced and nobody is flying with it.

It served its purpose and all the the improvements to ArduPilot remain
regardless of it not being supported anymore. Now it's just adding
maintenance work with no clear benefit, so pull the plug.
2018-06-26 07:32:08 -07:00
Lucas De Marchi d31e85e738 AP_HAL_Linux: fix copy and paste error on gpio table 2018-06-26 07:32:08 -07:00
Michael du Breuil 7043738f3b AP_HAL_Linux: Clear UART buffers when opening a port 2018-06-26 02:18:18 +01:00
Hyungsub 97b93920b3 AP_HAL_Linux: fix memory leaks
Fixes #8642
2018-06-18 10:30:56 +01:00
Peter Barker c9dbdd7a5c AP_HAL_Linux: clarify method name, use common methods for setting time 2018-06-15 08:01:22 +10:00
Eugene Shamaev 7dd8308a8c AP_HAL_Linux: reducing indenting by linearizing the logic 2018-06-09 22:46:48 -07:00
mirkix b32b57ad75 AP_HAL_Linux: change SPI Bus for PocketPilot final design 2018-06-07 12:28:21 -07:00
Michael du Breuil 80d1a1de9a AP_HAL_Linux: Remove timer process suspension interface 2018-06-06 07:16:58 +10:00
Michael du Breuil 737c4ac36f AP_HAL_Linux: Remove RC overrides 2018-06-05 09:51:09 +10:00
Lucas De Marchi 88dc17fe6e AP_HAL_Linux: Storage: fix initialization
Use init() to lazily create/open storage directory and keep fd open
afterwards. This avoids duplicate code opening the storage in several
places.
2018-05-24 08:00:33 -07:00
Lucas De Marchi 1f3b7b5687 AP_HAL_Linux: Storage: fix writing garbage while creating file
By the time we create the storage we hadn't still initialized the
buffer. Remove the writes during storage creation since ftruncate() will
take care of the file size aspect and MAX storage write chunk is taken
care by Linux according to the media/fs that is there.
2018-05-24 08:00:33 -07:00
Lucas De Marchi 5526997d45 AP_HAL_Linux: Storage: prefer custom storage
If ardupilot was started with --storage-directory option, use that
directory to save/load parameters.
2018-05-24 08:00:33 -07:00
Lucas De Marchi ff6e76ea6a AP_HAL_Linux: add custom storage directory 2018-05-24 08:00:33 -07:00
Lucas De Marchi 9e538632b3 AP_HAL_Linux: use AP_HAL_STORAGE_DIRECTORY
Add mkdir_p implementation copied from kmod and create the directory
with all possible components.
2018-05-24 08:00:33 -07:00
Andrew Tridgell b396b2a2e0 HAL_Linux: take account of available bytes in receive_time_constraint_us 2018-05-21 14:53:18 +10:00
Francisco Ferreira 5e821428a1 AP_HAL_Linux: remove Qualcomm board support 2018-05-17 09:57:20 +10:00
Andrew Tridgell b8eeac41c8 HAL_Linux: implement uart timestamp API 2018-05-16 18:49:22 +10:00
Michael du Breuil 517e20093e AP_HAL_Linux: Remove set_overrides() method 2018-05-11 12:13:39 +01:00
mirkix 95fbc222d5 AP_HAL_Linux: enable GPIOs for PocketPilot 2018-05-09 16:16:42 -07:00
Peter Barker d5cad015dc AP_HAL_Linux: move delay callback handling to base HAL Scheduler class 2018-05-09 16:15:38 +10:00
Andrew Tridgell 4404c95cc8 HAL_Linux: use ceilf() 2018-05-07 11:43:23 +10:00
Lucas De Marchi b1b4b66e65 AP_HAL_Linux: minlure: fix uart path
In some point in past it may have been ttyS2, but right now on kernel
4.16+ the UART is on ttyS5. We could do like is done for I2C and search
on sysfs, but it requires additional changes.
2018-05-04 11:47:04 -07:00
Lucas De Marchi 320db1d79b AP_HAL_Linux: remove unused i2c devpaths 2018-05-04 11:47:04 -07:00
Lucas De Marchi 2000e17646 AP_HAL: move get_device() method from AP_HAL_Linux
This way it's possible to use the method in platform-independent code
without a need to up cast.
2018-05-04 11:47:04 -07:00
Lucas De Marchi 4f2498947b AP_HAL_Linux: remove redundant ifdef
CONFIG_HAL_BOARD_SUBTYPE should be set in the boards header.
2018-05-04 11:42:55 -07:00
mirkix 0c353d2af0 AP_HAL_Linux: change PocketPilot to final baro sensor 2018-05-04 08:00:49 +10:00
mirkix 598ae5c3f7 AP_HAL_Linux: PocketPilot: change pru to final design 2018-05-04 08:00:49 +10:00
Mark Whitehorn 7ad0318d4f AP_HAL_Linux: fix latent bug in ToneAlarm 2018-04-10 21:48:16 +10:00
Lucas De Marchi cf3a9cddc8 AP_HAL_Linux: fix build error with flexible array
Apparently this code came in part from libuavcan that defines this
struct Control. They also had the same issue detailed on
https://github.com/UAVCAN/libuavcan/issues/116.

The solution here is much simpler though: stick to the design of cmsg()
even if it's C. As per cmsg(3), use a union together with CMSG_SPACE().
2018-03-22 00:49:58 -07:00
chobits 15b8ae99fe AP_HAL_Linux: fixed AP_MODULE_SUPPORTED on static build 2018-03-02 10:13:19 +11:00
mirkix 234dcc1939 AP_HAL_Linux: fix BeagleBone Blue voltage divider 2018-02-23 18:35:55 +10:00
Lucas De Marchi 755b1cdced AP_HAL_Linux: rpi: sort include headers 2018-02-12 09:05:21 -08:00
Lucas De Marchi 90160a9c52 AP_HAL_Linux: rpi: use const var and fix formatting
Use a const variable instead of a define so we don't polute the
environment with a define specific to this function.

Also remove tabs and replace with proper coding style.
2018-02-12 08:46:36 -08:00
Dmitri Ranfft 05ebabbf6b AP_HAL_Linux: fixed RPi version detection on kernel 4.9 2018-02-12 08:36:58 -08:00
Siddharth Purohit a55f1c85af HAL_Linux: add support for api change in AP_HAL::CANManager 2018-02-07 20:33:45 +11:00
Andrew Tridgell 26161ee467 HAL_Linux: Storage::_timer_tick is an override 2018-02-07 20:33:45 +11:00
Andrew Tridgell 22de99dd58 HAL_Linux: implement _timer_tick in UARTDriver 2018-02-07 20:33:45 +11:00
mirkix bf758098d7 AP_HAL_Linux: fix deallocation 2018-02-05 11:05:12 +11:00
mirkix c5eb52bf8d AP_HAL_Linux: fix comment 2018-01-23 13:32:12 -08:00
mirkix 700171a0fc AP_HAL_Linux: add second RCIN port for Blue 2018-01-17 15:25:51 -08:00
Nikita Tomilov 1549b1a52a AP_BoardConfig: CAN: Merge PX4 and Linux CAN setup
Here we merge PX4 and Linux CAN bus setup since the interface is almost
the same for both of them.
2018-01-17 07:24:17 -08:00
Tom Pittenger d713d57904 AP_HAL_Linux: update software license referencing UAVCAN submodule 2018-01-17 07:24:17 -08:00
Nikita Tomilov 3ac2e4e8c5 AP_HAL_Linux: CAN: _pollRead no more than 100 iterations
This adds a counter here to only loop to a maximum number of iterations.
Now we avoid situations in which we would be stuck processing packets here.
This also adds some other meaningful defines
2018-01-17 07:24:17 -08:00
Nikita Tomilov 43bfcbc8e2 AP_HAL_Linux: CAN: Rename CANDriver -> CANManager 2018-01-17 07:24:17 -08:00
Nikita Tomilov d0fc481202 AP_HAL_Linux: CAN: Rename Linux::LinuxCAN -> Linux::CAN 2018-01-17 07:24:17 -08:00
Alexey Bulatov e0acbd3e53 AP_HAL_LINUX: Add CAN to timer_task 2018-01-17 07:24:17 -08:00
Nikita Tomilov a50e6c6dd7 AP_HAL: board: linux: Add default CAN interface name 2018-01-17 07:24:17 -08:00
Nikita Tomilov b6665f7e58 AP_HAL_Linux: CAN: get rid of RaiiCloser 2018-01-17 07:24:17 -08:00
Alexey Bulatov 976500960f AP_HAL_LINUX: Add CAN driver 2018-01-17 07:24:17 -08:00
Andrew Tridgell 8fea99e1da HAL_Linux: use calloc in preferance to malloc 2018-01-17 11:22:05 +11:00
Andrew Tridgell 43c1bd0ae9 HAL_Linux: fixed I2C get_device() interface
just stubs for now
2018-01-15 11:46:02 +11:00
mirkix 8d7000db2c AP_HAL_Linux: fix typo 2018-01-09 12:54:03 -08:00
mirkix 9b6a826b49 AP_HAL_linux: add new board PocketPilot 2017-12-27 16:01:55 +00:00
mirkix eecd8fcfa6 AP_HAL_Linux: Add VOLTAGE_SCALING for BeagleBone Blue 2017-12-19 09:17:06 +11:00
mirkix 26f3a62db7 AP_HAL_Linux: remove BBBmini from RCInput_PRU.cpp 2017-12-14 12:40:37 -08:00
HeBin 0e1ce2a7fd AP_HAL_Linux: add Robsense PhenixPro Devkit Board support 2017-11-22 10:10:21 -08:00
Georgii Staroselskii 56534b34c5 AP_HAL_Linux: use GPIO_Sysfs for Navio
/boot/config.txt: dtoverlay=navio-rgb should be disabled for this thing
to work, though.
2017-11-17 09:20:55 -08:00
Georgii Staroselskii 5254ee03c2 AP_HAL_Linux: use GPIO_Sysfs for Edge 2017-11-17 09:18:36 -08:00
Georgii Staroselskii 8fcd30c611 AP_HAL_Linux: use GPIO_Sysfs for Navio 2 2017-11-17 09:18:35 -08:00
alexshirley 8058fdf093 AP_HAL_Linux: combine ppm and sbus on ocpoc_zynq
Removes compile-time selection of RCInput driver for ocpoc_zynq.
PPM and SBUS input are now colocated on the ocpoc board, and it
only needs to run RCInput_ZYNQ. Pulse input is also inverted
to accommodate SBUS input, which has no effect on PPM input.
2017-11-01 10:28:40 -07:00
Lucas De Marchi cbb9dcc2a1 AP_HAL_Linux: Storage: use define from HAL for directory 2017-10-30 16:57:37 -07:00
Georgii Staroselskii 79c14a92a9 AP_HAL_Linux: adapt Heat_Pwm for Edge 2017-10-20 13:03:08 -07:00
Georgii Staroselskii 4e6fab228c AP_HAL_Linux: add SPI devices for Edge 2017-10-20 13:03:08 -07:00
Staroselskii Georgii 3ade179700 AP_HAL_Linux: make use of RCInput_Navio2 in Edge 2017-10-20 13:03:08 -07:00
Staroselskii Georgii 2a99bb0c95 AP_HAL: use Raspberry Pi GPIO and Util classes for Edge
As it's a yet another Raspberry Pi based board, we may reuse the code.
2017-10-20 13:03:08 -07:00
Staroselskii Georgii 2a7e8d66ee AP_HAL_Linux: add Edge support
Just some usual boilerplate code.
2017-10-20 13:03:08 -07:00
Georgii Staroselskii 2dd68243a2 AP_HAL: add Edge support 2017-10-20 13:03:08 -07:00
Georgii Staroselskii d214a36e0a AP_HAL_Linux: reset duty cycle before setting period
On kernels 4.7+ duty_cycle should always be less than period.
Otherways, we'll get a EINVAL.

It makes sense to set duty_cycle to 0, as
duty_cycle doesn't really make sense without a proper period.

A proper way to handle these errors might be to call pwm_adjust_config
in every pwmchip backend but it's unrealistic to hope that all vendors
will do it quickly.
2017-10-17 13:28:34 -07:00
Lucas De Marchi 4d5aed1d69 AP_HAL_Linux: UARTDevice: never be the controlling terminal
If we are the controlling terminal for a tty device we will receive a
SIGHUP when the device disappears. Currently what happens is that we
simply stop the whole process. We don't want to fall off the sky due
to a bad device. This can happen for any reason, but it's more likely
if the UART is behind a USB connection.
2017-10-02 11:05:09 -07:00
Lucas De Marchi 5ebc8c2cb3 AP_HAL_Linux: ToneAlarm: ifdef out bogus message
These messages are only valid in a small subset of Linux boards (those
based on BBB and variants).  The ToneAlarm class should actually be
split allowing different implementations, but for now let's just disable
the message.
2017-09-28 09:00:26 -07:00
Aaron Wang Shi 6a82e3aecd AP_HAL_Linux: Add debug message in RCInput_RPI _timer_tick() 2017-09-25 21:11:56 -07:00
Aaron Wang Shi ccde7cfdd4 AP_HAL_Linux: Restart RCInput_RPI DMA sampling if it stops 2017-09-25 21:10:54 -07:00
Lucas De Marchi 3847825fba AP_HAL_Linux: make Aero use Tap ESC
This allows controlling the motors from Linux on Intel Aero RTF given
the right FPGA firmware is in place.
2017-09-21 07:59:20 -07:00
Peter Barker 044cac42e8 AP_HAL_Linux: make in_main_thread const and override 2017-09-19 09:40:11 +10:00
Lucas De Marchi 7ba82ff23a AP_HAL_Linux: remove raspilot
It's not being sold, there are just a few (different) engineering
samples built and there are no plans for this to go forward for people
that were pushing it.
2017-09-12 15:06:19 -07:00
Francisco Ferreira 4398be2275 AP_HAL_Linux: remove URUS 2017-09-11 10:04:11 -07:00
davidaroyer 7d2e44862f AP_HAL_Linux: add support for Aerotenna OcPoC-Zynq hardware 2017-09-08 07:30:49 -07:00
Georgii Staroselskii e79fc893fa AP_HAL_Linux: HAL_Linux_Class: delay SPIUARTDriver static initialization
There's an implicit (apart from the name) dependency between SPI and
SPIUARTDriver which results in a crush on a restart or a shutdown.

By moving the initialization we're making sure that all objects are
deleted in the right order.
2017-09-08 07:26:54 -07:00
Georgii Staroselskii 226eeeb738 AP_HAL_Linux: RCOutput_Sysfs: fix deleting _pwm_channels array
delete [] should be called rather than delete.
2017-09-08 07:26:54 -07:00
Georgii Staroselskii f6858821a6 AP_HAL_Linux: PWM_Sysfs: remove unneeded free() in ~PWM_Sysfs_Base
_export_path and _duty_path will have been already long time gone by the
time dtors kick in.

Probably better to use OwnPtr around those. But it's better to be done
in a separate PR.
2017-09-08 07:26:54 -07:00
Lucas De Marchi 66a1e420cb AP_HAL_Linux: RCInput_SoloLink: better name to first field
Checking the time on the tcpdump capture, it matches the first fields
from the data:

$ tshark -n -c 4 -r  ~/tmp/solo/rc.pcap
    1   0.000000     10.1.1.1 → 10.1.1.10    UDP 68 5005 → 5005 Len=26
    2   0.019976     10.1.1.1 → 10.1.1.10    UDP 68 5005 → 5005 Len=26
    3   0.040046     10.1.1.1 → 10.1.1.10    UDP 68 5005 → 5005 Len=26
    4   0.059961     10.1.1.1 → 10.1.1.10    UDP 68 5005 → 5005 Len=26

From the previous commit (first 2 packets):

     5fa8 f441 3414 0500 73d7  dc05 dc05 dc05 db05 e803 e803 e803 f401
     73f6 f441 3414 0500 74d7  dc05 dc05 dc05 db05 e803 e803 e803 f401

0x0005143441f45fa8 - 0x0005143441f4f673 = 0x4E14 = 19988 (usec)

Which seems to approximately match for the other packets as well. We are
not using the field since we rather get the time when we receive it, but
at least use a better name.
2017-08-17 12:04:27 -07:00
Lucas De Marchi 373d41fd6e AP_HAL_Linux: switch aero to RCInput_SoloLink 2017-08-17 12:04:27 -07:00
Lucas De Marchi 79b004cf6a AP_HAL_Linux: add prototype for handling SoloLink
This allows to use a Solo controller to control Linux-based flight
controllers. The protocol has been derived by analyzing a tcpdump
trace: some fields are ignored. Example trace of RC data (obtained
with `tshark -T fields -e data -n -c 5 -r  rc.pcap`

 unkonwn              seq   ch1  ch2  ch3  ...                ch8
 5fa8 f441 3414 0500 73d7  dc05 dc05 dc05 db05 e803 e803 e803 f401
 73f6 f441 3414 0500 74d7  dc05 dc05 dc05 db05 e803 e803 e803 f401
 dc44 f541 3414 0500 75d7  dc05 dc05 dc05 db05 e803 e803 e803 f401
 bc92 f541 3414 0500 76d7  dc05 dc05 dc05 db05 e803 e803 e803 f401
 dfe0 f541 3414 0500 77d7  dc05 dc05 dc05 db05 e803 e803 e803 f401
2017-08-17 12:04:27 -07:00
Peter Barker 23d91c93c8 AP_HAL_Linux: correct compilation warning
../../../libraries/AP_HAL_Linux/RCInput_RPI.cpp:129:35: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
         ::read(file, &pageInfo, 8);
2017-08-17 11:28:36 +01:00
Lucas De Marchi 5ea1784838 global: remove AP_HAL::in_timerprocess()
This is not used and in the only places it would make sense would be
internally to the scheduler so remove it.
2017-08-03 20:25:14 -07:00
Lucas De Marchi 93a558ce5c AP_HAL_Linux: do not call delay callbacks on other threads
If a thread other than the main one calls Scheduler::delay() we could
end up triggering the call of delay callbacks. Those should only ever
happen on the main thread.
2017-08-03 20:24:57 -07:00
Lucas De Marchi c170c2a847 AP_HAL_Linux: remove register_timer_process with extra arg
This is not used anymore.
2017-08-02 08:00:53 -07:00
Lucas De Marchi 0a158f6d3f AP_HAL_Linux: remove support for timesliced timer
This has long been replaced by the bus per thread scheme.
2017-08-02 08:00:53 -07:00
Siddharth Bharat Purohit d1e0f9733e HAL_Linux: use correct datatype for time conversion 2017-07-13 18:23:00 -07:00
Andrew Tridgell 9868ffe13b HAL_Linux: support receiver based RSSI 2017-07-03 11:22:21 +10:00
Lucas De Marchi ee0f46e3aa AP_HAL_Linux: RCInput_RPI: ignore unwanted signals
We are setting a termination handler for some signals which are of not
interest.  Just ignore them.  Ignoring SIGWINCH allows for example to
run on a screen and change the window size later without killing
ardupilot.
2017-05-23 09:09:51 +10:00
Lucas De Marchi e803045d1f AP_HAL_Linux: Scheduler: increase stack for scheduler threads
RPI-based boards that use RCInput_RPI need more stack space otherwise we
end up with stack corruption. This leads to crash particularly when also
using GPIO_RPI since it may change what that driver is poking on memory.

This increases stack size to 1M which is overkill for most of other
boards with a more controllable stack usage. However this exposes that
on multiple different HWs a single point for stack size decision may not
be the best.  This can be improved in future.
2017-05-23 09:09:51 +10:00
Peter Barker c78f3b9e78 AP_HAL_Linux: use HAL_SEMAPHORE_BLOCK_FOREVER macro 2017-05-08 10:23:03 +09:00
Andrew Tridgell 279c1b9d9c AP_HAL_Linux: rename macros to avoid conflicts
these macros were also defined in NuttX in clock.h
2017-05-06 15:21:14 +10:00
Peter Barker 5a02219642 AP_HAL_Linux: use HAL_SEMAPHORE_BLOCK_FOREVER 2017-05-01 15:05:51 +01:00
Andrew Tridgell 9b297ef5a1 HAL_Linux: fixed nested cork/push
don't generate extra pulse sets if we nest
2017-05-01 14:32:18 +10:00
Lucas De Marchi 875538ccb5 AP_HAL_Linux: examples: small fixes to BusTest
- Fix char allocation
  - Fix coding style
  - Fix accessing dev->bus_type(): it's a function
2017-04-19 01:13:40 -07:00
hiro2233 0d1d430600 AP_HAL_Linux:examples: Example to test device bus with the new APM API. 2017-04-19 01:05:12 -07:00
hiro2233 be06c1e8ed AP_HAL_Linux:SPIDevice: Add functions to get possible spi registered device 2017-04-19 01:05:12 -07:00
Lucas De Marchi 16c1bc1b0e AP_HAL_Linux: Util: fix coding style for pointers 2017-04-19 00:19:40 -07:00
Lucas De Marchi 9aa2a3938c AP_HAL_Linux: Util: make get_custom_log_directory const override final
While at it, add final and override to mark this as being the overriden
final implementation of this method.

Thanks to Phillip Khandeliants (@khandeliants) for reporting.
2017-04-19 00:19:22 -07:00
Lucas De Marchi 008e631147 AP_HAL_Linux: Util: fix overriden function signature
While at it, add final and override to mark this as being the overriden
final implementation of this method.

Thanks to Phillip Khandeliants (@khandeliants) for reporting.
2017-04-18 23:57:54 -07:00
Lucas De Marchi 6f952fe3dd AP_HAL_Linux: fix checking wrong value for pthread function
Thanks to Phillip Khandeliants (@khandeliants) for reporting.
2017-04-18 23:57:54 -07:00
Pierre Kancir 8d357983ee AP_HAL_LINUX: example fix travis warning
missing function declaration
implicit cast
some style fix
2017-04-13 19:56:16 +01:00
davidaroyer 512cd11125 AP_HAL_Linux: RCOutput_ZYNQ: check for valid channel 2017-04-11 12:10:33 +01:00
Eugene Shamaev 7831a85f1c AP_HAL_Linux: definitions for CAN bus 2017-04-10 22:38:12 +01:00
mirkix 9e1345453f AP_HAL_Linux: BBBmini remove onboard OpticalFlow 2017-03-07 22:48:48 -08:00
Lucas De Marchi 32d208dbe8 AP_HAL_Linux: move check for _split_transfers
This is likely not true, so allow not to check the other conditions.
Also remove comment since this is going to be added to the method.
2017-02-23 22:38:15 -08:00
Andrew Tridgell a2e445cf24 HAL_Linux: implement set_split_transfers() API for I2C 2017-02-23 22:38:15 -08:00
murata eb4d8963d0 AP_HAL_Linux: Change from magic number 0 to definition name. 2017-02-18 14:12:36 +00:00
murata 30bbe7abb6 AP_HAL_Linux: Unify from print or println to printf. 2017-01-27 18:20:22 +11:00
mirkix 6d99bb0937 AP_HAL_Linux: Add BeagleBone Blue to GPIO_BBB 2017-01-26 23:15:52 -08:00
mirkix 954267fc22 AP_HAL_Linux: Add BeagleBone Blue to RCInput_AioPRU 2017-01-26 23:15:52 -08:00
mirkix d16ab890e8 AP_HAL_Linux: Add BealgeBone Blue 2017-01-26 23:15:52 -08:00
mirkix ad7e21b860 AP_HAL_Linux: fix compiler warning in AnalogIn_IIO 2017-01-26 23:05:46 -08:00
Mathieu OTHACEHE 7c96f8e6a2 AP_HAL_Linux: rename APM to ardupilot.
This rename should have happened here:
fdb2a9c99b but was forgotten.
2017-01-25 16:57:47 +00:00
Julien Beraud 710875d3b9 OpticalFlow_Onboard: remove gyro cb
Not used anymore
2017-01-23 21:23:16 +11:00
Julien Beraud 59404f686d OpticalFlow_Onboard: add gyro integration support
Integrate the gyro values pushed by the inertial sensor backend using
bias values sent by EKF.
Use the unblocking RingBuffer to avoid locking the callers.
2017-01-23 21:23:16 +11:00
Lucas De Marchi c27c414e5a AP_HAL_Linux: Led_Sysfs: small fixes
- avoid trying to close fd when it's -1

  - Keep includes sorted

  - AP_HAL::panic() doesn't need \n terminator

  - %u requires unsigned type

  - #pragma once is the first thing on a header
2017-01-19 08:56:32 -08:00
Mathieu OTHACEHE 7d4d14a409 AP_HAL_Linux: add Led_Sysfs class.
Add a class to control leds via linux sysfs API.
2017-01-19 08:24:47 -08:00
Julien Beraud 0d4ca03dcd AP_HAL_Linux: init SPIDevice speed by default
Else a speed of 0 will be sent at each transfer.
Behaviour has changed when introducing SPIDevice
2017-01-16 10:23:47 -08:00
Lucas De Marchi 5472bc4de1 Global: change Device::PeriodicCb signature
Remove bool return as it's never being used and not supported on PX4.
2017-01-14 10:03:54 +11:00
Lucas De Marchi b910f230fb AP_HAL_Linux: RCInput: replace volatile with atomic 2017-01-11 11:25:00 +11:00
Andrew Tridgell 0a18f5e7b2 HAL_Linux: fixed a bug in RCInput::new_input
when a library called read() it would clear the new input flag, which
would cause new_input() in the main loop to return false. This could
trigger a false RC failsafe.
2017-01-09 21:47:19 -08:00
Lucas De Marchi b0ddf81687 Remove stdbool.h include for C++ sources
This header is not needed in our C++ sources.
2016-12-16 11:38:52 -08:00
Ivan Smirnov d4d35bdcbd AP_HAL_Linux: Scheduler: added _timer_tick for uartD 2016-12-07 10:25:00 -08:00
Lucas De Marchi f9b0f9164a AP_HAL_Linux: add TODO to AnalogIn_Raspilot
This is especially bad for raspilot since it has a spi bus shared for
all the peripherals.
2016-11-21 18:11:31 -02:00
Andrew Tridgell 6f82ec0642 HAL_Linux: convert RASPilot drivers to thread per bus 2016-11-21 18:04:10 -02:00
Lucas De Marchi 504de3ea9e AP_HAL_Linux: RCInput_RPI: fix whitespaces
Also add/change some minor coding style issues, reducing scope of
variables.
2016-11-19 14:05:22 -02:00
Lucas De Marchi aadc1643fc AP_HAL_Linux: reduce speed of MPU* devices
After introducing the temperature check we are resetting the fifo
several times due to difference in temperature.
2016-11-19 14:05:22 -02:00
Lucas De Marchi 8d3361cef4 AP_HAL_Linux: RCInput_RPI: fix using Util class on constructor
Program received signal SIGSEGV, Segmentation fault.
0x000b8760 in Linux::UtilRPI::get_rpi_version() const ()
(gdb) bt
 #0  0x000b8760 in Linux::UtilRPI::get_rpi_version() const ()
 #1  0x000b57ac in Linux::RCInput_RPI::RCInput_RPI() ()
 #2  0x0000acfc in _GLOBAL__sub_I__ZN9HAL_LinuxC2Ev ()
 #3  0x000e1600 in __libc_csu_init ()
 #4  0x76cad228 in __libc_start_main (main=0x7efff774, argc=1994186752,
     argv=0x76cad228 <__libc_start_main+168>, init=0xe15b4 <__libc_csu_init>,
     fini=0xe1614 <__libc_csu_fini>, rtld_fini=0x76fdf464 <_dl_fini>,
     stack_end=0x7efff774) at libc-start.c:246
 #5  0x0000afa4 in _start ()
2016-11-19 14:05:22 -02:00
Peter Barker cf5ed25c9e AP_HAL_Linux: do not attempt realtime when compiling Replay 2016-11-16 22:25:18 -02:00
Julien Beraud ac3f49b06f RPIOUART_Driver: fix warning
cast PKT_MAX_REGS to uint32_t to be able to compare without a warning
2016-11-16 17:37:15 -02:00
Lucas De Marchi c1647b13eb AP_HAL_Linux: fix leaking strings 2016-11-09 11:44:05 -03:00
Andrew Tridgell 4cf6dd1818 HAL_Linux: removed panic on bad SPI device 2016-11-09 17:08:11 +11:00
Andrew Tridgell a6ac02b61f HAL_Linux: implement device IDs for I2C and SPI 2016-11-09 17:08:04 +11:00
Mathieu OTHACEHE 60ba91aead Disco: add buzzer support
Use ToneAlarm class to handle Disco buzzer.
2016-11-07 18:02:21 -03:00
Mathieu OTHACEHE 0fa441a8a5 PWM_Sysfs: add an init method to do hal dependent stuff.
When PWM_Sysfs_Base constructor is called, global variable hal may not
have been initialized resulting in NULL dereferencing error.

Move hal dependent stuff from contructor to init method.
2016-11-07 14:59:31 -02:00
Lucas De Marchi 490841a814 AP_HAL_Linux: add O_CLOEXEC in places missing it
By opening with O_CLOEXEC we make sure we don't leak the file descriptor
when we are exec'ing or calling out subprograms. Right now we currently
don't do it so there's no harm, but it's good practice in Linux to have
it.
2016-11-07 12:37:30 -03:00
Ralf Ramsauer 530d3230df Linux: Scheduler: don't ignore return values
Several return values in the constructor of the scheduler were ignored
before, while they should be respected.

I found that bug while strac'ing ardupilot as it failed at some later
point.

Signed-off-by: Ralf Ramsauer <ralf.ramsauer@othr.de>
2016-11-03 17:27:37 -03:00
Lucas De Marchi 2b5f9fdd6b AP_HAL_Linux: teardown scheduler threads 2016-11-02 16:28:20 -02:00
Lucas De Marchi 89420e4b2d AP_HAL_Linux: add signal handler for normal termination
This allows to terminate the flight stack nicely, ensuring it returns 0
so init system can check by return code if it terminated nicely or if it
was due to a crash.
2016-11-02 16:28:20 -02:00
Lucas De Marchi fa540429f9 AP_HAL_Linux: allow to teardown bus threads
Add code to teardown all bus threads. This can be called while exiting
to wait for threads to finalize.
2016-11-02 16:28:20 -02:00
Lucas De Marchi 312a27dd20 AP_HAL: RCInput: rename deinit() to teardown() 2016-11-02 16:28:20 -02:00
Lucas De Marchi 89599f7bea AP_HAL_Linux: add unit tests for Thread implementations 2016-11-02 16:28:20 -02:00
Lucas De Marchi 992abd170d AP_HAL_Linux: allow to join threads 2016-11-02 16:28:20 -02:00
Lucas De Marchi 3b2de6de46 AP_HAL_Linux: allow PeriodicThread to stop
This takes the simplest approach of just waiting for the next time we
will process events.
2016-11-02 16:28:20 -02:00
Lucas De Marchi 20650e14b7 AP_HAL_Linux: allow PollerThread to stop 2016-11-02 16:28:20 -02:00
Lucas De Marchi da65a5c349 AP_HAL_Linux: allow to wakeup pollable
This allows to wakeup the thread that is sleeping on Poller::poll()
[ which in our case is an epoll_wait() call ]. This is usually achieved
by using a special signal and using the pwait() variant of the sleeping
function (or using signalfd). However integrating the signal in the
Thread class is more complex than simply use the eventfd syscall which
can serve our needs.
2016-11-02 16:28:20 -02:00
Lucas De Marchi efe819e21e AP_HAL_Linux: Poller: allow to fail constructor 2016-11-02 16:28:20 -02:00
Lucas De Marchi e5003c3116 AP_HAL_Linux: Poller: add some documentation 2016-11-02 16:28:20 -02:00
Lucas De Marchi da821e69eb AP_HAL_Linux: Thread: allow to use Thread from stack
Up until now we rely on Thread objects and variants thereof to be allocated
on heap or embedded in another object that's zero'ed on initialization.
However sometimes it's convenient to be able to use them on stack as
will be the case when writting unit tests.

Initialize all relevant fields to allow them to be used on stack. While
at it, prefer C++11 initialization on Poller since it's only setting the
default (invalid) value.
2016-11-02 16:28:20 -02:00
murata c808ee2f49 Global: To nullptr from NULL.
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.
2016-11-02 16:04:47 -02:00
hiro2233 cdfd057690 AP_HAL_LINUX: Added urus macro RCInput_RPI 2016-10-27 11:51:53 -02:00
hiro2233 cae0c11720 AP_HAL_Linux: Added URUS Macro to Util_RPI 2016-10-27 11:51:32 -02:00
hiro2233 37877f1530 AP_HAL_Linux: Added URUS macro to Scheduler 2016-10-27 11:51:32 -02:00
hiro2233 7000124f6a AP_HAL_Linux: Added URUS Macro for GPIO_RPI and UtilRPI 2016-10-27 11:51:32 -02:00
hiro2233 a7b79dc0e2 AP_HAL_Linux: GPIO_RPI: Added URUS Macro. 2016-10-27 11:51:32 -02:00
Lucas De Marchi 473add51f7 AP_HAL_Linux: RPIOUARTDriver: remove dma mention
There's no dma going on here, it's just a normal SPI transfer.
2016-10-27 10:35:01 -03:00
Lucas De Marchi d60b4842b6 AP_HAL_Linux: reduce scope of dummy buffer 2016-10-27 10:35:01 -03:00
Lucas De Marchi 76f1e4243a AP_HAL_Linux: remove double assignment
_dma_packet_tx.crc is already assigned below, we don't neet to set it to
0 before. While at it move the assignment to .crc up and fix coding
style.
2016-10-27 10:35:01 -03:00
Lucas De Marchi c898b28962 AP_HAL_Linux: use MIN where possible 2016-10-27 10:35:01 -03:00
Murilo Belluzzo c7a65a026c AP_HAL_PX4: UARTDriver: Make use of ByteBuffer class
This patch replaces the 'old style' ringbuffer by the ByteBuffer class.
An effort was made to keep the exchange as close as possible from a
drop-in replacement to minimize the risk of introducing bugs.

Although the exchange opens opportunities for improvement and
simplification of this class.
2016-10-27 14:23:43 +11:00
Lucas De Marchi 26650049c0 AP_HAL_Linux: UARTDriver: fix writting/reading with failures
When the buffer wraps and we do it in 2 steps, we can't actually do the
second part if it fails or if we wrote less bytes than we intended,
otherwise we will corrupt the data being sent.
2016-10-27 14:23:42 +11:00
Murilo Belluzzo ce81c45f80 AP_HAL_Linux: UARTDriver: Make use of ByteBuffer class
This patch replaces the 'old style' ringbuffer by the ByteBuffer class.
An effort was made to keep the exchange as close as possible from a
drop-in replacement to minimize the risk of introducing bugs.

Although the exchange opens opportunities for improvement and
simplification of this class.
2016-10-27 14:23:42 +11:00
Lucas De Marchi 539b727e5e AP_HAL_Linux: Remove misleading constant
The constant passed to cflag is BOTHER, meaning the actual baud is set
in the other specific members.  Don't define B* constants as they are
misleading here and this is why it doesn't work with e.g.
cfset[io]speed()... that function expect a B* constant which in Linux
is not the speed, but an index to an array with speeds.
2016-10-25 16:55:33 +11:00
Martin Evans 6f6112d7c2 AP_HAL_Linux: Add setting for GPIO for Dark board
Just like other RPI-based boards.
2016-10-24 10:00:24 -02:00
Martin Evans d2d3119b66 AP_HAL_Linux: PCA9685: Add quinary address 2016-10-24 10:00:06 -02:00
Mathieu OTHACEHE 152edf7189 Global: remove mode line from headers
Using a global .dir-locals.el file is a better alternative than
reincluding the same emacs header in every file of the project.
2016-10-24 09:42:01 -02:00
Julien Beraud 20dcd6e082 RCOutput_Bebop: fix motor order
Accidentally pushed in commit 298f7bffb9
The order of the motors shouldn't have been changed on version 5 because
it is specific to older versions of the ESC controller firmware
2016-10-17 20:55:49 +11:00