nodescan_v6_2.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. This file is part of grandPA.
  5. grandPA is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 2 of the License, or
  8. (at your option) any later version.
  9. grandPA is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with grandPA. If not, see <http://www.gnu.org/licenses/>.
  15. (c) 2012 micha.rathfelder@gmail.com
  16. """
  17. print("suche ArtNet Nodes ")
  18. import time
  19. import socket, struct
  20. import sys
  21. import _thread as thread
  22. import copy
  23. import random
  24. sys.stdout.write("\x1b]2;Nodescan\x07")
  25. print(socket.AF_INET)
  26. try:
  27. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  28. sock.bind(('', 6454))
  29. sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
  30. except socket.error as e:
  31. print("Socket 6454 ", "ERR: {0} ".format(e.args))
  32. sys.exit()
  33. try:
  34. sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  35. sock2.bind(('', 6455))
  36. sock2.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
  37. except socket.error as e:
  38. print("Socket2 6454 ", "ERR: {0} ".format(e.args))
  39. sys.exit()
  40. print(socket.AF_INET)
  41. sock_cmd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  42. def bind_cmd_node():
  43. global sock_cmd
  44. try:
  45. sock_cmd.bind(('', 7601)) #7601
  46. #sock_cmd.bind(('', 49737))
  47. sock_cmd.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
  48. except socket_cmd.error as e:
  49. print("Socket 6454 ", "ERR: {0} ".format(e.args))
  50. sys.exit()
  51. if __name__ == "__main__":
  52. bind_cmd_node()
  53. def ArtNet_poll(ip,port=6454):
  54. print("POLL",[ip,port],end="")
  55. #try:
  56. if 1:
  57. sock.sendto(b'Art-Net\x00\x00 \x00\x0e\x06\x00',(ip,port)) # ArtPol / ping
  58. print(" OK ;",end="")
  59. #send_node_cmd(ip=(2,255,255,255),cmd="CMD GT ")
  60. #except Exception as e:
  61. # print("Exception ArtNet-POLL",e,)
  62. print()
  63. def ArtPollReplyDelay():
  64. time.sleep(1)
  65. ArtPollReply()
  66. def ArtPollReply():
  67. print("ArtPollReply()")
  68. port = 6454
  69. content = []
  70. header = []
  71. # Name, 7byte + 0x00
  72. content.append("Art-Net\x00")
  73. # OpCode ArtPollReply -> 0x2100, Low Byte first
  74. content.append(struct.pack('<H', 0x2100))
  75. # Protocol Version 14, High Byte first
  76. content.append(struct.pack('>H', 14))
  77. # IP
  78. #ip = [int(i) for i in self.own_ip.split('.')]
  79. ip = [2, 0, 0, 10]
  80. content += [chr(i) for i in ip]
  81. # Port
  82. content.append(struct.pack('<H', 0x1936))
  83. # Firmware Version
  84. content.append(struct.pack('>H', 200))
  85. # Net and subnet of this node
  86. net = 0
  87. subnet = 0
  88. content.append(chr(net))
  89. content.append(chr(subnet))
  90. # OEM Code (E:Cue 1x DMX Out)
  91. content.append(struct.pack('>H', 0x0360))
  92. # UBEA Version -> Nope -> 0
  93. content.append(chr(0))
  94. # Status1
  95. content.append(struct.pack('>H', 0b11010000))
  96. # Manufacture ESTA Code
  97. content.append('LL')
  98. # Short Name
  99. content.append('LOOP-OpPollReplay\x00')
  100. # Long Name
  101. content.append('LOOP-OpPollReplay_ArtNet_Node' + '_' * 34 + '\x00')
  102. content.append('\x00'*100)
  103. # stitch together
  104. content = ''.join(content)
  105. #print(self.lang['send_ArtPollReply'])
  106. #self.s.sendto(content, ("<broadcast>", self.__port))
  107. print("send" ,[content])
  108. sock.sendto(content, ("<broadcast>", port))
  109. sock.sendto(content, ("2.0.0.255", port))
  110. sock.sendto(content, ("10.10.10.255", port))
  111. sock.sendto(content, ("192.168.2.255", port))
  112. #sock.sendto(content, ("2.0.0.255", port))
  113. #sock.sendto
  114. def testBounce(ip,port):
  115. print(("TESTBOUNCE", (ip, port)))
  116. try:
  117. sock.sendto("TESTBOUNCE " +ip, (ip, port))
  118. except socket.error as e:
  119. print("Socket", "ERR: {0} ".format(e.args))
  120. print(("TESTBOUNCE", (ip, port)))
  121. def reciveBounce(timeout=10):
  122. start = time.time()
  123. while 1:
  124. data = sock.recv(500)
  125. print("bounce",data)
  126. #data, addr = sock.recvfrom(500)
  127. if data:
  128. #print(addr)
  129. print("rBounte:",data)
  130. print()
  131. if time.time() > start+timeout:
  132. print("timeout stopping reciveBounce ")
  133. break
  134. def poll():
  135. port = 6454
  136. #ip = "255.255.255.255"
  137. #ArtNet_poll(ip)
  138. #ip = "<broadcast>"
  139. #ArtNet_poll(ip)
  140. ip = "192.168.0.255"
  141. ArtNet_poll(ip)
  142. ip = "192.168.0.99"
  143. ArtNet_poll(ip)
  144. ip = "2.255.255.255"
  145. ArtNet_poll(ip)
  146. ip = "2.0.0.255"
  147. ArtNet_poll(ip)
  148. ip = "2.255.255.255"
  149. ArtNet_poll(ip)
  150. #ip = "2.0.0.255"
  151. #ArtNet_poll(ip)
  152. #ip = "2.255.255.255"
  153. #ArtNet_poll(ip)
  154. print("")
  155. class ArtNetNodes():
  156. def __init__(self):
  157. print("CONSTRUCKT:",self)
  158. self.__nodes = []
  159. self.__lock = thread.allocate_lock()
  160. self.__tick = 0
  161. #self.__lock.acquire()
  162. #self.__lock.release()
  163. def clear(self):
  164. self.__lock.acquire()
  165. self.__nodes = []
  166. self.__lock.release()
  167. def add(self,add_node):
  168. #print("ArtNetNodes.add()",add_node)
  169. #for i in add_node:
  170. # print(i,[add_node[i]])
  171. #print()
  172. #print("add",add_node)
  173. try:
  174. self.__lock.acquire()
  175. update_node = 0
  176. if "MSG" in add_node and "BOOT" in add_node["MSG"].upper():
  177. BOOT = time.time()
  178. print(" BOOOOOOOOT")
  179. else:
  180. BOOT = 0
  181. for node in self.__nodes:
  182. info = node["MAC"],node["IP"].ljust(16," "),[node["SwIn"],node["SwOut"],node["PortTypes"]]
  183. node_match = 1
  184. keys = ["MAC","SwOut","SwIn","PortTypes"]
  185. for i in keys:
  186. if node[i] != add_node[i]:
  187. node_match = 0
  188. break
  189. if node_match: # NODE MAC
  190. update_node = 0
  191. for i in add_node:
  192. UPDATECOUNTER = node["UPDATECOUNTER"]
  193. #print("update i:",i,add_node[i])
  194. if i not in node:
  195. node[i] = ""
  196. if node[i] != add_node[i]:
  197. node_match = 0
  198. update_node += 1
  199. node[i] = add_node[i]
  200. UPDATECOUNTER +=1
  201. self.__tick += 1
  202. #break
  203. if update_node:
  204. node["UPDATECOUNTER"] = UPDATECOUNTER
  205. node["UPDATESTAMP"] = time.time()
  206. node["REFRESHSTAMP"] = time.time()
  207. if BOOT:
  208. node["BOOT"] = BOOT
  209. print("UPDATE NODE".ljust(16," "),info)
  210. else:
  211. #print("NODE NOT CHANGE".ljust(16," "),info)
  212. node["REFRESHSTAMP"] = time.time()
  213. update_node = 1
  214. print("x-node:",update_node,add_node)
  215. if not update_node: # ADD NEW NODE
  216. node = add_node
  217. if node:
  218. print("add_node",node)
  219. node["BOOT"] = BOOT
  220. info = node["MAC"],node["IP"].ljust(16," "),[node["SwIn"],node["SwOut"],node["PortTypes"]]
  221. node["UPDATECOUNTER"] = 1
  222. node["REFRESHSTAMP"] = time.time()
  223. node["UPDATESTAMP"] = time.time()
  224. print("ADD NEW NODE".ljust(16," "),node["UPDATECOUNTER"],info)
  225. self.__tick += 1
  226. self.__nodes += [node]
  227. finally:
  228. #print("release lock")
  229. self.__lock.release()
  230. def tick(self):
  231. self.__lock.acquire()
  232. x = self.__tick
  233. self.__lock.release()
  234. return x
  235. return random.randint(0,1000)
  236. def get(self):
  237. self.__lock.acquire()
  238. out = []
  239. #out = {}
  240. if self.__nodes:
  241. out = copy.deepcopy(self.__nodes)
  242. #for node in self.__nodes:
  243. # out[node["MAC"]] = node
  244. self.__lock.release()
  245. return out
  246. def recive(self):
  247. print("-- NODE SCAN START ---")
  248. print()
  249. while 1:
  250. data, addr = sock.recvfrom(500)
  251. new_node = ArtNet_decode_pollreplay( data )
  252. #print("rvc loop",addr)
  253. if new_node:
  254. #print("rcv 333",new_node)
  255. self.add(new_node)
  256. time.sleep(0.001)
  257. print("-- NODE SCAN STOP ---")
  258. print()
  259. def loop(self):
  260. thread.start_new_thread(self.recive, () )
  261. time.sleep(5)
  262. poll()
  263. Reciver = ArtNetNodes
  264. def ArtNet_decode_pollreplay(data):
  265. debug = 0
  266. node = {}
  267. if len(data) >= 10: #min opcode
  268. opcode = data[8:9+1]
  269. #print([opcode])
  270. #if opcode != struct.pack("<H",0x5000): #OpPollReplay
  271. if opcode == struct.pack("<H",0x2100): #OpPollReplay
  272. if len(data) >= 207: #Mal
  273. #if debug:print("-----------------------------------------")
  274. print("===================================================================-")
  275. print("decode",data[:13])
  276. if debug:print([opcode] ,"OpPollReplay")
  277. _ip = []
  278. #print("data[10]",data[10])
  279. _ip.append( data[10] )
  280. _ip.append( data[11] )
  281. _ip.append( data[12] )
  282. _ip.append( data[13] )
  283. node["IP"] = str(_ip)
  284. if debug:print([_ip])
  285. _port = struct.unpack("<H",data[14:15+1] )
  286. #Versinfo = struct.unpack("<H",data[16:17+1] )
  287. Versinfo = data[16:17+1]
  288. node["port"] = _port
  289. if debug:print("_port :", [_port ])
  290. node["version"] = Versinfo
  291. if debug:print("Version:",[Versinfo])
  292. NetSwitch = data[18]
  293. node["NetSwitch"] = NetSwitch
  294. if debug:print("NetSwitch:",[NetSwitch])
  295. SubSwitch = data[19]
  296. node["SubSwitch"] = SubSwitch
  297. if debug:print("SubSwitch:",[SubSwitch])
  298. #oem = struct.unpack("<H",data[19:20+1] )
  299. oem = data[20:21+1]
  300. node["oem"] = oem
  301. if debug:print("oem",[oem])
  302. ubea = data[22]
  303. node["ubea"] = ubea
  304. if debug:print("ubea ver.",[ubea])
  305. stat = data[23]
  306. node["status"] = stat
  307. if debug:print("Status1 ",[stat])
  308. esta = data[24:25+1]
  309. node["esta"] = esta
  310. if debug:print("esta Manuf",[esta])
  311. sname = data[26:26+17]
  312. #if debug:print(len(sname) #17+1)
  313. sname = sname.strip(b"\x00")
  314. node["sname"] = sname
  315. lname = data[44:44+43]
  316. #if debug:print(len(lname) #43+1)
  317. lname = lname.strip(b"\x00")
  318. node["lname"] = lname
  319. NodeReport = data[108:108+20]
  320. NodeReport = NodeReport.strip(b"\x00")
  321. #if debug:print("Node",node_nr,addr)
  322. if debug:print("43r:",[sname,lname,NodeReport])
  323. NumPort = data[173]
  324. node["NumPort"] = NumPort
  325. if debug:print("NumPort",[NumPort])
  326. PortTypes = data[174:174+4]
  327. node["PortTypes"] = PortTypes
  328. if debug:print("PortTypes",[PortTypes])
  329. GoodInput = data[178:178+4]
  330. node["GoodInput"] = GoodInput
  331. if debug:print("GoodInput",[GoodInput])
  332. GoodOutput = data[182:182+4]
  333. node["GoodOutput"] = GoodOutput
  334. if debug:print("GoodOutput",[GoodOutput])
  335. SwIn = data[186:186+4]
  336. node["SwIn"] = SwIn
  337. if debug:print("SwIn",[SwIn])
  338. SwOut = data[190:190+4]
  339. node["SwOut"] = SwOut
  340. if debug:print("SwOut",[SwOut])
  341. msg = data[108:108+40]
  342. node["MSG"] = msg.replace(b"\x00",b"")#.decode(errors="ignore")
  343. if debug:print("MSG",[msg])
  344. MAC = data[201:201+6]
  345. _MAC = []
  346. for x in MAC:
  347. #x = hex(ord(x))[2:]
  348. x = hex(x)[2:]
  349. x = x.rjust(2,"0")
  350. _MAC.append(x)
  351. #hex(ord("\xf9"))[2:]
  352. if debug:print("MAC",[":".join(_MAC)])
  353. node["MAC"] = ":".join(_MAC)
  354. #node_nr += 1
  355. #if debug:print([addr,data])
  356. #print()
  357. for k,v in node.items():
  358. if type(node[k]) is bytes:
  359. node[k] = v.decode(errors="ignore")
  360. else:
  361. print(opcode, len(data))
  362. return node
  363. def set_ip4(cur_ip=(2,0,0,91),new_ip=(2,0,0,201),new_netmask=(255,0,0,0)):
  364. #send ip
  365. port = 7600
  366. #print(ip)
  367. data = []
  368. #New ip
  369. #_ip = [192, 168, 2, 91]
  370. _ip = [ 2, 0, 0, 181] # CLASS C NET
  371. _ip = [ 2, 0, 0, 101] # CLASS C NET
  372. #_ip = [192, 168, 0, 91]
  373. _ip = new_ip
  374. print("NEW NODE _ip:", _ip)
  375. data.append(struct.pack('<B', _ip[0]))
  376. data.append(struct.pack('<B', _ip[1]))
  377. data.append(struct.pack('<B', _ip[2]))
  378. data.append(struct.pack('<B', _ip[3]))
  379. #_ip = [255, 255, 255, 255] # cange all nodes in Network to the same _ip ! DANGER !
  380. #_ip = [002, 000, 000, 255] # cange all nodes in subnet to the same _ip ! DANGER !
  381. _ip = [ 2, 0, 0, 199] # CLASS A NET
  382. _ip = [192, 168, 0, 91]
  383. #_ip = [ 2, 0, 0, 191] # CLASS C NET
  384. _ip = cur_ip
  385. print("OLD NODE _ip:", _ip)
  386. #OLD _ip , Target Node to change
  387. data.append(struct.pack('<B', _ip[0]))
  388. data.append(struct.pack('<B', _ip[1]))
  389. data.append(struct.pack('<B', _ip[2]))
  390. data.append(struct.pack('<B', _ip[3]))
  391. ip = ".".join(str(x) for x in _ip)
  392. #print("send to ip:", ip)
  393. # NETMASK
  394. MASK = []
  395. netmask = [255, 255, 255 , 0] #fast CLASS C funktioniert
  396. #netmask = [255, 0, 0 , 0] #CLASS C funkioniert nicht
  397. netmask = new_netmask
  398. print("NEW NODE net:",netmask)
  399. MASK.append(struct.pack('<B', netmask[0]))
  400. MASK.append(struct.pack('<B', netmask[1]))
  401. MASK.append(struct.pack('<B', netmask[2]))
  402. MASK.append(struct.pack('<B', netmask[3]))
  403. data += MASK
  404. data += [struct.pack('<B', 255)]*11
  405. print("------------------------------")
  406. data = b'CMD IP '+ b"".join(data)
  407. print("SENDING TO ",(ip,port))
  408. print([data]) #, cur_ip=(2,0,0,91))
  409. #sock.sendto(data ,(ip,port))
  410. sock.sendto(data ,(ip,port))
  411. def send_cmd(ip=(2,0,0,91),cmd=""):
  412. node_nr = 1
  413. port = 7600
  414. print(ip)
  415. data = []
  416. _ip = [ 2, 0, 0, 91] # CLASS C NET
  417. print("NEW NODE _ip:", _ip)
  418. data.append(struct.pack('<B', _ip[0]))
  419. data.append(struct.pack('<B', _ip[1]))
  420. data.append(struct.pack('<B', _ip[2]))
  421. data.append(struct.pack('<B', _ip[3]))
  422. #_ip = [255, 255, 255, 255] # cange all nodes in Network to the same _ip ! DANGER !
  423. #_ip = [002, 000, 000, 255] # cange all nodes in subnet to the same _ip ! DANGER !
  424. _ip = [ 2, 0, 0, 199] # CLASS A NET
  425. _ip = [ 2, 0, 0, 91] # CLASS A NET
  426. #_ip = [192, 168, 0, 91]
  427. _ip = [ 2, 0, 0, 255] # CLASS C NET
  428. #_ip = [ 2, 255, 255, 255] # CLASS C NET
  429. print("OLD NODE _ip:", _ip)
  430. #OLD _ip , Target Node to change
  431. data.append(struct.pack('<B', _ip[0]))
  432. data.append(struct.pack('<B', _ip[1]))
  433. data.append(struct.pack('<B', _ip[2]))
  434. data.append(struct.pack('<B', _ip[3]))
  435. ip = ".".join(str(x) for x in ip)
  436. print("send to ip:", ip)
  437. # NETMASK
  438. MASK = []
  439. netmask = [255, 255, 255 , 0] #fast CLASS C funktioniert
  440. netmask = [255, 0, 0 , 0] #CLASS C funkioniert nicht
  441. print("NEW NODE net:",netmask)
  442. MASK.append(struct.pack('<B', netmask[0]))
  443. MASK.append(struct.pack('<B', netmask[1]))
  444. MASK.append(struct.pack('<B', netmask[2]))
  445. MASK.append(struct.pack('<B', netmask[3]))
  446. data += MASK
  447. data += [struct.pack('<B', 255)]*11
  448. print("------------------------------")
  449. data = 'CMD '+cmd+' '+ "".join(data)
  450. print("SENDING TO ",(ip,port))
  451. print([data] )
  452. #sock.sendto(data ,(ip,port))
  453. sock.sendto(data ,(ip,port))
  454. def pack_ip(_ip):
  455. data = [b"\x00",b"\x00", b"\x00", b"\x00"]
  456. if _ip:
  457. data[0] = struct.pack('<B', int(_ip[0]))
  458. data[1] = struct.pack('<B', int(_ip[1]))
  459. data[2] = struct.pack('<B', int(_ip[2]))
  460. data[3] = struct.pack('<B', int(_ip[3]))
  461. return data
  462. def send_node_cmd(ip="",ip2="",cmd=""):
  463. print()
  464. port = 7600
  465. data = []
  466. print("send_node_cmd",ip,ip2,cmd,port)
  467. data = pack_ip(ip[:])
  468. print("ip",ip,ip2)
  469. if len(ip2) == 4:
  470. ip = ip2
  471. if len(ip) == 4:
  472. ip = ".".join(map(str,ip))
  473. print("send to ip:", ip)
  474. data2=""
  475. if not cmd:
  476. data2 = 'CMD GT'
  477. data2 = 'CMD ST'
  478. data2 = 'DMX OUT STORE'
  479. data2 = 'CMD DMX=IN '
  480. data2 = 'CMD DMX=OUT '
  481. data2 = 'CMD DMX=PIN '
  482. if type(cmd) == bytes:
  483. data2 = cmd
  484. else:
  485. data2 = bytes(str(cmd),"ascii",errors="ignore")
  486. print([data2],type(data2) )
  487. data2 = data2.ljust(20,b" ") + b"".join(data)
  488. print("SENDING COMMAND TO ",[data2],(ip,port))
  489. sock.sendto(data2 ,(ip,port))
  490. node_cmd_buf_list = []
  491. def node_cmd_recive():
  492. global node_cmd_buf_list
  493. #sock.sendto('\x00\x00\x00\x00\x00',(ip,port)) # ArtPol / ping
  494. while 1:
  495. data, addr = sock_cmd.recvfrom(5000)
  496. #print(len(data))
  497. #print([addr,data])
  498. if len(data) == 207:
  499. print()
  500. else:
  501. print("NODE CMD RESPONSE:", [addr,data])
  502. node_cmd_buf_list = [addr,data]
  503. #print([data])
  504. pass
  505. time.sleep(0.05)
  506. #send_node_cmd(ip="",cmd="CMD DMX=IN")
  507. #send_node_cmd(ip="",cmd="CMD DMX=OUT")
  508. #send_node_cmd(ip=(2,0,0,91),cmd="CMD DMX=PIN")
  509. #send_node_cmd(ip=(2,0,0,91),cmd="DMX OUT STORE")
  510. #send_node_cmd(ip=(2,0,0,255),cmd="DMX OUT STORE")
  511. #send_node_cmd(ip=(2,0,0,201),cmd="DMX OUT STORE")
  512. #send_node_cmd(ip=(2,0,0,255),ip2=(2,255,255,255),cmd="DMX OUT STORE")
  513. #send_node_cmd(ip=(2,0,0,201),ip2=(2,255,255,255),cmd="DMX OUT STORE")
  514. #send_node_cmd(ip=(2,0,0,255),ip2=(2,0,0,201),cmd="DMX OUT STORE")
  515. #send_node_cmd(ip=(2,0,0,201),ip2=(2,0,0,201),cmd="DMX OUT STORE")
  516. #send_node_cmd(ip=(2,0,0,201),ip2=(255,255,255,255),cmd="DMX OUT STORE")
  517. #send_node_cmd(ip=(255,255,255,255),ip2=(255,255,255,255),cmd="DMX OUT STORE")
  518. #exit()
  519. #
  520. if __name__ == "__main__":
  521. thread.start_new_thread(node_cmd_recive, () )
  522. #send_node_cmd(ip=(2,0,0,91),cmd="DMX OUT STORE")
  523. send_node_cmd(ip=(2,255,255,255),cmd="CMD GT ")
  524. rx = ArtNetNodes()
  525. rx.loop()
  526. z = 0
  527. while 1:
  528. nodes = rx.get()
  529. #print(len(nodes))
  530. if z % 10 == 0:
  531. print()
  532. pass
  533. print("node count",len(nodes),rx.tick(),2 )
  534. #for i in nodes:
  535. #print(i)
  536. z += 1
  537. time.sleep(0.2)
  538. print()
  539. print("time out")
  540. raw_input("ENDE")