Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:26:07+00:00 2026-06-12T23:26:07+00:00

I’m porting and existing system that used level triggered interrupts to an embedded Linux

  • 0

I’m porting and existing system that used level triggered interrupts to an embedded Linux device. I’m having a bit of trouble and hopefully someone can help. My plan was to use the poll() function (in user space, no plan for a low level driver) to detect when the gpio line is high. That’s the indication to do something.

Unfortunately I haven’t figured out how to enable that condition. Right now I’m doing the following:

  • Write the gpio number to /sys/class/gpio/export
  • Set the direction to “in”
  • Set the edge to ?

Can I setup the GPIO such that poll will return whenever the gpio line is high, even if poll() is called multiple times without clearing the condition, but it will wait if the line is low? Should I be using something else instead of trying to use poll()? Thanks!

Update

I thought I had a solution, but apparently not. I set the edge on the GPIO line to “rising”. On the hardware side, the line is tied to the “FIFO used” count of a data buffer. If there is data in the FIFO, the line is high. Otherwise it’s low. I then setup the following system:

GetByte() {
    Is there data in the FIFO? {
        Read a byte.
        Return
    }
    Call poll() to wait for the data {
        Is there data in the FIFO? {
            Read a byte.
            Return
        }
    }
}

The first “If” statement is there because I only read a byte at a time and poll() won’t return before the time out if the condition doesn’t change (and it won’t in my system if multiple bytes are in the FIFO). The problem I’m seeing now is that poll() will sometimes return but there isn’t any data in the FIFO. In fact, poll() returns ‘1’, but the FIFO reports that it’s empty.

I expect poll() will only detect changes when the gpioXX/value file changes from 0 to 1 due to the “rising” edge setting with the GPIO line. Is that correct? Is this a reasonable way to use poll() or should I be looking at a different design.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:26:09+00:00Added an answer on June 12, 2026 at 11:26 pm

    I finally figured out the answer. I need to read the GPIO’s value file before emptying the FIFO to ensure things are in a good state the next time poll() is called. Here’s the change to the pseudo code:

    GetByte() {
        Is there data in the FIFO? {
            Read the GPIO value file
            Read a byte.
            Return
        }
        Call poll() to wait for the data {
            Is there data in the FIFO? {
                Read a byte.
                Return
            }
        }
    }
    

    I always try to read a byte if one is available. If it’s the last byte in the FIFO, I read the GPIO value file first. I know the level triggered interrupt line is high when I do this, so I can safely clear any pending file events that poll() might see. Now I read the byte.

    Now when I call poll(), I know it won’t return unless it sees the rising edge from the interrupt. Simple fix, but it wasn’t until I read a comment in kernel/fs/sysfs/file.c until I fully understood what I needed to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.