Advertisement
Guest User

gpio set

a guest
Feb 24th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. int GPIOClass::getval_gpio(string& val){
  2.  
  3. string getval_str = "/sys/class/gpio/gpio" + this->gpionum + "/value";
  4. ifstream getvalgpio(getval_str.c_str());// open value file for gpio
  5. if (getvalgpio < 0){
  6. cout << " OPERATION FAILED: Unable to get value of GPIO"<< this->gpionum <<" ."<< endl;
  7. return -1;
  8. }
  9.  
  10. getvalgpio >> val ; //read gpio value
  11.  
  12. if(val != "0")
  13. val = "1";
  14. else
  15. val = "0";
  16.  
  17. getvalgpio.close(); //close the value file
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement