Commit Graph

38 Commits

Author SHA1 Message Date
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
DrZiplok@gmail.com e0be94a03f Change the way the port declaration macros work. This saves ~300
bytes by shrinking the constructor.

I don't quite understand why g++ is emitting two identical copies of
the ctor, but it wastes a bunch of space. 8(

Integrate FastSerial with the C library's standard I/O.  Add new
::printf and ::printf_P methods that do the obvious thing, and a
::getfd method so that a caller can use the other stdio functions with
the port if that's interesting.




git-svn-id: https://arducopter.googlecode.com/svn/trunk@361 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-08-31 06:22:54 +00:00
DrZiplok@gmail.com 22c9ed317e Change the way that FastSerial ports are created, so that we can avoid
creating port drivers for ports that aren't used.

This lets us save the RAM (~200 bytes per port) that would otherwise
have been used for buffers.  It also frees up the port's interrupt
vectors so that on Mega we can use the ports for other things
(e.g. SPI Master mode).

Better to fix this now than later when we have more consumers.



git-svn-id: https://arducopter.googlecode.com/svn/trunk@355 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-08-30 04:01:15 +00:00
DrZiplok@gmail.com b4a840a336 Add 'extern' definitions to legitimise clients that want to assume that Serial* always exists.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@321 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-08-27 02:29:14 +00:00
DrZiplok@gmail.com 6074c410d9 "Fast" serial driver that fully overrides the Arduino-provided HardwareSerial/Serial* driver.
The receive side is basically a copy of the HardwareSerial driver, whilst the transmit side
uses the same algorithm as the APM_FastSerial driver.

See the example sketch for usage details.



git-svn-id: https://arducopter.googlecode.com/svn/trunk@276 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-08-23 06:25:03 +00:00