user21117: I'm using a LinkIt ONE Arduino-like to send sensor data via MQTT.
It always worked very well, then out of the blue, it stopped printing anything using Serial.print();
But if I ommit the "Serial.begin(9600);" line, the code runs normally, sending sensor data via MQTT, even if I can't see debug output.
This shows the problem is on the Serial handling.
Since I can't show the entire code here, here's two test cases:
1.
void setup(){
  Serial.begin(9600);
  Serial1.begin(9600);
  while(!Serial); //Wait until Serial is ready before printing
}

void loop() {      
  Serial1.println("This came from serial 1"); //does nothing
  Serial.println("This came from serial 0");  //works
  delay(1000);
}

It shows me the following output:

This came from serial 0
This came from serial 0
Thi

Looks like the module freezes before the third iteration.
But if I omit the lines that aren't printed, from Serial1:
2.
void setup(){
  Serial.begin(9600);
  while(!Serial);  //Wait until Serial is ready before printing
}

void loop() {
  Serial.println("This came from serial 0");  //works
  delay(1000);
}

No output is shown on Serial monitor.
What is the reason behind this? Since Serial1 prints nothing, why can't I remove it?
Observations:
I tested the code in two LinkIt ONE modules of the same model.
I tested it in Arduino SDK 1.6.8, 1.5.6r2 and 1.6.5.
Edit:
Just made another test using the code below. It blinked two times showing that
Serial.begin(9600); runs
while(!Serial); runs (it didn't freeze the module waiting for Serial to initialize)
But Serial.println(); freezes
void setup(){
  pinMode(13, OUTPUT);
  blink();
  Serial.begin(9600);
  blink();
  while(!Serial); //Wait until Serial is ready before printing
}

void loop() {      
  Serial.println("This came from serial 0");  //works
  blink();
  delay(1000);
}

void blink(){
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);
}


user21117: The problem was solved by:

making a clean install of Arduino IDE 1.6.9
uploading the LinkIt SDK on board manager from version 1.1.17 to 1.1.23.

Then the Serial function returned back to normal.

21117: <p>I'm using a LinkIt ONE Arduino-like to send sensor data via MQTT.</p>
<p>It always worked very well, then out of the blue, it stopped printing anything using Serial.print();</p>
<p>But if I ommit the &quot;Serial.begin(9600);&quot; line, the code runs <strong>normally</strong>, sending sensor data via MQTT, even if I can't see debug output.</p>
<p>This shows the problem is on the Serial handling.</p>
<p>Since I can't show the entire code here, here's two test cases:</p>
<p>1.</p>
<pre><code>void setup(){
  Serial.begin(9600);
  Serial1.begin(9600);
  while(!Serial); //Wait until Serial is ready before printing
}

void loop() {      
  Serial1.println(&quot;This came from serial 1&quot;); //does nothing
  Serial.println(&quot;This came from serial 0&quot;);  //works
  delay(1000);
}
</code></pre>
<p>It shows me the following output:</p>
<blockquote>
<p>This came from serial 0</p>
<p>This came from serial 0</p>
<p>Thi</p>
</blockquote>
<p>Looks like the module freezes before the third iteration.</p>
<p>But if I omit the lines that aren't printed, from Serial1:</p>
<p>2.</p>
<pre><code>void setup(){
  Serial.begin(9600);
  while(!Serial);  //Wait until Serial is ready before printing
}

void loop() {
  Serial.println(&quot;This came from serial 0&quot;);  //works
  delay(1000);
}
</code></pre>
<p>No output is shown on Serial monitor.</p>
<p>What is the reason behind this? Since Serial1 prints nothing, why can't I remove it?</p>
<p>Observations:</p>
<p>I tested the code in two LinkIt ONE modules of the same model.</p>
<p>I tested it in Arduino SDK 1.6.8, 1.5.6r2 and 1.6.5.</p>
<p>Edit:</p>
<p>Just made another test using the code below. It blinked two times showing that</p>
<p>Serial.begin(9600); runs</p>
<p>while(!Serial); runs (it didn't freeze the module waiting for Serial to initialize)</p>
<p>But Serial.println(); freezes</p>
<pre><code>void setup(){
  pinMode(13, OUTPUT);
  blink();
  Serial.begin(9600);
  blink();
  while(!Serial); //Wait until Serial is ready before printing
}

void loop() {      
  Serial.println(&quot;This came from serial 0&quot;);  //works
  blink();
  delay(1000);
}

void blink(){
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);
}
</code></pre>
 21117: <p>The problem was solved by:</p>

<ul>
<li>making a clean install of Arduino IDE 1.6.9</li>
<li>uploading the LinkIt SDK on board manager from version 1.1.17 to 1.1.23.</li>
</ul>

<p>Then the Serial function returned back to normal.</p>
