TK-Nodescanner.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Valid-License-Identifier: GPL-2.0-only
  5. SPDX-URL: https://spdx.org/licenses/GPL-1.0.html
  6. (c) 2012 micha@uxsrv.de
  7. """
  8. import time
  9. import struct
  10. import sys
  11. import tkinter as Tkinter
  12. import _thread as thread
  13. import nodescan
  14. title = "TK-ArtNet-Nodscaner"
  15. sys.stdout.write("\x1b]2;"+title+"\x07")
  16. node_list = []
  17. def load(event):
  18. print()
  19. print("load()")
  20. sel = int( li_nodes.curselection()[0] )
  21. print("li_nodes.get")
  22. try:
  23. sel = int(li_nodes.get(sel).split()[0])
  24. print(sel)
  25. except:
  26. return 0
  27. sel -= 1
  28. node_list[sel]
  29. clear_entry_ip()
  30. e_ip.configure(state='normal')
  31. e_ip.insert("end",node_list[sel]["IP"].replace("[","").replace("]",""))
  32. #e_ip.configure(state='readonly')
  33. e_ip_new.insert("end",node_list[sel]["IP"].replace("[","").replace("]",""))
  34. e_mac.delete("0","end")
  35. e_mac.insert("end",node_list[sel]["MAC"].replace("[","").replace("]",""))
  36. e_mac2.delete("0","end")
  37. e_mac2.insert("end",node_list[sel]["MAC"].split(":")[-1])
  38. print("load",node_list[sel])
  39. e_lname.delete("0","end")
  40. e_lname.insert("end",node_list[sel]["lname"])
  41. e_sname.delete("0","end")
  42. e_sname.insert("end",node_list[sel]["sname"])
  43. e_artnet_uni1.delete("0","end")
  44. univ = "0"
  45. print("tttttttttttttttttttttttttttttttttttttttt")
  46. try:
  47. if node_list[sel]["PortTypes"][0] == "@":
  48. univ = ord(node_list[sel]["SwIn"][0])
  49. else:
  50. univ = ord(node_list[sel]["SwOut"][0])
  51. except Exception as e:
  52. print("load Exception",e)
  53. e_artnet_uni1.insert("end",univ)
  54. def clear_entry_ip():
  55. e_ip.configure(state='normal')
  56. e_ip.delete("0","end")
  57. e_ip.configure(state='readonly')
  58. e_ip_new.delete("0","end")
  59. def clear_node():
  60. global node_list
  61. li_nodes.delete("0","end")
  62. node_list = []
  63. li_nodes.delete("0","end")
  64. def poll(delay=1):
  65. print("poll()")
  66. global old_tick
  67. clear()
  68. clear_entry_ip()
  69. clear_node()
  70. time.sleep(delay)
  71. nodescan.poll()
  72. time.sleep(0.5)
  73. old_tick = 0
  74. def clear(event= None):
  75. print("clear()")
  76. global rx
  77. rx.clear()
  78. clear_node()
  79. #poll()
  80. def poll_loop(sleep):
  81. if sleep < 1:
  82. sleep = 1
  83. time.sleep(sleep)
  84. while 1:
  85. poll()
  86. time.sleep(sleep)
  87. old_tick = 0
  88. rx = nodescan.ArtNetNodes()
  89. def _scan():
  90. global rx,node_list,old_tick,Scrollbar
  91. print("get node from cache " )
  92. li_nodes.insert("end",str("----"))
  93. rx.loop()
  94. while 1:
  95. try:
  96. __scan()
  97. except Exception as e:
  98. print("_scan Exception as",e)
  99. time.sleep(0.1)
  100. def __scan():
  101. global rx,node_list,old_tick,Scrollbar
  102. while 1:
  103. nodes = rx.get()
  104. new_tick = rx.tick()
  105. if new_tick == old_tick:
  106. continue
  107. old_tick = new_tick
  108. #print("node",nodes)
  109. if nodes:
  110. li_node_scroll = li_nodes.yview()
  111. #clear_node()
  112. #li_nodes.delete(0,"end")
  113. #print("yea",len(nodes))
  114. node_nr = 1
  115. nodesB = {}
  116. for node in nodes:
  117. k = node["MAC"]
  118. nodesB[k] = node
  119. print("k",nodesB.keys())
  120. #for node in nodes:
  121. #for k,node in nodesB.items():
  122. k_sort = list(nodesB.keys())
  123. k_sort.sort()
  124. print("k sort",k_sort)
  125. for k in k_sort:
  126. node = nodesB[k]
  127. li_nodes.insert("end",str(node_nr).rjust(3," ") +" "+ node["lname"])
  128. bg = "lightgrey"
  129. color = li_nodes.itemconfig("end", bg=bg)
  130. ip = str(node_nr).rjust(3," ") +" "+ node["IP"]
  131. bg = ""
  132. if node["PortTypes"][0] == "@":
  133. ip += " DMX-in"
  134. bg ="yellow"
  135. else:
  136. ip += " DMX-out"
  137. bg ="lightgreen"
  138. if bg:
  139. color = li_nodes.itemconfig("end", bg=bg)
  140. li_nodes.insert("end",str(node_nr).rjust(3," ") +" short Name:"+ node["sname"])
  141. li_nodes.insert("end",ip)
  142. if bg:
  143. color = li_nodes.itemconfig("end", bg=bg)
  144. inout = " UNIVERS OUT="+ str(ord(node["SwOut"][0]))+" IN="+ str(ord(node["SwIn"][0]))
  145. li_nodes.insert("end",str(node_nr).rjust(3," ") + inout)
  146. li_nodes.insert("end",str(node_nr).rjust(3," ") +" MAC:"+ node["MAC"])
  147. timeline = ""
  148. timeline += " LASTCHANGE:%0.1f"% (time.time()-float(node["UPDATESTAMP"]) )
  149. REFRESHSTAMP = time.time()-float(node["REFRESHSTAMP"])
  150. timeline +=" LASTPING:%0.1f"% REFRESHSTAMP
  151. li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline )
  152. if node["BOOT"]:
  153. BOOT = time.time()-float(node["BOOT"])
  154. else:
  155. BOOT = 0
  156. timeline =" BOOT:%0.1f"% BOOT
  157. li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline +" sec" )
  158. bg = ""
  159. #if REFRESHSTAMP > 5 :
  160. # bg="red"
  161. #else:
  162. # bg="lightgreen"
  163. if bg:
  164. li_nodes.itemconfig("end", bg=bg)
  165. #li_nodes.insert("end",str(node_nr).rjust(3," ")
  166. #li_nodes.insert("end","")
  167. li_nodes.insert("end","*"*60)
  168. #li_nodes.itemconfig("end", bg="brown")
  169. node_nr += 1
  170. node_list += [node]
  171. #Scrollbar.set('0', '0.1')
  172. print(li_node_scroll)
  173. #print(dir(li_nodes))
  174. #li_node_scroll = int(li_node_scroll[0])
  175. #li_nodes.yview_moveto(li_node_scroll)
  176. time.sleep(0.2)
  177. def get_new_ip(event=None):
  178. b = e_ip_new.get().replace("[","").replace("]","")
  179. return b
  180. def get_new_ip_str(event=None):
  181. x = get_new_ip()
  182. #x = x[1:-1]
  183. x = x.strip()
  184. #x = x.replace(",",".")
  185. x = x.replace(" ","")
  186. x = x.split(",")
  187. print( "get_new_ip_str",x)
  188. return x
  189. def send_artaddr(event=None):
  190. ln = e_lname.get()
  191. sn = e_sname.get()
  192. ip = e_ip_new.get()
  193. ip = ip.replace(" ","")
  194. ip = ip.replace(",",".")
  195. univ = e_artnet_uni1.get()
  196. print("SEND ArtAddress:",[ln,sn,ip,univ])
  197. if ln and sn and ip and univ:
  198. nodescan.ArtAddress(ip=ip ,ShortName=sn, LongName=ln,Port="",Universes=univ)
  199. time.sleep(1)
  200. poll()
  201. def send_none(event=None):
  202. pass
  203. def send_mac(event=None):
  204. #new_mac = "CMD MAC6 " + hex(e_mac2.get()) #)
  205. #new_mac = "CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16))).decode()
  206. new_mac = b"CMD MAC6 " + struct.pack("<B",(int(e_mac2.get(),16)))
  207. a = e_ip.get().replace("[","").replace("]","")
  208. cur_ip = []
  209. for i in a.split(","):
  210. cur_ip +=[int(i)]
  211. print("SEND MAC:",cur_ip,new_mac)
  212. nodescan.send_node_cmd(cur_ip,cmd=new_mac)
  213. #poll(1.5)
  214. def send_dmx_store(event=None):
  215. cmd = "CMD DMX STORE "
  216. a = e_ip.get().replace("[","").replace("]","")
  217. cur_ip = []
  218. for i in a.split(","):
  219. cur_ip +=[int(i)]
  220. print("SEND:",cur_ip,cmd)
  221. nodescan.send_node_cmd(cur_ip,cmd)
  222. poll(1.5)
  223. def send_cmd(event=None):
  224. cmd = e_cmd.get() #"CMD DMX STORE "
  225. _send_cmd(cmd=cmd)
  226. def send_cmd2(event=None):
  227. cmd = e_cmd2.get() #"CMD DMX STORE "
  228. _send_cmd(cmd=cmd)
  229. def send_cmd3(event=None):
  230. cmd = e_cmd3.get() #"CMD DMX STORE "
  231. _send_cmd(cmd=cmd)
  232. def send_cmd4(event=None):
  233. cmd = e_cmd4.get() #"CMD DMX STORE "
  234. _send_cmd(cmd=cmd)
  235. def send_cmd5(event=None):
  236. cmd = e_cmd5.get() #"CMD DMX STORE "
  237. _send_cmd(cmd=cmd)
  238. def _send_cmd(event=None,cmd=""):
  239. #cmd = e_cmd.get() #"CMD DMX STORE "
  240. cmd = cmd.split(" ")
  241. value = cmd[-1]
  242. try:
  243. value = struct.pack("<B",int(value))
  244. except:pass
  245. cmd = cmd[:-1] #.append(value)
  246. cmd.append(value)
  247. print("_send_cmd:",cmd)
  248. cmd=" ".join(map(str,cmd) )
  249. a = e_ip.get().replace("[","").replace("]","")
  250. cur_ip = []
  251. sep = "xx"
  252. if "," in a:
  253. sep = ","
  254. if "." in a:
  255. sep = "."
  256. for i in a.split(sep):
  257. cur_ip +=[int(i)]
  258. print("SEND:",cur_ip,cmd)
  259. nodescan.send_node_cmd(cur_ip,cmd)
  260. #poll(1.5)
  261. def set_ip(event=None):
  262. print("SET NEW IP")
  263. cur_ip=(2,0,0,94)
  264. new_ip=(2,0,0,201)
  265. new_netmask=(255,0,0,0)
  266. a = e_ip.get().replace("[","").replace("]","")
  267. b = e_ip_new.get().replace("[","").replace("]","")
  268. c = variable.get() #e_mask_new.get()
  269. new_netmask = [] #c.split(".") #list(c)
  270. for i in c.split("."):
  271. new_netmask +=[int(i)]
  272. cur_ip = []
  273. for i in a.split(","):
  274. cur_ip +=[int(i)]
  275. new_ip = []
  276. for i in b.split(","):
  277. new_ip +=[int(i)]
  278. if new_ip == cur_ip:
  279. print("neu und als IP sind gleich" )
  280. return 0
  281. #cur_ip=(2,0,0,94)
  282. #new_ip=(2,0,0,201)
  283. print("new",[cur_ip, new_ip, new_netmask])
  284. print()
  285. nodescan.set_ip4(cur_ip,new_ip, new_netmask)
  286. poll(1.5)
  287. def set_node_pin(evnet=None):
  288. cmd = "CMD DMX=PIN"
  289. ip = get_new_ip_str()
  290. print("ip",[ip])
  291. nodescan.send_node_cmd(ip,cmd=cmd)
  292. poll(1.5)
  293. def set_node_in(evnet=None):
  294. cmd="CMD DMX=IN"
  295. ip = get_new_ip_str()
  296. nodescan.send_node_cmd(ip,cmd=cmd)
  297. poll(1.5)
  298. def set_node_out(evnet=None):
  299. cmd="CMD DMX=OUT"
  300. ip = get_new_ip_str()
  301. nodescan.send_node_cmd(ip,cmd=cmd)
  302. poll(1.5)
  303. root = Tkinter.Tk()
  304. #root.geometry("900x700+100+100")
  305. root.geometry("900x400+100+100")
  306. root.title( title)
  307. fframe = Tkinter.Frame(root)
  308. fframe.pack(side="top",expand=0,fill="x")
  309. cframe = Tkinter.Frame(root)
  310. cframe.pack(side="top",expand=1,fill="both")
  311. font1 = ("Helvetica", 8)
  312. font2 = ("Helvetica", 10)
  313. font3 = ("Helvetica", 16)
  314. font20 = font=("Helvetica", 20)
  315. b_scan = Tkinter.Button(fframe,text="ArtNetPoll",width=10,command=poll,font=font2)
  316. b_scan.pack(side="left",expand=0,fill="y")
  317. b_scan = Tkinter.Button(fframe,text="clear",width=10,command=clear,font=font2)
  318. b_scan.pack(side="left",expand=0,fill="y")
  319. scrollbar = Tkinter.Scrollbar(cframe)
  320. scrollbar.pack(side=Tkinter.RIGHT, fill="y")
  321. #pool = Tkinter.Listbox(root,selectmode="extended",exportselection=0)
  322. li_nodes = Tkinter.Listbox(cframe,exportselection=0,width=35,font=font1)
  323. li_nodes.pack(side="left",expand=0,fill="y")
  324. li_nodes.bind("<ButtonRelease-1>",load )
  325. li_nodes.config(yscrollcommand=scrollbar.set)
  326. scrollbar.config(command=li_nodes.yview)
  327. eframe = Tkinter.Frame(cframe)
  328. eframe.pack(side="left",expand=0,fill="y")
  329. eframe1 = Tkinter.Frame(cframe)
  330. eframe1.pack(side="left",expand=0,fill="y")
  331. # ----------------------------------------------
  332. line_frame = Tkinter.Frame(eframe)
  333. line_frame.pack(side="top",expand=0,fill="x")
  334. Tkinter.Label(line_frame,text="OLD IP:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  335. e_ip = Tkinter.Entry(line_frame,font=font20,width=13,state="disabled")
  336. e_ip["bg"] = "lightgrey"
  337. e_ip.pack(side="left")
  338. #b_scan = Tkinter.Button(line_frame,width=14,font=font3)
  339. #b_scan.pack(side="left",expand=1)
  340. # ----------------------------------------------
  341. line_frame = Tkinter.Frame(eframe)
  342. line_frame.pack(side="top",expand=0,fill="x")
  343. e_ip_label = Tkinter.Label(line_frame,text=" IP:",font=font3,width=6)
  344. e_ip_label.pack(side="left",expand=0,fill="y")
  345. e_ip_new = Tkinter.Entry(line_frame,font=font20,width=13)
  346. e_ip_new.bind("<Return>", set_ip )
  347. e_ip_new.bind("<KP_Enter>", set_ip)
  348. #e_ip_new.bind("<Tab>", update_name)
  349. e_ip_new.bind("<ISO_Left_Tab>", set_ip)
  350. e_ip_new.pack(side="left")
  351. #-------------------------------------------- line
  352. line_frame = Tkinter.Frame(eframe)
  353. line_frame.pack(side="top",expand=0,fill="x")
  354. variable = Tkinter.StringVar(root)
  355. variable.set("255.0.0.0") # default value
  356. Tkinter.Label(line_frame,text="MASK",font=font3,width=6).pack(side="left",expand=0,fill="y")
  357. e_mask_new = Tkinter.OptionMenu(line_frame, variable,"255.255.255.0","255.0.0.0") #,width=10)
  358. e_mask_new.configure(font=("Helvetica", 22))
  359. e_mask_new.configure(width=10)
  360. e_mask_new["bg"] = "#fff"
  361. #heigh=1,font=("Helvetica", 20)
  362. e_mask_new.pack(side="left")
  363. #e_mask_new.insert("end","255.0.0.0")
  364. #e_mask_new.insert("end","255.255.255.0")
  365. b_scan = Tkinter.Button(line_frame,text="SEND TO NODE",command=set_ip,width=14,font=font1)
  366. b_scan.pack(side="left",expand=0)
  367. #-------------------------------------------- line
  368. line_frame = Tkinter.Frame(eframe)
  369. line_frame.pack(side="top",expand=0,fill="x")
  370. Tkinter.Label(line_frame,text="MAC:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  371. e_mac = Tkinter.Entry(line_frame,width=13,font=font20)
  372. e_mac.pack(side="left")
  373. e_mac["bg"] = "lightgrey"
  374. e_mac2 = Tkinter.Entry(line_frame,width=3,font=font20)
  375. e_mac2.pack(side="left")
  376. e_mac2.bind("<Return>", send_mac )
  377. e_mac2.bind("<KP_Enter>", send_mac)
  378. Tkinter.Button(line_frame,text="SEND TO NODE",command=send_mac,width=14,font=font1).pack(side="left",expand=0)
  379. #-------------------------------------------- line
  380. #b_scan = Tkinter.Button(eframe1,width=14,font=font3)
  381. #b_scan.pack(side="top",expand=0)
  382. line_frame = Tkinter.Frame(eframe)
  383. line_frame.pack(side="top",expand=0,fill="x")
  384. Tkinter.Label(line_frame,text="DMX:",font=font3,width=6).pack(side="left",expand=0,fill="y")
  385. b_set_node_pin = Tkinter.Button(line_frame,text="HW-PIN",command=set_node_pin,width=6,font=font3)
  386. b_set_node_pin.pack(side="left",expand=0)
  387. b_set_node_in = Tkinter.Button(line_frame,text="IN",command=set_node_in,width=6,font=font3)
  388. b_set_node_in.pack(side="left",expand=0)
  389. b_set_node_out = Tkinter.Button(line_frame,text="OUT",command=set_node_out,width=6,font=font3)
  390. b_set_node_out.pack(side="left",expand=0)
  391. #-------------------------------------------- line
  392. line_frame = Tkinter.Frame(eframe)
  393. line_frame.pack(side="top",expand=0,fill="x")
  394. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  395. e_cmd = Tkinter.Entry(line_frame,font=font3,width=16)
  396. e_cmd.bind("<Return>", send_cmd )
  397. e_cmd.pack(side="left")
  398. #-------------------------------------------- line
  399. line_frame = Tkinter.Frame(eframe)
  400. line_frame.pack(side="top",expand=0,fill="x")
  401. Tkinter.Label(line_frame,text="LName",font=font3,width=6).pack(side="left",expand=0,fill="y")
  402. e_lname = Tkinter.Entry(line_frame,font=font3,width=26)
  403. e_lname.pack(side="left")
  404. #-------------------------------------------- line
  405. line_frame = Tkinter.Frame(eframe)
  406. line_frame.pack(side="top",expand=0,fill="x")
  407. Tkinter.Label(line_frame,text="SName",font=font3,width=6).pack(side="left",expand=0,fill="y")
  408. e_sname = Tkinter.Entry(line_frame,font=font3,width=16)
  409. e_sname.pack(side="left")
  410. #-------------------------------------------- line
  411. line_frame = Tkinter.Frame(eframe)
  412. line_frame.pack(side="top",expand=0,fill="x")
  413. Tkinter.Label(line_frame,text="ArtNet",font=font3,width=6).pack(side="left",expand=0,fill="y")
  414. Tkinter.Label(line_frame,text="SUB:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  415. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
  416. e_artnet_uni1.pack(side="left")
  417. Tkinter.Label(line_frame,text="NET:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  418. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4,state="disabled")
  419. e_artnet_uni1.pack(side="left")
  420. Tkinter.Label(line_frame,text="UNI:",font=font3,width=4).pack(side="left",expand=0,fill="y")
  421. e_artnet_uni1 = Tkinter.Entry(line_frame,font=font3,width=4)
  422. e_artnet_uni1.pack(side="left")
  423. Tkinter.Button(line_frame,text="send ArtAddr",command=send_artaddr,width=14,font=font1).pack(side="left",expand=0)
  424. #-------------------------------------------- line
  425. b_scan = Tkinter.Text(eframe,width=20,font=font2)
  426. b_scan.pack(side="top",expand=1,fill="x")
  427. #-------------------------------------------- line
  428. line_frame = Tkinter.Frame(eframe1)
  429. line_frame.pack(side="top",expand=0,fill="x")
  430. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  431. e_cmd2 = Tkinter.Entry(line_frame,font=font3,width=16)
  432. e_cmd2.insert("end","DMX ERASE ")
  433. e_cmd2.bind("<Return>", send_cmd2 )
  434. e_cmd2.pack(side="left")
  435. #-------------------------------------------- line
  436. line_frame = Tkinter.Frame(eframe1)
  437. line_frame.pack(side="top",expand=0,fill="x")
  438. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  439. e_cmd3 = Tkinter.Entry(line_frame,font=font3,width=16)
  440. e_cmd3.insert("end","DMX OUT STORE ")
  441. e_cmd3.bind("<Return>", send_cmd3 )
  442. e_cmd3.pack(side="left")
  443. #-------------------------------------------- line
  444. line_frame = Tkinter.Frame(eframe1)
  445. line_frame.pack(side="top",expand=0,fill="x")
  446. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  447. e_cmd4 = Tkinter.Entry(line_frame,font=font3,width=16)
  448. e_cmd4.insert("end","DMX OUT SET 2")
  449. e_cmd4.bind("<Return>", send_cmd4 )
  450. e_cmd4.pack(side="left")
  451. #-------------------------------------------- line
  452. line_frame = Tkinter.Frame(eframe1)
  453. line_frame.pack(side="top",expand=0,fill="x")
  454. Tkinter.Label(line_frame,text="CMD",font=font3,width=6).pack(side="left",expand=0,fill="y")
  455. e_cmd5 = Tkinter.Entry(line_frame,font=font3,width=16)
  456. e_cmd5.insert("end","REBOOT ")
  457. e_cmd5.bind("<Return>", send_cmd5 )
  458. e_cmd5.pack(side="left")
  459. thread.start_new_thread(_scan, () )
  460. nodescan.bind_cmd_node()
  461. def read_cmd_buf():
  462. b_scan.insert("end", "buf read\n" )
  463. while 1:
  464. if nodescan.node_cmd_buf_list:
  465. msg = str(nodescan.node_cmd_buf_list)
  466. print("read_cmd_buf msg",msg)
  467. nodescan.node_cmd_buf_list = []
  468. stamp = str(time.time())+"\n"
  469. stamp = time.strftime("%Y-%m-%d %X\n")
  470. b_scan.insert("end",stamp)
  471. b_scan.insert("end", msg +"\n")
  472. b_scan.see("end")
  473. time.sleep(0.1)
  474. #thread.start_new_thread(nodescan.node_cmd_recive, () )
  475. #thread.start_new_thread(read_cmd_buf, () )
  476. def _update():
  477. while 1:
  478. time.sleep(1)
  479. root.update_idletasks()
  480. def X():
  481. thread.start_new_thread(nodescan.node_cmd_recive, () )
  482. thread.start_new_thread(read_cmd_buf, () )
  483. thread.start_new_thread(_update, () )
  484. #thread.start_new_thread(node_cmd_recive, () )
  485. #send_node_cmd(ip=(2,0,0,91),cmd="DMX OUT STORE")
  486. ##nodescan.send_node_cmd(ip=(2,255,255,255),cmd="CMD GT ")
  487. #nodescan.send_node_cmd(ip,cmd=cmd)
  488. #rx.loop()
  489. z = 0
  490. time.sleep(1)
  491. poll()
  492. while 1:
  493. nodes = rx.get()
  494. #print(len(nodes))
  495. if z % 10 == 0:
  496. pass
  497. print("----")
  498. #pass#print("node count",len(nodes),rx.tick())
  499. #for node in nodes:
  500. # print(node["MAC"],node["lname"])
  501. z += 1
  502. time.sleep(0.2)
  503. print()
  504. print("time out")
  505. raw_input("ENDE")
  506. thread.start_new_thread(X,()) #node_cmd_recive, () )
  507. root.mainloop()