Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CDC blocks code execution when disconnected from USB
06-10-2015, 08:39 PM, (This post was last modified: 06-10-2015, 08:40 PM by B4lfiz4r.)
#1
Thumbs Down  CDC blocks code execution when disconnected from USB
Hey
Consider such case:
Code:
/*
    Blink a LED
*/

void setup()
{
    // initialize the digital pin USERLED as an output.
    pinMode(USERLED, OUTPUT);  
    pinMode(1, OUTPUT);  
}

void loop()
{
    toggle(USERLED);    // alternate ON and OFF
    toggle(1);    // alternate ON and OFF
    delay(500);        // wait for 500ms
    // ADDED FOR TESTING
    CDC.printf("okay.");
}

This is obviously running correctly when connected to USB port in computer, but...
THIS CODE WILL HANG ON CDC.*** CALL IF USB IS DISCONNECTED. THE LED WILL NOT BLINK.
Is this behaviour intented?
Sorry for the caps, but I've just spent several hours testing various PINGUINO boards banging my head and wondering why is my wireless pinguino stuff working only while connected to computers Angry

And wiki says nothing about such behaviour.
So I also ask you to write something about it on CDC article.

I have found only such mention so far:
Quote:On windows, the CONTROL_LINE variable must be used.
Instead of: CDC.print("toto",4);
use: if (CONTROL_LINE) CDC.print("toto",4);
CONTROL_LINE is used to know if a terminal is connected to Pinguino. If it is not used ( only on windows ) the USB buffer on the PC side can be overloaded.
but this is not strictly related to my issue, is it?



PS: I have tested the issue on PIC18F45K50, PIC18F4550 and PIC18F26J50 boards so far and it's in all of those.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)