Commit Graph

127 Commits

Author SHA1 Message Date
Peter Barker 334af1ecd7 DataFlash: base class method for resetting state on log open 2016-05-07 07:21:16 +10:00
Peter Barker eea2d5dcb5 DataFlash_File: avoid integer wrap when checking minimum time 2016-05-07 07:21:15 +10:00
Andrew Tridgell fe8070bd51 DataFlash: move lock to protect just buffer IO 2015-12-29 09:10:28 +11:00
Andrew Tridgell b967140572 DataFlash: enable minimal file mode
This adds a "minimal" dataflash mode with a board specific macro. The
QURT port uses this to avoid problematic system calls that are buggy
in the QURT RTOS

With some pending updates to QURT we may be able to remove some (or
all) of this
2015-12-27 16:21:26 +11:00
Peter Barker 2f1297f30c DataFlash_File: Check return values of lseek 2015-12-21 16:07:23 +11:00
Peter Barker ce84ba049f DataFlash_File: protect against fopen failing 2015-12-21 16:07:23 +11:00
Peter Barker 15265a45ed DataFlash_File: check fname before using it 2015-12-21 16:07:23 +11:00
Andrew Tridgell 025e4edd17 DataFlash: fixed warning 2015-12-20 17:55:40 +11:00
Andrew Tridgell 02d7867d79 DataFlash: added locking for multi-thread logging support 2015-12-20 17:55:39 +11:00
Peter Barker 7900359fac DataFlash: LOG_FILE_BUFSIZE sets buffer size for DataFlash_File 2015-12-08 10:59:57 +11:00
Tom Pittenger 4e3864049a DataFlash: compile warning - float to double promotion 2015-12-07 15:50:03 +09:00
Peter Barker faabe0b83d DataFlash: support multiple simultaneous backends 2015-12-03 13:21:51 +11:00
Lucas De Marchi 2591261af6 Global: rename min and max macros to uppercase
The problem with using min() and max() is that they conflict with some
C++ headers. Name the macros in uppercase instead. We may go case by
case later converting them to be typesafe.

