aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/CDC.cpp6
-rw-r--r--cores/arduino/HardwareSerial.cpp4
-rw-r--r--cores/arduino/HardwareSerial.h1
-rw-r--r--cores/arduino/USBAPI.h1
4 files changed, 12 insertions, 0 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp
index 7206aa6..1275304 100644
--- a/cores/arduino/CDC.cpp
+++ b/cores/arduino/CDC.cpp
@@ -213,6 +213,12 @@ size_t Serial_::write(uint8_t c)
return 0;
}
+Serial_::operator bool() {
+ if (_usbLineInfo.lineState > 0)
+ return true;
+ return false;
+}
+
Serial_ Serial;
#endif
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index 9985b78..f40ddee 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -398,6 +398,10 @@ size_t HardwareSerial::write(uint8_t c)
return 1;
}
+HardwareSerial::operator bool() {
+ return true;
+}
+
// Preinstantiate Objects //////////////////////////////////////////////////////
#if defined(UBRRH) && defined(UBRRL)
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h
index 176abe1..bf4924c 100644
--- a/cores/arduino/HardwareSerial.h
+++ b/cores/arduino/HardwareSerial.h
@@ -57,6 +57,7 @@ class HardwareSerial : public Stream
virtual void flush(void);
virtual size_t write(uint8_t);
using Print::write; // pull in write(str) and write(buf, size) from Print
+ operator bool();
};
#if defined(UBRRH) || defined(UBRR0H)
diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h
index 5169e65..f66cb16 100644
--- a/cores/arduino/USBAPI.h
+++ b/cores/arduino/USBAPI.h
@@ -39,6 +39,7 @@ public:
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
+ operator bool();
};
extern Serial_ Serial;