Ejemplo n.º 1
0
        IP = '127.0.0.1'
    finally:
        s.close()
    return IP

# Initialize UDP Controller Server on port 10001 (BotController)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_address = ('0.0.0.0', 10001)
print('Starting up Controller Server on '+server_address[0])
sock.bind(server_address)

if (Configuration.broadcast_IP):
    sock.setblocking(0)
    sock.settimeout(0.01)

noticer = MCast.Sender()

# Fixme push the network name inside the configuration file.
myip = get_ip_address('wlan0')

if (len(myip)>0):
    myip = myip
else:
    myip = 'None'

start = time.time()
print('Multicasting my own IP address: ' + myip)
while Configuration.broadcast_IP:
    noticer.send()
    try:
        data, address = sock.recvfrom(1)
Ejemplo n.º 2
0
#coding: latin-1
import numpy as np
import cv2
import socket
import sys
import time
from connection import MCast
import os
import ConfigMe
import Configuration

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

print('Parameters:' + str(sys.argv))
# Fetch the remote ip if I do not have one.  It should be multicasted by ShinkeyBot
reporter = MCast.Receiver()

ConfigMe.createconfig("config.ini")

# Load the configuration file
lastip = ConfigMe.readconfig("config.ini")

print("Last ip used:" + lastip)

if (len(sys.argv) < 2):
    print("Waiting for Multicast Message")
    shinkeybotip = reporter.receive()
    print('Bot IP:' + shinkeybotip)
    ip = shinkeybotip
elif sys.argv[1] == '-f':
    print("Forcing IP Address")