JetsonGPIO icon indicating copy to clipboard operation
JetsonGPIO copied to clipboard

Improve detect events skips

Open automech-rb opened this issue 2 years ago • 5 comments

Hi,

Thanks for this awesome C++ implementation. I am using the GPIO::add_event_detect(channel, GPIO::BOTH, callback_fn) feature to detect edge in Jetson AGX Xavier digital input. Environment is JP5.0.2 with docker.

I have a rotary encoder whose digital output change every 1 milliseconds from high to low (and vice versa).

The problem is when CPU load increases on Jetson to 50% or more, the add_event_detect is not able to pick up all the encoder output change. It don't detect around 30% of the edge (less callbacks) for same encoder RPM. I understand that this is not a RTOS based system, but do you have any recommendations to improve the GPIO callback performance?

thanks

automech-rb avatar Sep 20 '22 08:09 automech-rb

To add, this error behaviour is easy to simulate when comparing output if 15W and MAXN mode.

For now to mitigate this issue, I am using different thread and looping at >1000hz to check digital input.

Also, #77 seems to be similar issue but for 20KHz instead of 1KHz for mine!

automech-rb avatar Sep 20 '22 23:09 automech-rb

Thanks for the report.

@ShimmyShaman Do you have any idea about this issue?

pjueon avatar Sep 26 '22 11:09 pjueon

Distracted by other life things, but I have been looking into it. Believe there are fixes that can be made, but have to test/explore them.

ShimmyShaman avatar Sep 26 '22 21:09 ShimmyShaman

@automech-rb Does this issue also occur when CPU load is low?

pjueon avatar Sep 27 '22 12:09 pjueon

From my testing, this issue only occurs with high CPU usage (over 50%). To add more details:

  • I am using two add_event_detect for two encoders running inside docker container on JP5.0.2
  • Similar error behavior is observed when compute performance is limited by changing mode to 15W (+ more erratic callback sometimes low sometimes high in same timespan for constant encoder RPM)

automech-rb avatar Sep 27 '22 12:09 automech-rb