title: read from serial port
body: <p>This is the code given by <a href="http://www.gravitech.us/7segmentshield.html" rel="nofollow">http://www.gravitech.us/7segmentshield.html</a>.</p>
  
  <pre><code>void SerialMonitorPrint (byte Temperature_H, int Decimal, bool IsPositive)
  {
  Serial.print("The temperature is ");
  if (!IsPositive)
  {
    Serial.print("-");
  }
  Serial.print(Temperature_H, DEC);
  Serial.print(".");
  Serial.print(Decimal, DEC);
  Serial.print(" degree C");
  Serial.print("\n\n");
  }
  </code></pre>
  
  <p>But when I try to read data from serial port, I found that I read data character by character.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>while(1)
  {
      char buffer[100];
      int chars_read = read(fd, &amp;buffer, sizeof(buffer));
      buffer[chars_read] = '\0';
      printf("%s", buffer);
  }
  </code></pre>
  
  <p>So how can I read line by line?</p>