GPIO class for BBB
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.

26 lines
715 B

4 years ago
  1. /*To test the gpio class for BeagleBone Black
  2. Gerardo Marx, April/20/2020*/
  3. #include<iostream> // to input/output strings
  4. #include<fstream>
  5. #include<sstream>
  6. #define GPIO_PATH "/sys/class/gpio/gpio"
  7. int main(int argc, char *argv[]){
  8. if(argc!=2){
  9. std::cout << "The command usage is gpio #" << std::endl;
  10. std::cout << "where # is the gpio number" << std:: endl;
  11. return 2;
  12. }
  13. std::cout << "Starting program" << std::endl;
  14. int number = 44; // gpio
  15. std::string path;
  16. std::ostringstream s;
  17. std::ofstream fs;
  18. std::string file = "direction";
  19. s << GPIO_PATH << number; // gpio path
  20. path = std::string(s.str());
  21. fs.open((path + file).c_str());
  22. fs << "output";
  23. fs.close();
  24. return 0;
  25. }