Skip to content

Commit 8719388

Browse files
committed
Merge pull request #180 from oliviermartin/om/usb-serial-non-blocking
libraries/USBSerial: Allow the USB connection to be non-blocking
2 parents b828faf + 29f7151 commit 8719388

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

libraries/USBDevice/USBSerial/USBCDC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ static uint8_t cdc_line_coding[7]= {0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08};
2929

3030
#define MAX_CDC_REPORT_SIZE MAX_PACKET_SIZE_EPBULK
3131

32-
USBCDC::USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) {
32+
USBCDC::USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking): USBDevice(vendor_id, product_id, product_release) {
3333
terminal_connected = false;
34-
USBDevice::connect();
34+
USBDevice::connect(connect_blocking);
3535
}
3636

3737
bool USBCDC::USBCallback_request(void) {

libraries/USBDevice/USBSerial/USBCDC.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ class USBCDC: public USBDevice {
3535
* @param vendor_id Your vendor_id
3636
* @param product_id Your product_id
3737
* @param product_release Your preoduct_release
38+
* @param connect_blocking define if the connection must be blocked if USB not plugged in
3839
*/
39-
USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
40+
USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking);
4041

4142
protected:
4243

libraries/USBDevice/USBSerial/USBSerial.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ class USBSerial: public USBCDC, public Stream {
5353
* @param vendor_id Your vendor_id (default: 0x1f00)
5454
* @param product_id Your product_id (default: 0x2012)
5555
* @param product_release Your preoduct_release (default: 0x0001)
56+
* @param connect_blocking define if the connection must be blocked if USB not plugged in
5657
*
5758
*/
58-
USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001): USBCDC(vendor_id, product_id, product_release), buf(128){
59+
USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001, bool connect_blocking = true): USBCDC(vendor_id, product_id, product_release, connect_blocking), buf(128){
5960
settingsChangedCallback = 0;
6061
};
6162

0 commit comments

Comments
 (0)