title: Linux inserting carriage return-linefeed instead of just linefeed
body: <p>I am writing ASCII commands over a UART interface in an embedded linux system.</p>
  
  <p>I tested the code with a laptop to begin with. Both the embedded platform and the laptop share a ftdi usb dongle. The code should be identical on the two platforms (I thought).</p>
  
  <p>I am creating a string and sending it like so,</p>
  
  <pre><code>char cmd[MAX_STR_LEN];
  sprintf(cmd,"r %02x %02x\n",chipAddr,naddr);
  ssize_t bytes_tx = write(fd, (char *)cmd, strlen(cmd));
  if (bytes_tx &lt; 0){
      ERROR_PRINT("%s\n",strerror(errno));
      return -1;
  }
  </code></pre>
  
  <p>When I monitor the output of the serial device on an oscilloscope when running the code from the PC I see that <code>\n</code> is correctly interpreted as <code>0x0a</code>.</p>
  
  <p>When I run the same code snippet on the embedded platform I see <code>\n</code> is being interpreted as <code>0x0d 0x0a</code> or <code>\r\n</code>. </p>
  
  <p>How do I force the embedded platform to send only <code>\n</code> or <code>0x0a</code>? The embedded platform is running Linux Kernel 4.4.x generated with buildroot.</p>
  
  <p>--- UPDATED Full Test Code</p>
  
  <p>Placed full code here : <a href="https://pastebin.com/5dWhaaDv" rel="nofollow noreferrer">https://pastebin.com/5dWhaaDv</a></p>
  
  <p>result on both embedded and laptop targets,</p>
  
  <pre><code>Connected to /dev/ttyUSB0
  strlen 8 : r 40 00
  
  tx cmd[0] = 72 r
  tx cmd[1] = 20  
  tx cmd[2] = 34 4
  tx cmd[3] = 30 0
  tx cmd[4] = 20  
  tx cmd[5] = 30 0
  tx cmd[6] = 30 0
  tx cmd[7] = 0a 
  
  bytes_tx = 8
  sizeof(\n) : 4
  </code></pre>