Commit Graph

54 Commits

Author SHA1 Message Date
Andrew Tridgell f812fc921f build: fixed more build warnings 2012-08-09 16:19:39 +10:00
Andrew Tridgell 1fe297ab63 FastSerial: added tx_pending() method
this allows the caller to wait for the tx buffer to drain
2012-06-15 15:53:27 +10:00
Andrew Tridgell 9c1ce9e1c5 FastSerial: avoid buffer re-allocation on re-open if possible
we commonly re-open serial ports a lot in the AUTO GPS driver
2012-06-09 07:43:22 +10:00
Andrew Tridgell 0c445101ff FastSerial: added set_blocking_writes() interface
this allows us to put a serial port into non-blocking mode, so that
writes that don't fit in the transmit buffer are dropped. This will be
used in flight to prevent stray printf() calls from causing large time
delays in the code
2012-03-30 17:46:20 +11:00
Randy Mackay 8533aaf5d9 AP_PID, AP_RC_Channel, FastSerial - small changes to make example sketches compile again 2012-01-28 17:54:20 +09:00
Randy Mackay ed19c25a97 Arduino 1.0 - changed all #includes of "WProgram.h", "wiring.h" and "WConstants.h to "Arduino.h".
Modified FastSerial's write function to return size_t (number of bytes written).
2012-01-28 12:25:47 +09:00
Mike Smith 3582ad4e20 Fix issue #423 - FastSerial flush bug. 2011-12-26 15:52:21 -08:00
Andrew Tridgell 294c812b9b desktop: use the libc printf engine
getting ftoa_engine right was too much work
2011-11-08 11:59:30 +11:00
Andrew Tridgell 41dd8d60ba use ifdef for DESKTOP_BUILD 2011-10-09 22:16:14 +11:00
Andrew Tridgell 288aba074f fastserial: allow vprintf() to build without assembler 2011-10-09 22:08:59 +11:00
James Goppert 0c7c508541 Optional recursion added. 2011-09-30 17:17:51 -04:00
James Goppert 5489b84f8e Improvements to cmake. 2011-09-29 21:23:26 -04:00
James Goppert 71fbdf721a Added APO branch. 2011-09-28 20:51:12 -04:00
unknown a4e001bbcf Adding CMake support 2011-09-14 15:44:55 +02:00
tridge60@gmail.com 2e989fd101 replace space() with txspace()
space() was actually intended to be tx buffer space, it just had a
bug. The name txspace() is clearer however, and should prevent
confusion as to which buffer its for

git-svn-id: https://arducopter.googlecode.com/svn/trunk@3247 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-09-04 22:52:11 +00:00
tridge60@gmail.com c822bad359 added txspace() method to FastSerial
this returns the number of bytes available in the transmit buffer

git-svn-id: https://arducopter.googlecode.com/svn/trunk@3245 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-09-04 21:23:15 +00:00
DrZiplok 73004e45dc Add a method to BetterStream and FastSerial that can be used to report
the amount of data that can be written without blocking.



git-svn-id: https://arducopter.googlecode.com/svn/trunk@2549 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-12 22:26:39 +00:00
james.goppert 7809b0ca2a Massive warning fixes.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2089 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-05-04 19:12:27 +00:00
james.goppert aa598b575a APO merge.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1935 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-05-01 02:05:17 +00:00
james.goppert@gmail.com 2d1b59e9a6 Eclipse makefile support for examples.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1861 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-04-09 19:39:27 +00:00
mich146@hotmail.com c8281da5ec FastSerial Fix
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1826 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-03-29 00:08:27 +00:00
tridge60@gmail.com 860998d337 implemented typesafe PSTR()
This makes PSTR() type safe by using a 1 byte wrapper
structure. Attempts to use the wrong varient of a print function will
generate a compilation error.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1797 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-03-21 07:25:48 +00:00
DrZiplok@gmail.com fdde092213 Extend the logic that preserves buffer sizing on re-begin by also avoiding freeing and re-allocating buffers when they don't change in size.
This can make re-opening a port faster (as the free/malloc pair can be avoided) and possibly more robust (in the case where e.g. the heap has been corrupted).

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1479 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-10 08:17:31 +00:00
DrZiplok@gmail.com 8c9a5d36d8 Add documentation and reformat closer to our current code standard.
Add support for re-opening a port without changing the baudrate or buffer sizes.  By passing zero for the parameters that aren't to be changed, code can reconfigure a port without needing to know how it was originally configured.





git-svn-id: https://arducopter.googlecode.com/svn/trunk@1462 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-10 01:17:03 +00:00
DrZiplok 814a16000a Simplify FastSerial::begin baudrate calculations in line with the changes made in Arduino-0022
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1424 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-04 18:41:27 +00:00
DrZiplok 44b95ac5b3 Improve documentation re: macros used to define serial ports.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1335 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-28 23:26:10 +00:00
DrZiplok 47bb4d22c6 Use the presence of UDRx as an indication that the serial port x might need to be supported.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1200 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-19 19:57:34 +00:00
rmackay9@yahoo.com a257c51a09 Some changes to fix compile errors when using ATmega2560.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1187 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-19 13:05:02 +00:00
DrZiplok@gmail.com 363d9156d1 Change the way that we do board-to-board portability to avoid knowing about specific AVR devices; use the availability of registers/vectors instead. This lets us reduce the overall macro evil as well.
Drop some unused, old vector code.

Strip the UDR pointer from the class instance, since it's never used.

