alguien podría decir qué podría estar mal en el siguiente código C ++ para habilitar y configurar el pin no 49 (p9_23). Estoy comprobando directamente la salida en el multímetro.
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
using std::ofstream;
using namespace std;
#define gpio_path "/sys/class/gpio/"
enum GPIO_DIRECTION {INPUT,OUTPUT};
enum GPIO_SETVALUE {LOW=0, HIGH=1};
class GPIO
{
private:
int number,i;
string gpio_dir,name;
string filename,a,c,j,b,path,dir,val,value,high,low,input,output;
public:
GPIO(int number);
virtual int setdirection(GPIO_DIRECTION dir);
virtual int setpin(GPIO_SETVALUE val);
virtual int writein(string filename,string value);
virtual int write(string filename,int value);
virtual ~GPIO();
};
GPIO::GPIO(int number)
{
this->number=number;
std::ostringstream s;
s<<"gpio"<<number;
//again converting stream to string
this->name=string(s.str());
j=string(gpio_path);
this->path=j + this->name;
write("j/export",this->number);
}
int GPIO::setdirection(GPIO_DIRECTION dir)
{
switch(dir)
{
case INPUT: return this->writein("path/direction","in");
break;
case OUTPUT: return this->writein("path/direction","out");
break;
}
return -1;
}
int GPIO::setpin(GPIO_SETVALUE val)
{
switch(val)
{
case HIGH: return this->writein("path/value","1");
break;
case LOW: return this->writein("path/value","0");
break;
}
return -1;
}
int GPIO::write(string filename , int value)
{
ofstream ds;
ds.open(filename.c_str());
ds<<value;
ds.close();
return 0;
}
int GPIO:: writein(string filename , string value)
{
ofstream ls;
ls.open(filename.c_str());
ls<<value;
ls.close();
return 0;
}