Giter Club home page Giter Club logo

jetsongpio's Introduction

Hits

GitHub Streak

pjueon's GitHub stats

Top Langs

Experience:

  • Currently working as a SW/algorithm developer in the medical imaging field. (2020~)
  • Skills / Tools:
    • C++, CUDA C++, Python, C#
    • Korean, Japanese, English
    • Applied Pyhsics(Bachelor's degree), Electrical Engineering(Master's degree)

Interested in:

  • Computer Vision
  • Image Processing
  • Data Analysis
  • Machine Learning / AI
  • Numerical Analysis
  • Mathematics, Physics
  • Open Source
  • GPGPU Programming
  • Software Architecture
  • Auto trading (stock, crypto currency, etc)
  • Task Automation
  • Tools for developers

jetsongpio's People

Contributors

aditya-shriwastava avatar adityashriwasatava avatar akselaase avatar anath93 avatar ark3r avatar jeanchristopheruel avatar jki757 avatar jwpleow avatar keithrausch avatar knro avatar luisfgutierrez01 avatar ohadmen avatar pjueon avatar rotolof avatar schwartzcode avatar shimmyshaman avatar ultcrt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jetsongpio's Issues

Need to improve unit test

  • Make unit tests that don't require any hw setup (ex> test_dictionary_like, test_lazy_string) run automatically on build (maybe using ctest)
  • refactoring test codes

compilation error

cant compile for some reason. Here's the output to "g++ -o simple_out.cpp -lJetsonGPIO"

