-
I'm facing an issue with pi4j 2.6.0 on a Pi4, for which I need support how to analyse and track down the issue. I'm using the lib to control several GPIO as digital outputs and reading GPIO 22 as digital input. The issue is that the input event listening works reliable several times, but sporadic "suddenly" this happens: Since I got no exception i have no idea how to track this behaviour down to the root cause. The whole java program is relatively big. So i not post the whole program. If special code sections are interesting I will post this sections on request. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
To view available logging in the pi4j java files: in directory /src/main/resources Add entry org.slf4j.simpleLogger.defaultLogLevel=TRACE If you are asking more questions on this post, as your post says you moved to 2.6.0 SNAPSHOT, please copy paste the boardinfo details described here https://www.pi4j.com/documentation/board-info/ And say which providers you are using, Hopefully the trace provides some info of where normal operation faltered. |
Beta Was this translation helpful? Give feedback.
-
If having this detail captured and including a timestamp is of assistance these are more items that you can place into the properties file.
Also, you questioned whether your switch was bouncing, there is a debounce parm available. this.inputConfig1 = DigitalInput.newConfigBuilder(pi4j)
.id("Data_In")
.name("Data_In")
.address(this.dataPinNum)
.pull(PullResistance.OFF)
.debounce(10)
.provider("gpiod-digital-input"); |
Beta Was this translation helpful? Give feedback.
-
It looks like 22 is the only input pin so it has the listener. |
Beta Was this translation helpful? Give feedback.
-
I believe you are asking for details when your event fires, my suggestion is add logging into your code. Place it in the event handler and other important steps in your java code. Use the traces to document code flow when operating correctly and the steps that lead up to the problem occurring. Copied portions of java core code as an example of this coding protected Logger logger = LoggerFactory.getLogger(this.getClass());
In a method
logger.debug("[INITIALIZE] -- INITIALIZED SUCCESSFULLY"); |
Beta Was this translation helpful? Give feedback.
-
In your log i can see, that the event handler is being fired due to the different threads: pool-3-thread-1 Can you perhaps perform a head dump, when this 100% CPU utilization is reached? This does not sound good. Can you add loggers when you enter your handler, and when you leave the handler? Perhaps that may help as well a bit. |
Beta Was this translation helpful? Give feedback.
-
I am glad your issue is solved! |
Beta Was this translation helpful? Give feedback.
To view available logging in the pi4j java files:
in directory /src/main/resources
Create file simplelogger.properties
Add entry org.slf4j.simpleLogger.defaultLogLevel=TRACE
If you are asking more questions on this post, as your post says you moved to 2.6.0 SNAPSHOT, please copy paste the boardinfo details described here https://www.pi4j.com/documentation/board-info/ And say which providers you are using, Hopefully the trace provides some info of where normal operation faltered.