1

post data to gurtam with python

Тема: post data to gurtam with python

hello
i have my own server and i receive data from about 200 devices
after getting some important data from received packet (like heart rate and temp)
i have to send gis information to gurtam for show location on wialon map server

so
i have a mysql database with my records on the server.how can i send data to gurtal with python
i pried regular python socketing but dont received any response from wialon
is there any example for this?!

thank you

2

post data to gurtam with python

Re: post data to gurtam with python

Hello

You should create data packages and send it using the protocol of supported devices.

For example you can use our own protocol Wialon IPS http://extapi.wialon.com/hw/cfg/Wialon% … _v_2_0.pdf

Viktor Yarovenko
Hardware department Specialist
3

post data to gurtam with python

Re: post data to gurtam with python

thank you for the replay
my problem is not formating

i have this code:

import socket

clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientsocket.connect(('193.193.165.165', 20332))
clientsocket.send(bytes('#L#2.0;myuser name;1234;C04C', 'UTF-8'))
while True:
    data = clientsocket.recv(1024)
    print ("Received response:" + str(data))
    clientsocket.close()
    break

after running on the server i got this error:
the server dont accept my connection:

Traceback (most recent call last):
  File "t2.py", line 4, in <module>
    clientsocket.connect(('193.193.165.165', 20332))
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a perio
d of time, or established connection failed because connected host has failed to respond

is there any specific standard for send connection request ?!

4

post data to gurtam with python

Re: post data to gurtam with python

Works for me

import socket

clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientsocket.connect(('193.193.165.165', 20332))
clientsocket.send('#L#username;NA\r\n')
while True:
    data = clientsocket.recv(1024)
    print ("Received response:" + str(data))
    clientsocket.close()
    break

PS In sample i send login packet for Wialon IPS 1.1 http://extapi.wialon.com/hw/cfg/Wialon%20IPS.pdf

5

post data to gurtam with python

Re: post data to gurtam with python

shmi пишет:

Works for me

import socket

clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientsocket.connect(('193.193.165.165', 20332))
clientsocket.send('#L#username;NA\r\n')
while True:
    data = clientsocket.recv(1024)
    print ("Received response:" + str(data))
    clientsocket.close()
    break

PS In sample i send login packet for Wialon IPS 1.1 http://extapi.wialon.com/hw/cfg/Wialon%20IPS.pdf

ok
your code is working on python 2.7
but in python 34 we must send encoded byte with sockets
and this make mistake with wialon

can you test your code with python34 please!?

6

post data to gurtam with python

Re: post data to gurtam with python

Python 3 code

...
clientsocket.send(b'#L#shmi;NA\r\n')
...
7

post data to gurtam with python

Re: post data to gurtam with python

shmi пишет:

Python 3 code

...
clientsocket.send(b'#L#shmi;NA\r\n')
...

last code working good
but now i have problem again

i have to send a custom packet to gurtam
my code is like this

clientsocket.send(b'#MGV002,860855020120917,,S,15042016,112233,A,5130.1358000,N,3544.7009000,W,0,5,00,1.95,12,0,,,432,35,5,5,-70,,,,,,,,,1,25,Timer;!')

but unfortunately its not working!!

what is my code problem?'
anything must change for a custom format?

8

post data to gurtam with python

Re: post data to gurtam with python

roozgar
I'm not sure packet of what type are you trying to send but its format is invalid. List of available packet types you can find in docs

All packets should be in a format #TP#msg\r\n (packet type is red, message data is blue)
Here's some valid packets for  Wialon IPS 1.1
#L#shmi;NA\r\n - Login packet
#M#Message to driver\r\n - Message to driver
#SD#150416;085139;5356.4223;N;02741.2094;E;2;330;228;9\r\n - Short data packet

9

post data to gurtam with python

Re: post data to gurtam with python

shmi пишет:

roozgar
I'm not sure packet of what type are you trying to send but its format is invalid. List of available packet types you can find in docs

All packets should be in a format #TP#msg\r\n (packet type is red, message data is blue)
Here's some valid packets for  Wialon IPS 1.1
#L#shmi;NA\r\n - Login packet
#M#Message to driver\r\n - Message to driver
#SD#150416;085139;5356.4223;N;02741.2094;E;2;330;228;9\r\n - Short data packet

i have a device it use the format i used to send data to gurtam (started with $)
and i can see its data and location in gurtam map
i think this kind of packet have a custom format...

10

post data to gurtam with python

Re: post data to gurtam with python

Wialon IPS protocol has its own format and if you want to use this protocol to send data to Wialon you have to use its format.