예제 #1
0
/**
 * \brief Communication Data Class (CDC) Process
 *
 *   This is the link between USB and the "good stuff". In this routine data
 *   is received and processed by CDC-ACM Class
 */
PROCESS_THREAD(cdc_process, ev, data_proc)
{

	PROCESS_BEGIN();
	uart_usb_init();

	while(1) {
      

	    // turn off LED's if necessary
		if (led3_timer) led3_timer--;
		else			Led3_off();

 		if(Is_device_enumerated() && (usb_mode == rndis_debug) && rndis_state && (!usb_busy)) {

			if (justenumerated) {

				//If we have serial port, set it as output
			    if (usb_mode == rndis_debug) {
					uart_usb_set_stdout();
					menu_print();
				}
				justenumerated = 0;
			}

			//Flush buffer if timeout
	        if(timer >= 4 && tx_counter!=0 ){
	            timer = 0;
	            uart_usb_flush();
	        } else {
				timer++;
			}

			while (uart_usb_test_hit()){
  		  	   menu_process(uart_usb_getchar());   // See what they want
            }


		}//if (Is_device_enumerated())


		if (usb_mode == rndis_debug) {
			etimer_set(&et, CLOCK_SECOND/80);
		} else {
			etimer_set(&et, CLOCK_SECOND);
		}

		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));	
		
	} // while(1)

	PROCESS_END();
}
예제 #2
0
/**
 * \brief Communication Data Class (CDC) Process
 *
 *   This is the link between USB and the "good stuff". In this routine data
 *   is received and processed by CDC-ACM Class
 */
PROCESS_THREAD(cdc_process, ev, data_proc)
{
	PROCESS_BEGIN();

#if USB_CONF_RS232
	static FILE *rs232_stdout,*usb_stdout;
	rs232_stdout=stdout;
#endif

	while(1) {
	    // turn off LED's if necessary
		if (led3_timer) led3_timer--;
		else			Led3_off();
		
 		if(Is_device_enumerated()) {
			// If the configuration is different than the last time we checked...
			if((uart_usb_get_control_line_state()&1)!=previous_uart_usb_control_line_state) {
				previous_uart_usb_control_line_state = uart_usb_get_control_line_state()&1;
				static FILE* previous_stdout;
				
				if(previous_uart_usb_control_line_state&1) {
					previous_stdout = stdout;
					uart_usb_init();
					uart_usb_set_stdout();
				//	menu_print(); do this later
				} else {
					stdout = previous_stdout;
				}
#if USB_CONF_RS232
				usb_stdout=stdout;
#endif
			}

			//Flush buffer if timeout
	        if(timer >= 4 && tx_counter!=0 ){
	            timer = 0;
	            uart_usb_flush();
	        } else {
				timer++;
			}

#if USB_CONF_RS232
			stdout=usb_stdout;
#endif
			while (uart_usb_test_hit()){
  		  	   menu_process(uart_usb_getchar());   // See what they want
            }
#if USB_CONF_RS232
            if (usbstick_mode.debugOn) {
			  stdout=rs232_stdout;
			} else {
			  stdout=NULL;
			}
#endif
		}//if (Is_device_enumerated())



		if (USB_CONFIG_HAS_DEBUG_PORT(usb_configuration_nb)) {
			etimer_set(&et, CLOCK_SECOND/80);
		} else {
			etimer_set(&et, CLOCK_SECOND);
		}

		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));	
		
	} // while(1)

	PROCESS_END();
}