From Mark CLohesy, 2 Months ago, written in C++.
This paste will die in 8 Months.
Embed
  1.  
  2.  
  3. Skip to content
  4. Using Gmail with screen readers
  5. in:sent script lcd
  6.  
  7. Conversations
  8. Scripts
  9.  
  10. Hiddensoul (Mark Clohesy) <hiddensoul@twistedsouls.com>
  11. Attachments
  12. Sat, May 2, 2015, 8:43 PM
  13. to Brodie
  14.  
  15. Here is the MODEM reboot script
  16. gargoyle-reset.py
  17.  
  18. The old LCD status script
  19. LCD-OLD.py
  20.  
  21. the new LCD Script
  22. LCD.py
  23.  
  24. and the arduino sketch for the LCD
  25. ​​shack_LCD​.ino
  26.  
  27. 4 Attachments
  28.  
  29. #!/usr/bin/python
  30. # This pings devices on LAN and WAN and displays UP/DOWN status on arduino LCD screen
  31. # The Messages for the LCD are hard coded in to the Arduino code so we only have to
  32. # send an ASCII code for each state message
  33. ####################################################################################################
  34.  
  35. import os
  36. import serial
  37. import time
  38.  
  39. # Functions ########################################################################################
  40.  
  41. # Ping Device for State and send state to arduino
  42. # Hostname = IP or name of device on network, up/down = ASCII code sent to arduino for up/down State
  43. def pingDev (hostname, up, down):
  44.         response = os.system("ping -c 1 -W 2 " + hostname)
  45.         if response == 0:
  46.                 byteSer = up
  47.         else:
  48.                 byteSer = down
  49.         time.sleep(1)
  50.         ser.write(chr(byteSer))
  51.         time.sleep(4)
  52.  
  53. # Initial Commands before main loop ################################################################
  54.  
  55. # Send Null to wake up arduino serial
  56. ser = serial.Serial('/dev/ttyUSB0', 9600)
  57. ser.write(chr(0))
  58. time.sleep(2)
  59.  
  60. #Main Loop #########################################################################################
  61.  
  62. while True:
  63.         pingDev( hostname="192.168.0.7", up=79, down=80 ); #DOROTHY (SHACK SWITCH)
  64.         pingDev( hostname="192.168.0.2", up=73, down=74 ); #OCTOPUS (MAIN SWITCH)
  65.         pingDev( hostname="192.168.0.1", up=69, down=70 ); #GARGOYLE (MODEM/ROUTER)
  66.         pingDev( hostname="110.232.242.101", up=83, down=84 ); #LOCAL WAN ADDRESS (FROM ISP)
  67.         pingDev( hostname="203.22.132.1", up=65, down=66 ); #DCSI (ISP)
  68.         pingDev( hostname="google.com", up=77, down=78 ); #GOOGLE (DNS CHECK)
  69.         pingDev( hostname="192.168.0.3", up=67, down=68 ); #SS-TITANIC (SERVER)
  70.         pingDev( hostname="192.168.0.5", up=71, down=72 ); #PHAZER (PRINTER)
  71.         pingDev( hostname="192.168.10.8", up=81, down=82 ); #FT-707 Rig PC (HIDDENPAD)
  72.         pingDev( hostname="192.168.30.2", up=75, down=76 ); #MYRRDIN (BRODIE WIRELESS DESKTOP)
  73.         pingDev( hostname="192.168.0.4", up=85, down=86 ); #LG PVR (LOUNGEROOM)
  74.         pingDev( hostname="192.168.20.1", up=87, down=88 ); #ISIS (JO-ANNES PC)
  75.         pingDev( hostname="192.168.40.1", up=89, down=90 ); #EXCALIBUR (ANGUS' PC)
  76.  
  77. ####################################################################################################
  78.  
  79.  
  80. # EOF
  81. LCD.py
  82. Displaying LCD.py.