mcled_status 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. Mode=USB # (UART / USB )
  3. Output=0
  4. Beep=0
  5. # echo "T" >/dev/ttyAMA0
  6. echo -n "Serial ledStatus v1.0 : "
  7. if [ $Mode = "UART" ]
  8. then
  9. echo -e "UART mode\n"
  10. Output=ttyAMA0
  11. else
  12. echo -e "USB mode\n"
  13. Output=ttyACM0
  14. fi
  15. stty -F /dev/ttyACM0 ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo
  16. ip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
  17. test=$(mcstatus $ip status | grep players: | awk '{print$2}' | sed 's/\x2F20//g')
  18. player1=$(mcstatus $ip status | grep players: | awk '{print$3}' | sed 's/\[\x2E//g')
  19. date_raw=$(date +%H%M)
  20. case $Beep in
  21. 0*)
  22. echo "Buzzer:OFF"
  23. echo "z" >/dev/$Output
  24. sleep 1
  25. ;;
  26. 1*)
  27. echo "Buzzer:ON"
  28. echo "Z" >/dev/$Output
  29. sleep 1
  30. ;;
  31. *)
  32. ;;
  33. esac
  34. case $date_raw in
  35. [0700-2200]*)
  36. echo "Day:ON"
  37. echo "D" >/dev/$Output
  38. sleep 1
  39. ;;
  40. [2201-0659]*)
  41. echo "Day:OFF"
  42. echo "N" >/dev/$Output
  43. sleep 1
  44. ;;
  45. *)
  46. ;;
  47. esac
  48. case $test in
  49. 0*)
  50. echo "O"
  51. echo "0" >/dev/$Output
  52. ;;
  53. 1*)
  54. if [ $player1 = "Tristus51" ]
  55. then
  56. echo "Code:Tristan only"
  57. echo "T" >/dev/$Output
  58. echo $tristan
  59. elif [ $player1 = "MisterPig51" ]
  60. then
  61. echo "Code:MisterPig only"
  62. echo "V" >/dev/$Output
  63. elif [ $player1 = "BobBadin" ]
  64. then
  65. echo "Code: Ethan Only"
  66. echo "E" >/dev/$Output
  67. else
  68. echo "1" >/dev/$Output
  69. fi
  70. ;;
  71. 2*)
  72. echo "Code: two"
  73. echo "2" >/dev/$Output
  74. ;;
  75. [3-9]|[1-2][0-0]*)
  76. echo "Code: further"
  77. echo "3" >/dev/$Output
  78. ;;
  79. *)
  80. echo $test
  81. echo "Code: Error"
  82. echo "X" >/dev/$Output
  83. ;;
  84. esac