/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/Scrt1.o: In function _start': (.text+0x18): undefined reference to main'
(.text+0x1c): undefined reference to `main'
collect2: error: ld returned 1 exit status

What is a `target`?

Sorry for the noob question, but what is the "target". I had a CMakeLists.txt that was building fine without a target and now I guess I need one.

"assuming you added a target called mytarget, then you can link it with:"

target_link_libraries(mytarget JetsonGPIO::JetsonGPIO)

I tried making the "target" the name of my project and the name of the executable. No dice.

Build as a static lib

Hey,
Is it possible to enable building the library as a static library, rather than a shared one?
Thanks.

I'm getting `CMake Error at CMakeLists.txt:4 (FetchContent_Declare): Unknown CMake command "FetchContent_Declare".`

CMake Error at CMakeLists.txt:3 (include): include could not find load file: FetchContent CMake Error at CMakeLists.txt:4 (FetchContent_Declare): Unknown CMake command "FetchContent_Declare". -- Configuring incomplete, errors occurred!

This is from your README where it says "Without installation
If you don't want to install the library you can add it as an external project with CMake's FetchContent:"

Maybe I made a mistake, but this is what I put in my CMakeLists.txt and tried to build


cmake_minimum_required(VERSION 3.1)

include(FetchContent)
FetchContent_Declare(
  JetsonGPIO 
  GIT_REPOSITORY https://github.com/pjueon/JetsonGPIO.git 
  GIT_TAG master
)
FetchContent_MakeAvailable(JetsonGPIO)

target_link_libraries(mytarget JetsonGPIO::JetsonGPIO)

project(MyProject)


add_executable(myexample pwm_sample.cpp)

SPI Example?

Was wondering if anyone is able to use this library for SPI communication. If so, could you please share example code?

Using library

Hi,

I was planning to use your library on Jetson Xavier NX. I am wondering if you don't mind answering couple questions about it
I am aware that you need to add pin definitions for Xavier NX, in gpio_pin_data.cpp, and couple other bits in that file. Is there anything else to add?

Thanks

M

Change PWM phase?

Hi. Thanks for making this library. Have you tried implementing a function to adaptively change PWM phase? I am thinking this function will be similar to ChangeDutyCycle(). I found a blog post that does this for SAMD21 boards but am not sure how well it translates to the Jetson NANO. I will open a pull request if I figure it out.

ChangeDutyCycle only accepts 1% increments

Hi.

I'm implementing the JetsonGPIO library on a Jetson Nano. My interest is on using few I/O and one of the PWM output. I'm checking the pin 33 PWM with this library and everything seems to work ok. By checking with an osciloscope, I'm ecountering the following issues:
1: the GPIO::PWM::ChangeDutyCycle is only accepting increments by 1%. If I command it with 0.1 value, there is no PWM output. At 0.5 value it starts to react, but the output is the same unit 1.0 is reached. The same happens with values between 1.0 to 2.0 and so on. By digging into the code, the ChangeDutyCycle functions seems to command down to nano-seconds and it seems that the math is correct.

2: the output frequency does not match the commanded frequency. For low values, such as 100, the output is correct, but as far as the commanded value increases, the output frequency is allways a little less. For instance, commanding 10.000 Hz is outputing 9987 Hz.

I would like to have some insights to correct for both problems or at least to understand them, specially for point 1.

Many thanks to everybody answering.
Roger

The type of "channel" in event module should be changed to std::string

The library supports 4 pin numbering modes: BOARD, BCM, CVM and TEGRA_SOC.
CVM and TEGRA_SOC use strings instead of numbers which correspond to signal names on the CVM/CVB connector and the Tegra SoC respectively.

So the channel is NOT always convertible to type int.

But the event module is probably implemented with assumption that the channel is always convertible to int.

For example, in wait_for_edge, add_event_detect function, std::atoi is used to convert the channel to int .
If the user is using CVM or TEGRA_SOC, these functions will throw an exception.

And callback objects use the channel argument as int type. This should be fixed too.

GPIO events triggered on modbus writes

I'm having a strange problem. We've connected 4 GPIOs as inputs to the Jetson board and configured interrupt event callbacks on each of them using a custom callback, as described in #25. We've also configured a modbus through 10.10.0.1:502 with libmodbus.

The problem we ran into is that when a modbus write is performed, it triggers the GPIO events as well. These events seems to be random - sometimes none are triggered, sometimes all of them are triggered or anything in between. As far as I can tell, the modbus and epoll libraries used to trigger the GPIO events are not related at all. However, there seems to be some interaction somewhere. Since modmus and libmodbus are also included in the problem, I realise this is probably out of the scope for this repo, but I was wondering if you had some insight into what the issue may be or where I should start looking?

I've also opened an issue on the NVidia repo (the same bug is observed with their Python library).

In the PWM sample file, how would you change the direction?

The script makes my motor go clockwise. How would I make it go counterclockwise?


#include <iostream>
// for delay function.
#include <chrono>
#include <map>
#include <string>
#include <thread>

// for signal handling
#include <signal.h>

#include <JetsonGPIO.h>

using namespace std;

inline void delay(int s) { this_thread::sleep_for(chrono::seconds(s)); }

static bool end_this_program = false;

void signalHandler(int s) { end_this_program = true; }

int main()
{
    // Pin Definitions
    int output_pin = 18;

    // When CTRL+C pressed, signalHandler will be called
    signal(SIGINT, signalHandler);

    // Pin Setup.
    // Board pin-numbering scheme
    GPIO::setmode(GPIO::BOARD);

    // set pin as an output pin with optional initial state of HIGH
    GPIO::setup(output_pin, GPIO::OUT, GPIO::HIGH);
    GPIO::PWM p(output_pin, 200);
    auto val = 75.0;
    p.start(val);

    cout << "PWM running. Press CTRL+C to exit." << endl;
    for (int i = 0; i < 4; i++){
        delay(1);
        cout << 1;
    }

    p.stop();
    GPIO::cleanup();

    return 0;
}













Cannot use add_event_detect

Hello, I'm trying to use the add_event_detect with a callback function defined as follows:

void cb_fcn(const std::string& channel){
    cout << "Inside callback" << endl;
}

my_class::my_class(int new_pinPWMA, int new_Freq)
    :p(createPWM(new_pinPWMA, new_Freq))
{
    p.start(0);
    pulse = 0;
    add_event_detect(pinEncA,RISING, cb_fcn);
}

However I get the following error when I run the code:

terminate called after throwing an instance of 'std::runtime_error'
what(): [Exception] Channel 127 is invalid (catched from: GPIO::add_event_detect())

I followed the interrupt sample but can get my implementation to work, I hope you can help me.

Thank you for your time.

Throw an exception when running wait_for_edge() in a new thread

Hello, I'm trying to use GPIO::wait_for_edge() to calculate the high level duration of a PWM signal input like this:

` struct timeval start, end;

int mode_pin = 11;
GPIO::setmode(GPIO::BOARD);
GPIO::setup(mode_pin, GPIO::IN);
int high_voltage_time;

