Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added USBSerial operator int() to test for USB connectivity (a-la Leo…

…nardo)
  • Loading branch information...
commit 76a40780fad7e9d54eb0171ce072922a992a4b3e 1 parent c98a9c8
@majenkotech majenkotech authored
View
4 hardware/pic32/cores/pic32/HardwareSerial.cpp
@@ -582,6 +582,10 @@ USBSerial::USBSerial(ring_buffer *rx_buffer)
_rx_buffer->tail = 0;
}
+USBSerial::operator int() {
+ return gConnected ? 1 : 0;
+}
+
#ifdef _DEBUG_USB_VIA_SERIAL0_
#define DebugViaSerial0(x) Serial0.println(x)
#else
View
1  hardware/pic32/cores/pic32/HardwareSerial.h
@@ -141,6 +141,7 @@ class USBSerial : public Stream
virtual void write(uint8_t);
virtual void write(const char *str);
virtual void write(const uint8_t *buffer, size_t size);
+ operator int();
using Print::write; // pull in write(str) and write(buf, size) from Print
};
View
2  hardware/pic32/cores/pic32/HardwareSerial_cdcacm.c
@@ -164,7 +164,7 @@ static int gRX_length[NRX];
static volatile byte gRX_in;
static volatile byte gRX_out;
-static boolean gConnected = false;
+boolean gConnected = false;
//*******************************************************************************
View
1  hardware/pic32/cores/pic32/HardwareSerial_cdcacm.h
@@ -7,6 +7,7 @@
#define USB_SERIAL_MIN_BUFFER_FREE 128
extern boolean gCdcacm_active;
+extern boolean gConnected;
typedef void (*cdcacm_reset_cbfn)(void);
typedef boolean (*cdcacm_storedata_cbfn)(const byte *buffer, int length);
Please sign in to comment.
Something went wrong with that request. Please try again.