Created
August 12, 2016 22:29
-
-
Save GalNissim/e7cc0e25ec785706f1055f2cc3628ddb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import sys | |
| from time import sleep | |
| def get_command_msg(id): | |
| return "_GPHD_:%u:%u:%d:%1lf\n" % (0, 0, 2, 0) | |
| UDP_IP = "10.5.5.9" | |
| UDP_PORT = 8554 | |
| KEEP_ALIVE_PERIOD = 2500 | |
| KEEP_ALIVE_CMD = 2 | |
| MESSAGE = get_command_msg(KEEP_ALIVE_CMD) | |
| print("UDP target IP:", UDP_IP) | |
| print("UDP target port:", UDP_PORT) | |
| print("message:", MESSAGE) | |
| if sys.version_info.major >= 3: | |
| MESSAGE = bytes(MESSAGE, "utf-8") | |
| while True: | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| sock.sendto(MESSAGE, (UDP_IP, UDP_PORT)) | |
| sleep(KEEP_ALIVE_PERIOD/1000) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment