Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cannot use epoll with edge events in Orange Pi Lite H3

Featured Replies

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

Solved by Casi

  • Author
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

  • Author
  • Solution

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
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.