facine / easyblack Goto Github PK
View Code? Open in Web Editor NEWBeaglebone Black C++ Library for GPIO using high performance of mmap.
License: MIT License
Beaglebone Black C++ Library for GPIO using high performance of mmap.
License: MIT License
Hi there,
I am running into static initialization order issues with this library in its current form (aka the "Static initialization order fiasco" see: https://isocpp.org/wiki/faq/ctors#static-init-order ).
I was able to fix it in my case by converting the following variables to the "Construct On First Use Idiom" (described just below the above link, on the same page): PIN_INDEX, BSPM_TEMPLATE and BSPWM_TEMPLATE.
The fix (which worked for me) is below, and won't affect the function of the library, just make it more portable/predictable across different compilers. Essentially it just enforces a functional initialization order.
In the memGPIO.cpp:
add the following instead of the current static initialization of the above variables:
const std::map<std::string, const memGPIO::gpioPin> &memGPIO::PIN_INDEX() {
static const std::map<std::string, const memGPIO::gpioPin> *index = new std::map<std::string, const memGPIO::gpioPin>(memGPIO::initializePins());
return *index;
}
const std::string &memGPIO::BSPM_TEMPLATE()
{
static const std::string *tmpl = new std::string(memGPIO::initializeBSPMTemplate());
return *tmpl;
}
const std::string &memGPIO::BSPWM_TEMPLATE()
{
static const std::string *tmpl = new std::string( memGPIO::initializeBSPWMTemplate());
return *tmpl;
}
In memGPIO.hpp, replace the variable declarations with the following function declarations:
// Available PINs.
static const std::map <std::string, const gpioPin> &PIN_INDEX();
// DTS file templates.
static const std::string &BSPM_TEMPLATE();
static const std::string &BSPWM_TEMPLATE();
Finally, in memGPIO.cpp, replace all uses of PIN_INDEX with PIN_INDEX(), BSPM_TEMPLATE with BSPM_TEMPLATE(), and PSPWM_TEMPLATE with PSPWM_TEMPLATE().
Hello,
I was wondering either you are planning on adding external interrupts handling on pins in your library? That feature would help me a lot right now and I think its a great feature in general. I would aprichiate some info :).
Hello there,
I would like to use your library in my project. I am using QT Creator and arm-linux-gnueabihf-g++ (gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux) for compiling and deploying programs to BeagleBone Black. The problem I faced is that my compiller doesnt know the nullptr. Could you please tell me what version are you using?
Hello Facine,
I have a problem with your library. In my project I need to use GPIO to send aproximetly 60 Clock signals as fast as possible once per minute. Problem is, that beaglebone stops after about 3-4 hours of work (Can't connect by usb/eth, gpio not working). I tried to clean cache and bufffer cyclically every 5minutes and tried to use watchdog but without any effect. When I was using older library (iolib from element14 forum) there was no such issue. I would be greatful for any help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.