So I have a BeagleBone Black board (Debian distro), and I want to be able to set some GPIO
pin from a low
value to a high
value.
For achieving this I’m using the BlackLib
[1] library (a C++ library that offers general access to all beaglebone’s pins).
That library haves a class called BlackGPIO
that offers the functionality that I want.
BlackLib::BlackGPIO NSLP_pin(BlackLib::GPIO_61, BlackLib::output, BlackLib::SecureMode);
auto NSLP_pinMode = NSLP_pin.getValue();
NSLP_pin.setValue(BlackLib::high);
I expect that this lines of code will set the signal from a low
value to a high
one (the signal is low
by default).
The problem is that the signal goes high
only for about ~10ms
(measured on a scope), and after that it goes low
again.
What I do wrong?
How can I set the some GPIO
pin at a certain value, and remain like that until I change it?
[1] link.
Your asking in the wrong place. You should be asking the maintainer of the code you’re using, not here. I can tell you that wrapping the GPIO sysfs system would be trivial for even an aatuer C/C++ developer. Once you understood how sysfs applies to the gpio stuff.
I do not have any code in C/C++ i can show you but i recently wrote a very simple Nodejs ( javascript ) wrapper library for much more than just gpio but here . . . if you can read Javascript, which you should if you’re using C++ . . .
“use strict”;
var fs = require(‘fs’);
var path = “/sys/class/gpio/gpio”;
exports.read = function(pin, file){
fs.access(path + pin + “/” + file, fs.F_OK, (err) => {
if(err){throw err;}
});
return fs.readFileSync(path + pin + “/” + file, ‘utf8’);
};
exports.write = function(pin, file, value){
fs.access(path + pin + “/” + file, fs.F_OK, (err) => {
if(err){throw err;}
});
fs.writeFileSync(path + pin + “/” + file, value, ‘utf8’);
};
exports.export_pin = function(pin){
var file ="/sys/class/gpio/export";
fs.writeFileSync(file, pin, ‘utf8’);
};
exports.unexport_pin = function(pin){
var file ="/sys/class/gpio/unexport";
fs.writeFileSync(file, pin, ‘utf8’);
};
Not very difficult is it ?