Advertisement
Guest User

Untitled

a guest
Jan 7th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.99 KB | None | 0 0
  1. import serial
  2.  
  3. port = serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=3.0)
  4.  
  5. #serial strings
  6. #select audio
  7. a = "0ACS\r\n"
  8. #select video
  9. v = "0VCS\r\n"
  10. #select both
  11. av = "0AVS\r\n"
  12.  
  13. #outs
  14. o1 = "0CO1\r\n"
  15. o2 = "0CO2\r\n"
  16. o3 = "0CO3\r\n"
  17. o4 = "0CO4\r\n"
  18. o5 = "0CO5\r\n"
  19. o6 = "0CO6\r\n"
  20. o7 = "0CO7\r\n"
  21. o8 = "0CO8\r\n"
  22. oa = "0ALL\r\n"
  23.  
  24. #ins
  25. i1 = "0CI1\r\n"
  26. i2 = "0CI2\r\n"
  27. i3 = "0CI3\r\n"
  28. i4 = "0CI4\r\n"
  29. i5 = "0CI5\r\n"
  30. i6 = "0CI6\r\n"
  31. i7 = "0CI7\r\n"
  32. i8 = "0CI8\r\n"
  33. i0 = "0OFF\r\n"
  34.  
  35. print "VAMS 0808 ssh interface V0.2 created by luke :)"
  36. print "for a list of commands, type '?'"
  37. while True:
  38.     command = raw_input ("enter command: ")
  39.     if command == "a":
  40.         port.write(a)
  41.         print "audio selected"
  42.     elif command == "v":
  43.         port.write(v)
  44.         print "video selected"
  45.     elif command == "av":
  46.         port.write(av)
  47.         print "audio & video selected"
  48.     elif command == "o":
  49.         while True:
  50.             out = raw_input ("select output channel: ")
  51.             if out == "1":
  52.                 port.write(o1)
  53.                 print "output 1 selected"
  54.                 break
  55.             if out == "2":
  56.                 port.write(o2)
  57.                 print "output 2 selected"
  58.                 break
  59.             if out == "3":
  60.                 port.write(o3)
  61.                 print "output 3 selected"
  62.                 break
  63.             if out == "4":
  64.                 port.write(o4)
  65.                 print "output 4 selected"
  66.                 break
  67.             if out == "5":
  68.                 port.write(o5)
  69.                 print "output 5 selected"
  70.                 break
  71.             if out == "6":
  72.                 port.write(o6)
  73.                 print "output 6 selected"
  74.                 break
  75.             if out == "7":
  76.                 port.write(o7)
  77.                 print "output 7 selected"
  78.                 break
  79.             if out == "8":
  80.                 port.write(o8)
  81.                 print "output 8 selected"
  82.                 break
  83.             if out == "a":
  84.                 port.write(oa)
  85.                 print "all outputs selected"
  86.                 break
  87.             else:
  88.                 print "you've entered an invalid command."
  89.                 print "please select an output channel between 1-8 or a for all"
  90.     elif command == "i":
  91.         while True:
  92.             inp = raw_input ("select input channel: ")
  93.             if inp == "1":
  94.                 port.write(i1)
  95.                 print "input 1 selected"
  96.                 break
  97.             if inp == "2":
  98.                 port.write(i2)
  99.                 print "input 2 selected"
  100.                 break
  101.             if inp == "3":
  102.                 port.write(i3)
  103.                 print "input 3 selected"
  104.                 break
  105.             if inp == "4":
  106.                 port.write(i4)
  107.                 print "input 4 selected"
  108.                 break
  109.             if inp == "5":
  110.                 port.write(i5)
  111.                 print "input 5 selected"
  112.                 break
  113.             if inp == "6":
  114.                 port.write(i6)
  115.                 print "input 6 selected"
  116.                 break
  117.             if inp == "7":
  118.                 port.write(i7)
  119.                 print "input 7 selected"
  120.                 break
  121.             if inp == "8":
  122.                 port.write(i8)
  123.                 print "input 8 selected"
  124.                 break
  125.             if out == "0":
  126.                 port.write(i0)
  127.                 print "output switched off"
  128.                 break
  129.             else:
  130.                 print "you've entered an invalid command."
  131.                 print "please select an input channel between 1-8 or 0 for off"
  132.     elif command == "?":
  133.         print "here are a list of commands:"
  134.         print "a = select audio"
  135.         print "v = select video"
  136.         print "av = select audio and video"
  137.         print "o = output"
  138.         print "i = input"
  139.     else:
  140.         print "you've entered an invalid command."
  141.         print "for a list of usable commands, type '?'"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement