Skip to content

Commit

Permalink
Merge pull request contiki-os#199 from g-oikonomou/cc253x-cdc-acm-lin…
Browse files Browse the repository at this point in the history
…e-state-fix

Improve handling of CDC ACM line state
  • Loading branch information
adamdunkels committed Apr 17, 2013
2 parents 260b004 + 007e113 commit c99b62f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
14 changes: 1 addition & 13 deletions cpu/cc2538/usb/usb-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,9 @@ do_work(void)
if(events & USB_CDC_ACM_LINE_STATE) {
uint8_t line_state = usb_cdc_acm_get_line_state();
PRINTF("CDC-ACM event 0x%04x, Line State = %u\n", events, line_state);
if(line_state == 0) {
/* CDC-ACM line went down. Stop streaming */
enabled = 0;
} else if(line_state == (USB_CDC_ACM_DTE | USB_CDC_ACM_RTS)) {
if(line_state & USB_CDC_ACM_DTE) {
enabled = 1;
} else {
/*
* During tests on Ubuntu and OS X, line_state never stays == 2
* (USB_CDC_ACM_RTS) for too long. We always see this value when the
* line is in the process of going up or coming down. If it is going
* up, value 3 will enable us shortly. Otherwise, we may as well
* disable already.
*
* All other values: disable
*/
enabled = 0;
}
}
Expand Down
11 changes: 11 additions & 0 deletions platform/cc2530dk/dev/usb-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ do_work(void)
enabled = 0;
}

events = usb_cdc_acm_get_events();
if(events & USB_CDC_ACM_LINE_STATE) {
uint8_t line_state = usb_cdc_acm_get_line_state();
if(line_state & USB_CDC_ACM_DTE) {
enabled = 1;
} else {
enabled = 0;
}
}

if(!enabled) {
return;
}
Expand Down Expand Up @@ -254,6 +264,7 @@ PROCESS_THREAD(usb_serial_process, ev, data)
usb_setup();
usb_cdc_acm_setup();
usb_set_global_event_process(&usb_serial_process);
usb_cdc_acm_set_event_process(&usb_serial_process);
usb_set_ep_event_process(EPIN, &usb_serial_process);
usb_set_ep_event_process(EPOUT, &usb_serial_process);

Expand Down

0 comments on commit c99b62f

Please sign in to comment.