Skip to content

'Program received signal SIGABRT : Cannot set pin mode - No such device' after setting pin to gpio::mode::in. #7

@Petross404

Description

@Petross404

Hi,

I am using this code with my Adafruit FT232H:

#include <gpio++.hpp>

#include <asio.hpp>
#include <iostream>
#include <thread>

int main( int argc, char** argv )
{
	asio::io_service io;
	auto chip = gpio::get_chip(io, "0");

	auto pin = chip->pin(2);
	if( pin->supports(gpio::in) )
	{
		pin->as(gpio::mode::in); // <- Throws
		std::cout << "Success" << std::endl;
	}

	std::cout << "Monitoring pin:" << std::endl;
	pin->on_state_changed([](gpio::state s)
	{
		std::cout << "State=" << s << std::endl;
	});

	io.run();
	return 0;
}

I am getting this:

*** Program received signal SIGABRT (Aborted) ***
terminate called after throwing an instance of 'std::runtime_error'
  what():  chip:0#2: Cannot set pin mode - No such device

Some info:

$ gpioinfo 
gpiochip0 - 4 lines:
        line   0:      unnamed       unused   input  active-high 
        line   1:      unnamed       unused   input  active-high 
        line   2:      unnamed       unused   input  active-high 
        line   3:      unnamed       kernel   input  active-high [used]

I am trying to read an input event with a physical button connected to pin 2 (C8 for my board). Needless to say that using the pins as output (flashing a led) is working ok. Also, the other pins don't work for input - they crash too.

Any ideas why the library is throwing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions