You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
788 B

3 years ago
3 years ago
3 years ago
  1. #!/usr/bin/python
  2. import sys
  3. LED3_PATH = "/sys/class/leds/beaglebone:green:usr3"
  4. def write2LED(fileName, value, path=LED3_PATH):
  5. """This function writes the passed value to the file in the path"""
  6. fo = open(path + fileName,"w")
  7. fo.write(value)
  8. fo.close()
  9. return
  10. def removeTrigger():
  11. write2LED("/trigger", "none")
  12. return
  13. #Application Begin:
  14. print("Starting the LED Python Script")
  15. if len(sys.argv)!=2:
  16. print("Incorrect number of arguments")
  17. sys.exit(2)
  18. #More than one argument:
  19. if sys.argv[1]=="on":
  20. print("LED on")
  21. removeTrigger()
  22. write2LED("/brightness", "1")
  23. elif sys.argv[1]=="off":
  24. print("LED off")
  25. removeTrigger()
  26. write2LED(fileName="/brightness", value="0")
  27. else:
  28. print("Wrong command")
  29. print("End of Script")