aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/CDC.cpp
diff options
context:
space:
mode:
authorDavid Madison <dmadison@users.noreply.github.com>2019-02-15 14:27:49 -0500
committerDavid Madison <dmadison@users.noreply.github.com>2019-02-15 14:28:30 -0500
commit2307486942f246aca947d770849b5d05822d7d17 (patch)
tree051494fa25c7614a79ed75b504fabf60fdf9249e /cores/arduino/CDC.cpp
parentfbad822c99b957b513b018cb135b41051f93cc11 (diff)
Replace Serial with null
Allows sketches using Serial to compile but discards all data
Diffstat (limited to 'cores/arduino/CDC.cpp')
-rw-r--r--cores/arduino/CDC.cpp134
1 files changed, 0 insertions, 134 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp
index 142f8f6..9fea948 100644
--- a/cores/arduino/CDC.cpp
+++ b/cores/arduino/CDC.cpp
@@ -163,140 +163,6 @@ bool CDC_Setup(USBSetup& setup)
return false;
}
-
-void Serial_::begin(unsigned long /* baud_count */)
-{
- peek_buffer = -1;
-}
-
-void Serial_::begin(unsigned long /* baud_count */, byte /* config */)
-{
- peek_buffer = -1;
-}
-
-void Serial_::end(void)
-{
-}
-
-int Serial_::available(void)
-{
- if (peek_buffer >= 0) {
- return 1 + USB_Available(CDC_RX);
- }
- return USB_Available(CDC_RX);
-}
-
-int Serial_::peek(void)
-{
- if (peek_buffer < 0)
- peek_buffer = USB_Recv(CDC_RX);
- return peek_buffer;
-}
-
-int Serial_::read(void)
-{
- if (peek_buffer >= 0) {
- int c = peek_buffer;
- peek_buffer = -1;
- return c;
- }
- return USB_Recv(CDC_RX);
-}
-
-int Serial_::availableForWrite(void)
-{
- return USB_SendSpace(CDC_TX);
-}
-
-void Serial_::flush(void)
-{
- USB_Flush(CDC_TX);
-}
-
-size_t Serial_::write(uint8_t c)
-{
- return write(&c, 1);
-}
-
-size_t Serial_::write(const uint8_t *buffer, size_t size)
-{
- /* only try to send bytes if the high-level CDC connection itself
- is open (not just the pipe) - the OS should set lineState when the port
- is opened and clear lineState when the port is closed.
- bytes sent before the user opens the connection or after
- the connection is closed are lost - just like with a UART. */
-
- // TODO - ZE - check behavior on different OSes and test what happens if an
- // open connection isn't broken cleanly (cable is yanked out, host dies
- // or locks up, or host virtual serial port hangs)
- if (_usbLineInfo.lineState > 0) {
- int r = USB_Send(CDC_TX,buffer,size);
- if (r > 0) {
- return r;
- } else {
- setWriteError();
- return 0;
- }
- }
- setWriteError();
- return 0;
-}
-
-// This operator is a convenient way for a sketch to check whether the
-// port has actually been configured and opened by the host (as opposed
-// to just being connected to the host). It can be used, for example, in
-// setup() before printing to ensure that an application on the host is
-// actually ready to receive and display the data.
-// We add a short delay before returning to fix a bug observed by Federico
-// where the port is configured (lineState != 0) but not quite opened.
-Serial_::operator bool() {
- bool result = false;
- if (_usbLineInfo.lineState > 0)
- result = true;
- delay(10);
- return result;
-}
-
-unsigned long Serial_::baud() {
- // Disable interrupts while reading a multi-byte value
- uint32_t baudrate;
- ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
- baudrate = _usbLineInfo.dwDTERate;
- }
- return baudrate;
-}
-
-uint8_t Serial_::stopbits() {
- return _usbLineInfo.bCharFormat;
-}
-
-uint8_t Serial_::paritytype() {
- return _usbLineInfo.bParityType;
-}
-
-uint8_t Serial_::numbits() {
- return _usbLineInfo.bDataBits;
-}
-
-bool Serial_::dtr() {
- return _usbLineInfo.lineState & 0x1;
-}
-
-bool Serial_::rts() {
- return _usbLineInfo.lineState & 0x2;
-}
-
-int32_t Serial_::readBreak() {
- int32_t ret;
- // Disable IRQs while reading and clearing breakValue to make
- // sure we don't overwrite a value just set by the ISR.
- ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
- ret = breakValue;
- breakValue = -1;
- }
- return ret;
-}
-
Serial_ Serial;
#endif /* if defined(USBCON) */