Using "Data Terminal Ready" signal to determine when the host is connected.

pull/980/head
Jeremy Brodt 2015-03-17 14:18:56 -05:00
parent d1b1a93371
commit bbe2e0caed
1 changed files with 9 additions and 2 deletions

View File

@ -27,6 +27,10 @@ static uint8_t cdc_line_coding[7]= {0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08};
#define CDC_GET_LINE_CODING 0x21 #define CDC_GET_LINE_CODING 0x21
#define CDC_SET_CONTROL_LINE_STATE 0x22 #define CDC_SET_CONTROL_LINE_STATE 0x22
// Control Line State bits
#define CLS_DTR (1 << 0)
#define CLS_RTS (1 << 1)
#define MAX_CDC_REPORT_SIZE MAX_PACKET_SIZE_EPBULK #define MAX_CDC_REPORT_SIZE MAX_PACKET_SIZE_EPBULK
USBCDC::USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking): USBDevice(vendor_id, product_id, product_release) { USBCDC::USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking): USBDevice(vendor_id, product_id, product_release) {
@ -54,10 +58,13 @@ bool USBCDC::USBCallback_request(void) {
transfer->remaining = 7; transfer->remaining = 7;
transfer->notify = true; transfer->notify = true;
success = true; success = true;
terminal_connected = true;
break; break;
case CDC_SET_CONTROL_LINE_STATE: case CDC_SET_CONTROL_LINE_STATE:
terminal_connected = false; if (transfer->setup.wValue & CLS_DTR) {
terminal_connected = true;
} else {
terminal_connected = false;
}
success = true; success = true;
break; break;
default: default: