czw., 19 gru 2019 o 14:35 Kent Gibson <warthog618@xxxxxxxxx> napisał(a): > > > + > > + ret = gpiod_line_request_both_edges_events(line, GPIOD_TEST_CONSUMER); > > + g_assert_cmpint(ret, ==, 0); > > + > > + gpiod_test_chip_set_pull(0, 4, 1); > > + usleep(10000); > > + gpiod_test_chip_set_pull(0, 4, 0); > > + usleep(10000); > > + gpiod_test_chip_set_pull(0, 4, 1); > > + usleep(10000); > > + > > I assume the sleep is to wait for the event to be generated from the > call gpiod_test_chip_set_pull, which is not guaranteed to occur before > the call returns, otherwise you can toggle the line too fast and may > miss events. Yes, this is why I put it there. Otherwise, some simulated interrupts were being dropped when they fired while the previous ones were still served. > Arbitrary sleeps in code, including tests, should be avoided as they > are brittle and obsure what you are actually waiting for. Indeed. > An alternative in this case is to add a second event fd and wait for > the event to arrive there before continuing. > I'm not sure I understand. We can't have two event fd's for the same line. Or are you thinking about setting up a second line, generating events on it and consuming them so that we can rely on the timing to make sure the events were registered for the first one too? Bart