#!/usr/bin/env python3
import os
import random
import time
import socket
import sys

delay = 0.1

if len(sys.argv) <= 1:
    print("usage: ./prog $NUM_SHOOTS [$FLOAT_DELAY_BETWEEN_SHOTS]")
    exit(1)

if len(sys.argv) > 2:
    delay = float(sys.argv[2])

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("192.168.0.191", 3490))

for i in range(int(sys.argv[1])):
    a = random.randint(0, 360)
    msg = str(a) + " \r\n"
    s.send(msg.encode())
    time.sleep(delay)