while (!end_this_program) 
{
    GPIO::wait_for_edge(mode_pin, GPIO::Edge::RISING);
    gettimeofday(&start,NULL);
    GPIO::wait_for_edge(mode_pin, GPIO::Edge::FALLING);
    gettimeofday(&end,NULL);
    high_voltage_time = end.tv_usec - start.tv_usec;
    printf("%d\n",high_voltage_time);
}`

It works well when executed independently. But I want to check two channels at the same time. And when I create two threads to run the same function, it works well for a while (about 1 minute) and then throws the exception:

[Exception] Failure to open the /sys/class/gpio/gpio{$ch}/edge file (catched from: GPIO::wait_for_edge())
terminate called after throwing an instance of 'std::runtime_error'
what(): Failure to open the /sys/class/gpio/gpio{$ch}/edge file
Aborted (core dumped)

Do you have any clue for this? Thank you.

Unable to use class methods as callbacks

Hello, I'm trying to implement 2 magnetic encoders into my project. In order to do so I've created a script that takes two input pins, adds an interrupt to each of the pins and counts pulses. That works fine when doing inside the main function. The problem is whenever I try to fit all of this inside a class. Right now I have the following code:

class EncReader
{
private:
    int EncA;
    int EncB;
    int Pulse;
public:
    EncReader(int new_EncA, int new_EncB, double new_ts);
    void cb_fcnA(const string &channel);
    void cb_fcnB(const string &channel);
    void pulse_callback_encA();
    void pulse_callback_encB();
    void encoder_setup();
    int get_pulse();
};

EncReader::EncReader(int new_EncA, int new_EncB, double new_ts):
    EncA(new_EncA), EncB(new_EncB), Pulse(0), ts(new_ts)

{
    encoder_setup();
}

void EncReader::encoder_setup(){
    setmode(BOARD);
    setup(EncA,IN);
    setup(EncB,IN);

    add_event_detect(EncA,BOTH, cb_fcnA);
    add_event_detect(EncB,BOTH, cb_fcnB);
}

void EncReader::cb_fcnA(const string &channel){
    pulse_callback_encA();
}

void EncReader::cb_fcnB(const string &channel){
    pulse_callback_encB();
}

void EncReader::pulse_callback_encA(){             //Interrupt attached to encoder A
    if(input(EncB) == input(EncA)){
        Pulse--;
    }
    else{
        Pulse++;
    }
}

void EncReader::pulse_callback_encB(){             //Interrupt attached to encoder B
    if(input(EncA) != input(EncB)){
        Pulse--;
    }
    else{
        Pulse++;
    }
}

However, I get the following error when trying to compile:

error: invalid use of non-static member function ‘void EncReader::cb_fcnA(const string&)'
add_event_detect(EncA,BOTH, cb_fcnA);

I need to use these functions inside of the class for my project, so I don't know what else to do. Any help is appreciated.

An error while using JetsonGPIO(C++) on Tx2

I followed the instruction and installed JetsonGPIO v1.0.3, however, when I ran the sample_out.cpp, there occured( other samples failed either):

terminate called after throwing an instance of 'std::runtime_error'

what(): [Exception] [model_data]None is not in gpio_chip_dirs (catched from: GPIO::get_data())

Aborted (core dumped)

Then I used JetsonGPIO in python (sample_out.py), it worked well and pin could output. Nothing changed between two conditions. Needs a little help, thanks.

PWM not working

Hi everyone,

I'm trying to get PWM to work on my Xavier NX. I modified the code in the manner described here to get the NX to work with this library: #10

I am able to get inputs/outputs to work,

however, when testing the PWM sample code, I get this issue:

terminate called after throwing an instance of 'std::out_of_range'
what(): map::at
Aborted (core dumped)

Here's the sample code I used:

#include <iostream>
// for delay function.
#include <chrono>
#include <thread>
#include <map>
#include <string>

// for signal handling
#include <signal.h>

#include <JetsonGPIO.h>

using namespace std;

const map<string, int> output_pins{{"JETSON_XAVIER", 18}, {"JETSON_NANO", 33}, {"JETSON_NX", 33}};

//if(output_pins.find(GPIO::model) == output_pins.end() ){
//      cerr << "PWM not supported on this board\n";
//      terminate();
//}

// Pin Definitions
const int output_pin = output_pins.at(GPIO::model);

bool end_this_program = false;

inline void delay(int s){
        this_thread::sleep_for(chrono::seconds(s));
}

void signalHandler (int s){
        end_this_program = true;
}


int main(){

if(output_pins.find(GPIO::model) == output_pins.end() ){
        cerr << "PWM not supported on this board\n";
        terminate();
}


        // When CTRL+C pressed, signalHandler will be called
        signal(SIGINT, signalHandler);

        // Pin Setup.
        // Board pin-numbering scheme
        GPIO::setmode(GPIO::BOARD);

        // set pin as an output pin with optional initial state of HIGH
        GPIO::setup(output_pin, GPIO::OUT);
        GPIO::PWM p(output_pin, 50);
        p.start(5);

        cout << "PWM running. Press CTRL+C to exit." << endl;

        while(!end_this_program){
                delay(1);
        }

        p.stop();
        GPIO::cleanup();

        return 0;
}

How to prevent PWM-Destructor stopping my PWM after the program ends?

I try to write a wrapper-function in Simulink with S-Function Builder to get PWM functionality in Simulink for the Jetson Nano.
So I run p.start(DutyCycle[0]) periodically to set new frequency/dutycycle changes for every simulink step, but this leads to flickering LEDs.

I think this happens because when every Simulink step ends, the destructor of the PWM Class stops the PWM signal and the next Simulink step starts it again -> so pwm gets on and off and i have this ugly flickering.

Has someone an idea what i could do or could we build in a parameter to prevent the PWM stop?
Thank you very much.
Greetings, Tim.

Input Issue

I have an issue, my input retvel always = -1855670792, but when I use python gpio it runs normally.

An issue on Jetson Xavier NX

Hello
How are you?
Thanks for contributing this project.
I've tried to use this library on Jetson Xavier NX but failed.
Could u add to support Xavier NX?
Thanks

[FEA] Improved runtime exception handling

We're working on a fairly complex Jetson-based robotics project and this library forms an important part of the GPIO controller. I understand that your first priority is of course to properly support compilation and running on Jetson platforms. However, its often easier and more convenient to develop and test the software on desktop and deploy it on the robots' Jetsons.

The problem is that when I run software where the GPIO library is used on my desktop, I get a std::runtime_error exception seemingly generated when the GPIO singleton is instantiated (the culprit seems to be this line in my case). I'm not able to catch this exception, however, since this exception is generated and uncaught inside the GPIO API. If my client was able to catch and handle the exception, I could simply then disable the GPIO handler and eliminate all interactions with it.

My question is if there's a way to make the exception propagate out to the client where it can be handled? Alternatively, how can the code be modified to handle the exceptions internally and make the GPIO API unavailable to clients? I've tried modifying the library code to try and handle the exceptions internally, but I'm running into trouble with the _cleaner that runs at the end of the GPIO's lifetime and I can't seem to think of an easy workaround.

pullups or pulldown?

Hello:
If I were to configure the GPIO as inputs, then how do I configure the input as pull-up or pull-down?

error when run simple_out or simple_pwm

Hi

I've just followed your instruction to make and install the lib and compiled the two sample programs. I got the same error message when ran them as:

[Exception] map::at (catched from: get_data())
terminate called after throwing an instance of 'bool'
Aborted (core dumped)

I cannot figure out why this happened and please give me some advice.

I've also run the simple_out.py from "NVIDIA/jetson-gpio" and seemed OK, got no error message.

Thank you.

ps: my device in hand is Jetson-Tx2

Linking issue

Hi, I followed the guide on nVidia JetPack 4.5.1. It installed correctly, but I cannot compile anything. I always get a linking error:

g++ simple_out.cpp -lJetsonGPIO

//usr/local/lib/libJetsonGPIO.a(gpio_event.o): In function `std::thread::thread<void (&)()>(void (&)())':
gpio_event.cpp:(.text._ZNSt6threadC2IRFvvEJEEEOT_DpOT0_[_ZNSt6threadC5IRFvvEJEEEOT_DpOT0_]+0x30): undefined reference to `pthread_create'
gpio_event.cpp:(.text._ZNSt6threadC2IRFvvEJEEEOT_DpOT0_[_ZNSt6threadC5IRFvvEJEEEOT_DpOT0_]+0x34): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status

Any ideas?

Thanks

Can't access PWM object in a Custom Class

Hello, I'm trying to do a custom class in which I will manage several pins of the Jetson Nano board and I came acrross a problem when trying to add a PWM object as a data member of the class, specifying in advance the channel and the frequency it will operate as.
However, when i try to use the start method the following error pops up:

"Invalid use of member function 'GPIO::PWM myclass::p(int, int)'(did you forget the '()'?)"

Normal output and input pins instantiated from inside a class work perfectly, as I tested with another class. Please find the code below.

#include <JetsonGPIO.h>

using namespace GPIO;

class myClass
{
private:
    int channel;
    int frequency;
    PWM p (int channel = 32, int freq = 60);
public:
    myClass(int new_channel = 32, int new_freq = 50);
    void setupPWM();
    void startPWM( double dutyCycle);
};

myClass::myClass( int new_channel, int new_freq)
{
    channel = new_channel;
    frequency = new_freq;
}

void myClass::setupPWM()
{
    setwarnings(false);
    semode(BOARD);
    setup(channel, OUT, LOW);
}

void myClass::startPWM(double dutyCycle)
{
    p.start(dutyCycle);
}

I truly do not know what I'm doing wrong, as I need to be able to access all different pins from inside the same class. I don't know if there's a better way to do this, but I'd appreciate the help.

lack of multiple arguments support for some APIs

Multiple arguments support for some APIs like the Nvidia's official Jetson.GPIO is missing.

Functionally, it is not a big deal but it would be great if the library covers all public APIs of the official Jetson.GPIO.

Improve detect events skips

Hi,

Thanks for this awesome C++ implementation.
I am using the GPIO::add_event_detect(channel, GPIO::BOTH, callback_fn) feature to detect edge in Jetson AGX Xavier digital input. Environment is JP5.0.2 with docker.

I have a rotary encoder whose digital output change every 1 milliseconds from high to low (and vice versa).

The problem is when CPU load increases on Jetson to 50% or more, the add_event_detect is not able to pick up all the encoder output change. It don't detect around 30% of the edge (less callbacks) for same encoder RPM. I understand that this is not a RTOS based system, but do you have any recommendations to improve the GPIO callback performance?

thanks

Compilation error when using add_event_detect()

Hi,

I'm trying to use this library on Jetson Xavier with JetPack 4.6 and ROS-Melodic. It works fine, but...

When I add the function add_event_detection() to my code I always get compilation errors. Even with your example "button_interrupt.cpp".

So I made a new small test code:

#include <iostream>
#include <string>
#include <JetsonGPIO.h>
#include <signal.h>

bool shutdown = false;

void signalHandler(int s)
  {
  shutdown = true;
  }

void callback_fn(const std::string& channel)
  {
  std::cout << "Callback called from channel " << channel<< std::endl;
  }

int main()
  {
  signal(SIGINT, signalHandler);  

  GPIO::setmode(GPIO::BOARD);
  
  GPIO::setup(12, GPIO::IN);
 
  GPIO::add_event_detect(12, GPIO::RISING, callback_fn); // also tried GPIO::Edge::RISING
  
  while(!shutdown)
    {
    //
    }
  
  GPIO::remove_event_detect(12);
  
  GPIO::cleanup();
  
  return 0;
  }

When I remove add_event_detection(...) I can compile and run the program without errors. Here is a screenshot of the compilation error message:

compilation_error

Does anyone know how to fix this?

Greetings
Marcel

Error while trying to include JetsonGPIO Library with find_package(JetsonGPIO REQUIRED)

When following the instructions in the readme, I get the following error. I cannot find the required JetsonGPIOConfig.cmake or jetsongpio-config.cmake files anywhere on my system.

By not providing "FindJetsonGPIO.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "JetsonGPIO", but CMake did not find one.

  Could not find a package configuration file provided by "JetsonGPIO" with
  any of the following names:

    JetsonGPIOConfig.cmake
    jetsongpio-config.cmake

  Add the installation prefix of "JetsonGPIO" to CMAKE_PREFIX_PATH or set
  "JetsonGPIO_DIR" to a directory containing one of the above files.  If
  "JetsonGPIO" provides a separate development package or SDK, be sure it has
  been installed.

Max interrupt frequency

What's the maximum interrupt frequency on a pin the library allows? I'm trying to control a DC motor with encoder, with an encoder frecuency of about 20KHz but I'm not achieving the expected results.

Need support for callbacks with no argument

You don't always use the channel name in your callbacks.
Of course, you can just ignore it, but unused arguments may cause compile warnings (related to #50).

So it would be nice if callbacks with no argument can be used too.

GPIO input issue

Hi guy,
I found that an issue from your code, you don't return value in GPIO::input(const string& channel), so this function has the random value.
Please review it.
BR

@@ -557,7 +560,7 @@ int GPIO::input(const string& channel){
}

int GPIO::input(int channel){

  • input(to_string(channel));
  • return input(to_string(channel));
    }

Small issues

The requirements for the library have increased with recent commits and implementations of the callback model. I've had to install gcc version 7.5 and add the following to my projects CMakeLists file (c++11 is no longer sufficient).
add_compile_options(-std=c++14)
I'm not quite sure what of that is worth mentioning (if at all) in the README.


also... CallbackTypeSelctor is a typo mistake in latest commit

UDEV rules and Docker

Hi,

Do I need to update the UDEV rules (99-gpio.rules) on the Jetson before using this lib inside docker?
I am sorry if its already mentioned but I was not able to find it.

Thanks

Bug when you set a pin as output twice

If you set a pin as an output twice, the output stops working.

This does not work:

  GPIO::setmode(GPIO::BOARD);
  GPIO::setup(32, GPIO::OUT, 0);
  GPIO::setup(32, GPIO::OUT, 0);
  std::this_thread::sleep_for(std::chrono::milliseconds(100));
  GPIO::output(32, 1);

I think the problem is, that the pins are exported every time the setup function is called.
I did not test it with input or pwm pins, or switching from input to output.

I use some other library that calls the GPIO library and in there, the pin needs the possibility to change the direction.

To solve the problem, I tried to check in the _setup_single_out function if the ch_info.f_direction stream is opened and only call _export_gpio if it's not. But this broke my i2c port and I have no idea why.

Library JetsonGPIO - add_event_detect

Hi all!

i'm using "add_event_detect" to detect a button click signal to snap photos. But i can't retrieve the context of my class.

A few lines of my code:
//---------------------------------------------------------------------------
void Snap(int iPin, void* ptr)
{
MyGPIO* pGpio = (MyGPIO*)ptr;
};

                          //---------------------------------------------------------------------------
                          MyGPIO::MyGPIO() {};
                          
                          //---------------------------------------------------------------------------
                          MyGPIO::~MyGPIO() {};
                          
                          //---------------------------------------------------------------------------
                          bool MyGPIO::LoadGPIO()
                          {
                              int iPin = 18;
                              GPIO::setup(iPin, GPIO::IN);
                              GPIO::add_event_detect(iPin, GPIO::Edge::RISING, Snap, 50);
                          }

¿Any idea?
thanks!!

PWM Pin 32 does not work

When using pin mode GPIO::BOARD, attempting to instantiate a PWM object with pin 32 fails.

The pwm_dir variable is not properly initialized in channelinfo on line 405 of gpio_pin_data.cpp, and as a result the map entry for pwm pin 32 leaves the pwm_dir variable blank, which leaves the rest of the code unable to work with it.

I'm not certain what the cause of this is, but a working fix is to add this line

if (pinName == "32"){pwm_dir(x.PWMSysfsDir);}

immediately after line 393 of the same file. I assume there is some issue with the initialization of the pwm_dir variable that this fixes.

Docker container

Hello, I've a question.
How can I use the library from within docker container ?
I'm using Jetson nano

Jetpack 4.6 -- error: ‘enable_if_t’ in namespace ‘std’ does not name a template type template <class T, class = std::enable_if_t<!std::is_same<std::decay_t<T>, Callback>::value>

Getting this below after upgrading to jetpack 4.6

/usr/local/include/JetsonGPIO.h:164:39: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
template <class T, class = std::enable_if_t<!std::is_same<std::decay_t, Callback>::value>>
^~~~~~~~~~~
/usr/local/include/JetsonGPIO.h:164:50: error: expected ‘>’ before ‘<’ token
template <class T, class = std::enable_if_t<!std::is_same<std::decay_t, Callback>::value>>
^
/usr/local/include/JetsonGPIO.h: In lambda function:
/usr/local/include/JetsonGPIO.h:167:83: error: ‘decay_t’ is not a member of ‘std’
comparer([](const func_t& A, const func_t& B) { return comparer_impl<std::decay_t>(A, B); })
^~~~~~~
/usr/local/include/JetsonGPIO.h:167:83: note: suggested alternative: ‘decay’
comparer([](const func_t& A, const func_t& B) { return comparer_impl<std::decay_t>(A, B); })
^~~~~~~
decay
/usr/local/include/JetsonGPIO.h:167:83: error: ‘decay_t’ is not a member of ‘std’
/usr/local/include/JetsonGPIO.h:167:83: note: suggested alternative: ‘decay’
comparer([](const func_t& A, const func_t& B) { return comparer_impl<std::decay_t>(A, B); })
^~~~~~~
decay
/usr/local/include/JetsonGPIO.h:167:64: error: parse error in template argument list
comparer([](const func_t& A, const func_t& B) { return comparer_impl<std::decay_t>(A, B); })
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/JetsonGPIO.h: At global scope:
/usr/local/include/JetsonGPIO.h:210:54: error: could not convert ‘nullptr’ from ‘std::nullptr_t’ to ‘const GPIO::Callback&’
unsigned long bounce_time = 0);
^
/usr/local/include/JetsonGPIO.h:211:115: error: could not convert ‘nullptr’ from ‘std::nullptr_t’ to ‘const GPIO::Callback&’
void add_event_detect(int channel, Edge edge, const Callback& callback = nullptr, unsigned long bounce_time = 0);
^
app_plunger/CMakeFiles/motor.dir/build.make:62: recipe for target 'app_plunger/CMakeFiles/motor.dir/src/motor.cpp.o' failed
make[2]: *** [app_plunger/CMakeFiles/motor.dir/src/motor.cpp.o] Error 1
CMakeFiles/Makefile2:984: recipe for target 'app_plunger/CMakeFiles/motor.dir/all' failed
make[1]: *** [app_plunger/CMakeFiles/motor.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/afrid/Desktop/release_v2.1/release_v2.1/piece_level/src/app_plunger/src/sw_trigger.cpp:6:0:
/usr/local/include/JetsonGPIO.h:164:39: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
template <class T, class = std::enable_if_t<!std::is_same<std::decay_t, Callback>::value>>
^~~~~~~~~~~
/usr/local/include/JetsonGPIO.h:164:50: error: expected ‘>’ before ‘<’ token
template <class T, class = std::enable_if_t<!std::is_same<std::decay_t, Callback>::value>>
^
/usr/local/include/JetsonGPIO.h: In lambda function:
/usr/local/include/JetsonGPIO.h:167:83: error: ‘decay_t’ is not a member of ‘std’
er([](const func_t& A, const func_t& B) { return comparer_impl<std::decay_t>(A, B); })
^~~~~~~
/usr/local/include/JetsonGPIO.h:167:83: note: suggested alternative: ‘decay’
er([](const func_t& A, const func_t& B) { return comparer_impl<std::decay_t>(A, B); })
^~~~~~~
decay
/usr/local/include/JetsonGPIO.h:167:83: error: ‘decay_t’ is not a member of ‘std’
/usr/local/include/JetsonGPIO.h:167:83: note: suggested alternative: ‘decay’
er([](const func_t& A, const func_t& B) { return comparer_impl<std::decay_t>(A, B); })
^~~~~~~
decay
/usr/local/include/JetsonGPIO.h:167:64: error: parse error in template argument list
comparer([](const func_t& A, const func_t& B) { return comparer_impl<std::decay_t>(A, B); })
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/JetsonGPIO.h: At global scope:
/usr/local/include/JetsonGPIO.h:210:54: error: could not convert ‘nullptr’ from ‘std::nullptr_t’ to ‘const GPIO::Callback&’
unsigned long bounce_time = 0);
^
/usr/local/include/JetsonGPIO.h:211:115: error: could not convert ‘nullptr’ from ‘std::nullptr_t’ to ‘const GPIO::Callback&’
Edge edge, const Callback& callback = nullptr, unsigned long bounce_time = 0);
^
app_plunger/CMakeFiles/Trigger.dir/build.make:62: recipe for target 'app_plunger/CMakeFiles/Trigger.dir/src/sw_trigger.cpp.o' failed
make[2]: *** [app_plunger/CMakeFiles/Trigger.dir/src/sw_trigger.cpp.o] Error 1
CMakeFiles/Makefile2:1341: recipe for target 'app_plunger/CMakeFiles/Trigger.dir/all' failed
make[1]: *** [app_plunger/CMakeFiles/Trigger.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

pre-build script

Rough ideas:

  • Apply clangformat to all the source files.
  • Check if all the files start with the copyright comments.
  • Automatically generate Model.h file from the configuration file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.