Multiple (and independant) java processes use pi4j #366
|
I have a setup where multiple and independant java processes listen (and also writes) on different GPIO ports. So these java processes do not share a single GPIO port. What needs to be taken into account? Can this setup have any interferences ? |
Replies: 3 comments
|
Hi, that's a nice use-case... but not something I didn't try myself yet. Maybe it's a good idea to do a proof-of-concept with two minimal applications that control different GPIOs? Maybe use https://www.pi4j.com/getting-started/minimal-example-application/ and start it two times with different LEDs? |
|
Like @FDelporte I didn't know the expected behavior so I tested this code using the gpiod provider. I did not test with the Pigpio provider I failed to have markup list all the code as a single piece of java code, sorry, it make it difficult to read/copy. PI4J PROVIDERSPROVIDERS: [6] "I/O Providers" <com.pi4j.provider.impl.DefaultProviders> `` package com.pi4j.test.devices.dht22; import com.pi4j.Pi4J; import java.util.concurrent.ExecutionException; public class GpioTest2 { // ledRed.blink(1, 5, TimeUnit.SECONDS); } `` |
|
As long as the different processes use different GPIOs, then there shouldn't be any problem. The same situation can arise when running a pi4j java app and a shell script or something else accessing a port the app doesn't access. |
Hi, that's a nice use-case... but not something I didn't try myself yet. Maybe it's a good idea to do a proof-of-concept with two minimal applications that control different GPIOs? Maybe use https://www.pi4j.com/getting-started/minimal-example-application/ and start it two times with different LEDs?