hello, your script like this

Code:
--------------------
    import sys, string, select
  from socket import *
  import RPi.GPIO as GPIO
  
  # Define maximum xPL message size
  buff = 1500
  
  # Define xPL base port
  port = 3865
  
  # Sub routine for sending a heartbeat
  def SendHeartbeat() :
  hbSock = socket(AF_INET,SOCK_DGRAM)
  hbSock.setsockopt(SOL_SOCKET,SO_BROADCAST,1)
  msg = 
"xpl-stat\n{\nhop=1\nsource=johnb-monitor.python\ntarget=*\n}\nhbeat.app\n{\ninterval=5\nport="
 + str(port) + "\n}\n"
  hbSock.sendto(msg,("192.168.1.255",3865))
  
  
  # Initialise the socket
  UDPSock = socket(AF_INET,SOCK_DGRAM)
  addr = ("0.0.0.0",port)
  
  # Try and bind to the base port
  try :
  UDPSock.bind(addr)
  except :
  # A hub is running, so bind to a high port
  port = 50000
  
  addr = ("192.168.1.39",port)
  try :
  UDPSock.bind(addr)
  except :
  port += 1
  
  print "xPL Monitor for Python, bound to port " + str(port)
  
  SendHeartbeat()
  
  while 1==1 :
  readable, writeable, errored = select.select([UDPSock],[],[],60)
  
  if len(readable) == 1 :
  data,addr = UDPSock.recvfrom(buff)
  print data
  radioname = "Esszimmer"
  if radioname in data :
  if "POWER=1" in data :
  print radioname + " is on"
  GPIO.setmode(GPIO.BCM)
  GPIO.setwarnings(False)
  GPIO.setup(18, GPIO.OUT)
  GPIO.output(18, True)
  elif "POWER=0" in data :
  print radioname + " is off"
  GPIO.setmode(GPIO.BCM)
  GPIO.setwarnings(False)
  GPIO.setup(18, GPIO.OUT)
  GPIO.output(18, False)
  else :
  print "other message for " + radioname
  
  
--------------------


and exactly the same ;)


------------------------------------------------------------------------
TheD6Bel's Profile: http://forums.slimdevices.com/member.php?userid=58077
View this thread: http://forums.slimdevices.com/showthread.php?t=71077

_______________________________________________
discuss mailing list
discuss@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/discuss

Reply via email to