Fix up the comment describing RAM savings.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1145 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-16 08:48:20 +00:00
DrZiplok@gmail.com 0fd1228e27 Add ::peek for compatibility with trunk Arduino.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@943 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-27 01:49:10 +00:00
DrZiplok@gmail.com 70baf31139 Resurrect lf -> crlf translation that was lost when I dropped the stdio support.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@921 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-25 03:41:52 +00:00
DrZiplok@gmail.com aa2bbe9131 A better workaround for the PSTR warning bug. This seems to work correctly.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@919 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-25 02:59:15 +00:00
DrZiplok@gmail.com 2dfb44907f Add a test case for printf_P
git-svn-id: https://arducopter.googlecode.com/svn/trunk@918 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-25 01:55:21 +00:00
DrZiplok c473af0082 Back out the "workaround" for PSTR() warnings; it doesn't.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@913 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-24 08:07:04 +00:00
DrZiplok@gmail.com f30bf9cab7 Add format attributes to printf and printf_P. The latter is a bit wishful as gcc isn't smart enough to deal with what PSTR does, but with some other hackery this can be used to generate useful warnings.
Add a workaround for a GCC bug that generates spurious warnings when PSTR() is used.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@901 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-23 09:09:52 +00:00
DrZiplok@gmail.com 43262a573f Bring in floating point support for BetterStream::printf, courtesy of the avr-libc implementation.
Strip the stdio integration from FastSerial as we aren't using it and it just wastes space.

Note that this does not attempt to fix the bogus floating point handling in ::print(ln).  That's an issue for another day.

BetterStream::printf(_P) aka FastSerial::printf(_P) support is now as documented for avr-libc printf with floating point support enabled.


git-svn-id: https://arducopter.googlecode.com/svn/trunk@895 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-23 00:38:16 +00:00
DrZiplok@gmail.com c833182dbe Duplicate include protection for BetterStream.h
git-svn-id: https://arducopter.googlecode.com/svn/trunk@761 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-11-01 07:42:51 +00:00
DrZiplok@gmail.com 271d4736a8 Factor the Stream-related enhancements out from FastSerial proper, so that we could use them on other Stream subclasses if that seemed worthwhile.
Add print_P and println_P implementations to give folks wedded to the vanilla Stream methods a way to print PROGMEM strings.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@715 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-10-23 05:59:40 +00:00
DrZiplok 84697f4111 Fix ::printf_P to transmit to the correct interface. Fixes the XBee test.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@685 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-10-18 04:40:33 +00:00
DrZiplok@gmail.com ca6d51cddb If ::begin() is called on a port that is already open, preserve the previous buffer settings. This makes it easy to change serial speeds without having to know how the port buffers were set up originally.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@672 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-10-17 06:15:47 +00:00
DrZiplok@gmail.com 5ba0c7328f Hook up stdio input, for the heck of it. We seem to be moving away from it, but there are things it can do that are hard to do with the Stream interfaces.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@555 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-25 18:15:56 +00:00
DrZiplok@gmail.com d45f67b3ef Add a carriage return before printing a newline when we are called as stdout/stderr.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@547 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-24 07:32:38 +00:00
DrZiplok@gmail.com f72129bdb3 Clean up the bitrate calculations per the Atmel datasheet.
Verified that when configured for 115200, the actual output as seen on a scope is around 117600Hz consistent with the +2.1% error in the datasheet.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@542 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-23 05:41:30 +00:00
DrZiplok@gmail.com 9db013e648 Stop trying to be so clever in the tx interrupt handler. We may race with the code stuffing bytes into the ring such that we consume the last byte and empty the ring before they set the UDRE interrupt.
If that happens since we weren't checking the ring for emptiness we would loop and spit out the whole ring again.  It's cheaper in terms of interrupt latency to just check the ring at interrupt time than it is to futz with ATOMIC_BLOCKs in the ::write code.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@535 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-22 06:56:27 +00:00
DrZiplok@gmail.com 6d31545b8d Per Jose, fix the interrupt vectors to work for non-1280-based Arduino.
Make Serial0 also stdin and stderr.



git-svn-id: https://arducopter.googlecode.com/svn/trunk@534 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-22 03:00:10 +00:00
DrZiplok@gmail.com 11865c1718 Remove the method call from the interrupt handlers. This brings the rx and tx interrupt paths down to < 60 instructions worst case, or ~4us.
At 115200 we expect ~100us between interrupts, or around 5% CPU overhead.  4us latency is probably acceptable for servo signal jitter too if we decide to consider using the Arduino Servo library.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@513 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-13 17:44:59 +00:00
analoguedevices 63ae72648e Commented out AP_Common, which is not implemented yet.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@443 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-08 22:18:58 +00:00
DrZiplok@gmail.com 6268189d31 Dynamically allocate serial buffers at ::begin time. Allow buffer sizes to be dynamically set.
This provides an opportunity for saving memory in the case of ports that do little or no work (e.g. the console) as well as increasing buffering for ports that receive large amounts of data in a short time (e.g. high-bitrate NMEA).



git-svn-id: https://arducopter.googlecode.com/svn/trunk@425 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-07 05:41:35 +00:00
DrZiplok@gmail.com 6b6637bd06 Omit the ::write method, as Print already implements it.
Fix a critical bug in the TX output buffer handling.



git-svn-id: https://arducopter.googlecode.com/svn/trunk@403 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-06 09:01:20 +00:00
DrZiplok@gmail.com 009ef940c6 Update to take advantage of the new Stream class in Arduino 0019.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@387 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-05 19:43:08 +00:00