Problem receiving data from GPS device , python TCP

Viewed 22

I m trying to read data from a GPS device "Telonika FMB204" using a python socket and TCP/IP all you have to do as setup is to specify the server IP and the port the start my python I found Telonika forum showing data received successfully, I try to test it using my dynamic IP address but I the script shows no data my question is there any way to host the script somewhere ?

link :https://community.teltonika-gps.com/4965/how-to-read-data-from-teltonika-fmb001-with-a-python-script

import socket
port = 3000
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', port))
s.listen(1)
conn, addr = s.accept()
print('Connected by ', addr)
imei = conn.recv(1024)
conn.send('\x01')

while True:
    try:
        data = conn.recv(1024)
        if not data:
            break
        f = open("demofile2.txt", "a")
        f.write(data)
        f.close()
        print(data)

    except socket.error:
        print("Error Occured.")
        break
0 Answers
Related