title: TCP message from gps tracker
body: <p>I'm writing a simple python script to catch messages from gps trackers and write messages to server's db.</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import socket, string
  import MySQLdb
  
  def write_message(x):
      db = MySQLdb.connect(host="localhost", user="root", passwd="****", db="****", charset='utf8')
      cursor = db.cursor()
      sql = '''INSERT INTO test(test_c) VALUES ('%(test_c)s') '''%{"test_c":x}
      cursor.execute(sql)
      db.commit()
      db.close()
      return x  
  
  HOST = ""
  PORT = 50007
  
  srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  srv.bind((HOST, PORT))
  while 1:
      print u"Listen to " + str(PORT)
      srv.listen(1)             
      sock, addr = srv.accept()
      while 1:
          pal = sock.recv(2048)
          if not pal: 
              break
          print u"Recieved %s:%s:" % addr, pal
          lap = write_message(pal)
      sock.close()
  </code></pre>
  
  <p>To test script I use my home pc with the script</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import socket
  
  HOST = '****'   
  PORT = 50007            
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect((HOST, PORT))
  mes = u'a'
  s.sendall(mes)
  s.close()
  </code></pre>
  
  <p>Everything goes fine and server writes messages to db. With utf-8 they are full of unicode characters and it's ok. But when I use gps tracker I catch some strange messages like "xxSA░7d└╣" ('xx\x11\x01\x03SA\x907d\x84 \x10\x0b2\x01\x00\x01\\xa7\r\n') but the documentation says that messages contain ascii symbols only.
  I've found that there is "socket.SOCK_RAW" option and tried to use it, but got "socket.error: [Errno 93] Protocol not supported". </p>
  
  <p>Do you know what is the solution?</p>
  
  <p>The device is GT03b.</p>