title: string writing in python serial Port on Raspberrypi
body: <p>I am implementing SIM900 interface in RPi using python language. 
  However, there is a problem in sending string in port.write() function. </p>
  
  <p>Here is my code:</p>
  
  <pre><code># This line has to write on serial port
  port.write(b'AT+SAPBR=3,1,"APN","TATA.DOCOMO.INTERNET"\r\n') 
  </code></pre>
  
  <p>The above line works well...</p>
  
  <p>Now my requirement is the string <code>TATA.DOCOMO.INTERNET</code> which has to read from command line, and I need to append that string with <code>b'AT+SAPBR=3,1,"APN","xxxx"\r\n'</code>.</p>
  
  <p>But when I am trying to read the APN name into variable and after appending it is not working, the code lines are</p>
  
  <pre><code># AP ="TATA.DOCOMO.INTERNET"-string read from serial input
  AP = gsm.read() 
  t1 = "AT+SAPBR=3,1,"
  t2 = '"APN",'
  t3 = AP
  t4 = '\r\n'
  t = t1 + t2 + t3 + t4
  </code></pre>
  
  <p>The output of it in python is as follows:</p>
  
  <pre><code>AT+SAPBR=3,1,"APN","TATA.DOCOMO.INTERNET"\r\n'
  </code></pre>
  
  <p>It looks like the line which I need, but when I write in gsm.write(t)
  it gives an error, I even tried with </p>
  
  <pre><code>gsm.write(byte(t))
  gsm.write(t.encode())
  </code></pre>
  
  <p>But, it still does not work.</p>