| 
																	
																	
																	
																 | 
																@ -0,0 +1,26 @@ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																/*To test the gpio class for BeagleBone Black
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																 Gerardo Marx, April/20/2020*/ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#include<iostream> // to input/output strings
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#include<fstream>
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#include<sstream>
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#define GPIO_PATH "/sys/class/gpio/gpio"
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																int main(int argc, char *argv[]){ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  if(argc!=2){ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    std::cout << "The command usage is gpio #" << std::endl; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    std::cout << "where # is the gpio number" << std:: endl; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    return 2; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  } | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  std::cout << "Starting program" << std::endl; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  int number = 44; // gpio
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  std::string path; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  std::ostringstream s; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  std::ofstream fs; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  std::string file = "direction"; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  s << GPIO_PATH << number; // gpio path
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  path = std::string(s.str()); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  fs.open((path + file).c_str()); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  fs << "output"; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  fs.close(); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  return 0; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																} |