Changes generated with:

	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)max(/\1MAX(/g'
	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)min(/\1MIN(/g'
2015-12-01 16:28:09 -02:00
Caio Marcelo de Oliveira Filho 753956bd77 AP_Dataflash: use millis/micros/panic functions 2015-11-20 12:35:00 +09:00
Peter Barker fc05ad81eb DataFlash_File: cache oldest log to avoid directory scans when downloading 2015-11-12 12:23:46 +11:00
Lucas De Marchi 20c6ffc5e3 Replace use of UARTDriver::printf_P() with UARTDriver::printf()
This also starts to show warnings on places that were already using
wrong printf format strings.
2015-10-30 14:35:25 +09:00
Lucas De Marchi 2c38e31c93 Remove use of PSTR
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.
2015-10-30 14:35:04 +09:00
Peter Barker e481497574 DataFlash: delete oldest file rather than the lowest-numbered file
Also reference log numbers by their list index to accomodate log number
wrapping in DataFlash_File
2015-10-21 10:50:32 +11:00
Andrew Tridgell b0aa7cb990 DataFlash: use new perf API 2015-10-20 18:16:16 +11:00
Peter Barker 8f1471c137 DataFlash: leave room in buffer for non-startup messages 2015-09-18 09:13:45 +10:00
Buzz 684dfaf26f DataFlash: fix OSX build 2015-09-09 13:09:01 +09:00
Peter Barker 60010e794e DataFlash: ensure 10% free space when initialising logging 2015-09-09 12:22:35 +10:00
Peter Barker 8f8493225c DataFlash: DFMessageWriter; ability to trickle messages out to DF 2015-09-03 09:54:55 +10:00
Lucas De Marchi 327a3a4298 DataFlash: standardize inclusion of libaries headers
Do the missing header changes due to changing the code before the pr
getting accepted.
2015-08-18 17:12:52 +10:00
Gustavo Jose de Sousa 709204c01d DataFlash: standardize inclusion of libaries headers
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.
2015-08-11 16:38:24 +10:00
Grant Morphett 08f5305519 DataFlash: fix coverity warnings - add param init in constructor 2015-07-30 12:37:09 +10:00
Peter Barker 65813f308e DataFlash: fix incorrect comment 2015-07-21 13:11:00 +09:00
Peter Barker 844f050cf3 DataFlash: correct zero-byte-file handling in CLI
-rw-rw-r-- 1 pbarker pbarker   2105344 Jul  1 16:10 1.BIN
-rw-rw-r-- 1 pbarker pbarker         0 Jul  1 19:35 2.BIN
-rw-rw-r-- 1 pbarker pbarker   2494464 Jul  1 16:58 3.BIN
-rw-rw-r-- 1 pbarker pbarker 128503808 Jul  1 20:22 4.BIN
-rw-rw-r-- 1 pbarker pbarker         3 Jul  1 19:46 LASTLOG.TXT

Before fix:

2 logs
Log 3 in logs/3.BIN of size 2494464 2015/7/1 6:58
Log 4 in logs/4.BIN of size 128503808 2015/7/1 10:22

After Fix:

4 logs
Log 1 in logs/1.BIN of size 2105344 2015/7/1 6:10
Log 2 in logs/2.BIN of size 0 2015/7/1 9:35
Log 3 in logs/3.BIN of size 2494464 2015/7/1 6:58
Log 4 in logs/4.BIN of size 128503808 2015/7/1 10:22

If the last file was zero bytes, no files would be shown.
2015-07-02 08:53:18 +10:00
Peter Barker c5c39a77a3 DataFlash: method to flush ringbuffer to fd 2015-06-30 16:19:22 +10:00
Víctor Mayoral Vilches c06abeb02e DataFlash_File: Support custom_log_directory 2015-06-30 14:36:42 +10:00
Peter Barker 723c37bcf7 DataFlash: backend/frontend split 2015-06-26 16:02:50 +10:00
Andrew Tridgell 73445fdae9 DataFlash: added error checking and fixed a warning 2015-05-30 22:16:22 +10:00
Lucas De Marchi c894a1349e DataFlash: use functor macros
Functor is not yet being used but let's make is macro fallback to the
previous Delegate implementation for easy of transition between the two.
2015-05-26 13:46:54 +10:00
Andrew Tridgell b5d930be61 DataFlash: support member functions for rover 2015-05-21 07:48:47 +10:00
Andrew Tridgell b0a90df135 DataFlash: fixed double Init of DF object
thanks to Michael De Breuil
2015-05-15 16:33:10 +10:00
Andrew Tridgell 438f954379 DataFlash: fixed some build warnings 2015-05-05 09:45:58 +10:00
Andrew Tridgell 69f9d25cd0 DataFlash: fix for HAL_SITL rename 2015-05-05 09:45:56 +10:00
Andrew Tridgell 2dfe3cb844 DataFlash: added a perf counter for microSD overruns
this allows us to tell if a microSD can handle a high logging rate
2015-04-21 20:45:30 +10:00
Andrew Tridgell c153d31dd2 DataFlash: speed up DataFlash in Replay 2015-04-21 10:14:41 +10:00
Emile Castelnuovo ebc3dcd142 DataFlash: Clean up, VRBRAIN deleted unused boards. 2015-02-02 08:44:01 +11:00
Emile Castelnuovo ffd26e59cd DataFlash: added new VRBRAIN boards 2015-02-02 08:43:59 +11:00
Andrew Tridgell 2ddf3e728a DataFlash: use common RingBuffer.h 2015-01-07 08:41:14 +11:00
Andrew Tridgell c93ae67541 DataFlash: don't try and open logfile on failure more than once
this prevents a corrupted microSD card from causing a continuous
attempt to open a log file while in flight, which can cause large
scheduler delays

Pair-Programmed-With: Grant Morphett <grant@gmorph.com>
2014-12-21 14:50:42 +11:00
Andrew Tridgell 9d846d5f2a DataFlash: allow use of a smaller writebuf for PX4v1
this fixes logging on PX4v1
2014-09-09 17:32:44 +10:00
LukeMike 8f552d5758 VRBRAIN: Changed the management of VirtualRobotix's boards. 2014-06-19 11:27:38 +02:00
Emile Castelnuovo ab9a320187 DataFlash: added #ifdefs for VRBRAIN board 2014-04-08 16:19:19 +10:00
Andrew Tridgell 27dbf608c8 DataFlash: fixed a build warning 2014-03-25 13:31:21 +11:00
Andrew Tridgell ecdd74d580 DataFlash: return number of logs as zero correctly
when we have no file based logs, report no logs :)
2014-03-11 17:11:58 +11:00
Andrew Tridgell f222f2ef1e DataFlash: fixed logging on PX4v1
large writes break IO, a NuttX bug
2014-02-20 06:55:35 +11:00
Andrew Tridgell 6618bdae67 DataFlash: periodically use lseek to avoid NuttX seek bug 2014-02-16 13:21:35 +11:00
Andrew Tridgell 63910bf8cd DataFlash: work around a NuttX bug
the seek offset of files can get badly mucked up when it crosses
cluster boundaries. We need to fix this in NuttX, but meanwhile this
works around the bug. It seems that doing a lseek(fd, 0, SEEK_CUR)
fixes the seek offset in the file.

The bug seems to first happen at an offset of 315392. It also
doesn't happen every time - it is more likely to happen on the first
log download after booting
2014-02-15 05:00:08 +11:00
Andrew Tridgell 921f923c5f DataFlash: reset write log on new log 2014-01-14 14:28:56 +11:00
Andrew Tridgell ef28d087d2 DataFlash: added logging_started() API 2014-01-14 13:51:06 +11:00
Andrew Tridgell f6db03dfb0 DataFlash: don't fsync on SITL
this makes it much faster on virtual machines
2014-01-14 12:46:26 +11:00
Andrew Tridgell b4b66210ff DataFlash: improve reliability of microSD for logs 2014-01-14 12:46:26 +11:00
Andrew Tridgell cb23298384 DataFlash: try to keep dataflash writes aligned
also rename lastlog.txt to LASTLOG.TXT as NuttX seems to get less
corruption with VFAT filenames that don't need uppercase mappings
2014-01-14 12:46:26 +11:00
Randy Mackay a53d1075ec DataFlash: add EnableWrites method
This method allows temporarily suspending writes to the dataflash which
will be used in ArduCopter to ensure no messages are written while the
copter is disarmed
2014-01-07 22:43:44 +09:00
Andrew Tridgell 4519aa8867 DataFlash: only fsync every 10 seconds
prevents too much work in SITL
2014-01-04 08:15:38 +11:00
Andrew Tridgell 8019d45200 DataFlash: use HAL_OS_POSIX_IO 2013-12-31 10:28:38 +11:00
Andrew Tridgell a43e0f6f31 DataFlash: stop logging when erasing logs 2013-12-29 15:00:15 +11:00
Andrew Tridgell e1a86440bb DataFlash: stop write logging while reading
prevents nuttx getting confused
2013-12-28 14:25:54 +11:00
Andrew Tridgell e6bafa2d8f DataFlash: added structures to Init() of dataflash
this will allow the get_log_data() call to add FMT headers if a log
has wrapped
2013-12-17 11:51:36 +11:00
Andrew Tridgell 5d53b780ba DataFlash: added functions for load download support 2013-12-17 11:51:35 +11:00
Andrew Tridgell 4ce2555a65 DataFlash: don't try to create a directory that exists
this is an attempt to avoid microSD card corruption. The most common
corruption is two 'logs' directories, which may indicate an issue with
trying to create it a 2nd time.
2013-12-14 15:47:49 +11:00
Andrew Tridgell 6b2222c32e DataFlash: show timestamps on flash logs 2013-10-24 14:22:48 +11:00
Andrew Tridgell a86bb15a05 DataFlash: updates for AP_HAL::MemberProc 2013-09-30 21:06:42 +10:00
Andrew Tridgell 19e9c95983 DataFlash: use new scheduler API 2013-09-28 21:24:03 +10:00
Andrew Tridgell 49d3d624d7 DataFlash: enabled DataFlash_File for Linux 2013-09-28 21:24:02 +10:00
Andrew Tridgell dd747505c5 DataFlash: report when DataFlash write fails 2013-08-30 13:01:34 +10:00
Andrew Tridgell 709a277c7f DataFlash: chamged FMT message to include labels
this makes it easier for MP to parse and display
2013-04-23 19:46:22 +10:00
Andrew Tridgell 9ef34943af DataFlash: change log extension to *.bin 2013-04-23 15:03:10 +10:00
Andrew Tridgell 844e1b9ef9 DataFlash: added support for printing flight mode as a string
makes analysing logs easier.

Pair-Programmed-With: Randy
2013-04-20 15:17:49 +10:00
Andrew Tridgell b5ae588341 DataFlash_File: fixed creation of 0.log 2013-04-20 13:52:37 +10:00
Andrew Tridgell 62f190ed15 DataFlash: simplify code now that copter is converted
no longer need as many public functions
2013-04-20 13:52:37 +10:00
Andrew Tridgell c29d870497 DataFlash: dump the format of logs at the start of the log 2013-04-20 13:52:36 +10:00
Andrew Tridgell 916e8d0992 DataFlash: new dataflash logging system
this allows us to remove the display functions in the vehicle code,
and also allows us to store the format of a log file in the log. It
also stores the parameters used in a flight, rather than the
parameters set at the time the log is dumped
2013-04-20 13:52:36 +10:00
Andrew Tridgell da5a5ea368 DataFlash: added file based 'dataflash' logging 2013-04-17 21:32:53 +10:00