# Echoing back commands slows down the speed that lights update but it gives # more reliability since you know when a packet is received. Set this to # false to increase the light update speed. should_echo = True #----- # bridge setup # set up the serial port for communication with # the yun's microprocessor print "Setup the Arduino bridge..." bridge = BridgeClient() # Very important! Without this comannd, communication will work # but will be significantly slower, since it will open and close # sockets in each function. bridge.begin() #----- print "Setup the UDP Socket..." # set up UDP server. Python can do a simple server # in just a few lines.. sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP sock.bind(("", UDP_PORT)) #----- # loop #repeats ad nauseam
# port for the UDP connection to bind to UDP_PORT = 10008 #----- # bridge setup # set up the serial port for communication with # the yun's microprocessor print "Setup the Arduino bridge..." bridge = BridgeClient() # Very important! Without this comannd, communication will work # but will be significantly slower, since it will open and close # sockets in each function. bridge.begin() addr = None #----- print "Setup the UDP Socket..." # set up UDP server. Python can do a simple server # in just a few lines.. sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP sock.bind(("", UDP_PORT)) sock.settimeout(1.0) #----- # loop #repeats ad nauseam