Jump to content

Cannot use epoll with edge events in Orange Pi Lite H3


Go to solution Solved by Casi,

Recommended Posts

Posted (edited)

Hello everyone, I'm creating my coursework project and I should create my own C++ library for easier GPIO usage. I'm struggling with using epoll in my code, because it doesn't register edge events, that I specified. My code looks like this:

void somePollingFunc(std::string path) {
	int epollFD = epoll_create1(0);
	if(epollFD == -1){
		throw std::runtime_error("Failed to create epoll");
	}

	int socketToRead = open(path.c_str(), O_RDONLY | O_NONBLOCK);
	if(socketToRead < 0) {
		throw std::runtime_error(std::string("Failed to open file\nPath: ") + path.data());
	}

	// Creating epoll struct
	struct epoll_event gpioPollFD;
	gpioPollFD.data.fd = socketToRead;
	gpioPollFD.events = EPOLLET;

	// Adding gpio fd to epoll
	if(epoll_ctl(epollFD, EPOLL_CTL_ADD, socketToRead, &gpioPollFD) == -1) {
		throw std::runtime_error("Failed to add custom file descriptor to epoll");
	}
	
	char readByte;
	bool callbackStop = false;
	int pollValue;

	do {
		pollValue = epoll_wait(epollFD, &gpioPollFD, 1, 100);
		if(pollValue == 0){ continue; }
			
		if(::read(gpioPollFD.data.fd, &readByte, 1)){
			callbackStop = callback(readByte);
		}
		lseek(gpioPollFD.data.fd, 0, SEEK_SET);
	} while(!callbackStop);
	close(epollFD);
}

I checked my edge file, its value is set right, also I experimented using EPOLLIN or EPOLLPRI, they both works for every action that happen to socket

Am I missing something or such functionality doesn't work?

Edited by Casi
Posted
On 11/30/2021 at 4:31 AM, Werner said:

There is no Orange Pi Lite 3.

I'm sorry, I've meant Orange PI Lite with H3 processor. Sorry for long reply. As a newbie I have limitations for posts

  • Solution
Posted

I've found my error, I've found my error, I filtered all events with EPOLLET flag that is input-only, so it newer occured in output

  • Werner changed the title to Cannot use epoll with edge events in Orange Pi Lite H3
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines