Pi4J / pi4j-v2

Pi4J Version 2.0
Apache License 2.0
273 stars 57 forks source link

based on machine (pi5) set pwmchip to 2, Also set provider priority … #343

Closed taartspi closed 5 months ago

taartspi commented 5 months ago

…of Gpiod input/output, linuxFS i2c & pwm, so they are loaded and Pigpio is not. On all legacy Pi (! Pi5) do the opposite priority and pwmchip is 0. I still have the WEB pages updates to do.

@eitch Result, I also had to use the static way to set the Board info for selecting the pwmchip value. Repeated runs showed occasionally the Context was not set in the class, same as I hit with getPriority.

I decided on Pi5 to make the GpioD provider a higher priority then the linuxfs digital. Both higher than Pigpio on Pi5. Below are the providers loaded when all are available

Pi4
---------------------------------------------------------
PI4J PROVIDERS
----------------------------------------------------------
PROVIDERS: [6] "I/O Providers" <com.pi4j.provider.impl.DefaultProviders> 
├─ANALOG_INPUT: [0] <com.pi4j.io.gpio.analog.AnalogInputProvider> 
├─PWM: [1] <com.pi4j.io.pwm.PwmProvider> 
│ └─PROVIDER: "PiGpio PWM Provider" {pigpio-pwm} <com.pi4j.plugin.pigpio.provider.pwm.PiGpioPwmProviderImpl> {com.pi4j.plugin.pigpio.provider.pwm.PiGpioPwmProviderImpl} 
├─DIGITAL_OUTPUT: [1] <com.pi4j.io.gpio.digital.DigitalOutputProvider> 
│ └─PROVIDER: "PiGpio Digital Output (GPIO) Provider" {pigpio-digital-output} <com.pi4j.plugin.pigpio.provider.gpio.digital.PiGpioDigitalOutputProviderImpl> {com.pi4j.plugin.pigpio.provider.gpio.digital.PiGpioDigitalOutputProviderImpl} 
├─SERIAL: [1] <com.pi4j.io.serial.SerialProvider> 
│ └─PROVIDER: "PiGpio Serial Provider" {pigpio-serial} <com.pi4j.plugin.pigpio.provider.serial.PiGpioSerialProviderImpl> {com.pi4j.plugin.pigpio.provider.serial.PiGpioSerialProviderImpl} 
├─ANALOG_OUTPUT: [0] <com.pi4j.io.gpio.analog.AnalogOutputProvider> 
├─SPI: [1] <com.pi4j.io.spi.SpiProvider> 
│ └─PROVIDER: "PiGpio SPI Provider" {pigpio-spi} <com.pi4j.plugin.pigpio.provider.spi.PiGpioSpiProviderImpl> {com.pi4j.plugin.pigpio.provider.spi.PiGpioSpiProviderImpl} 
├─DIGITAL_INPUT: [1] <com.pi4j.io.gpio.digital.DigitalInputProvider> 
│ └─PROVIDER: "PiGpio Digital Input (GPIO) Provider" {pigpio-digital-input} <com.pi4j.plugin.pigpio.provider.gpio.digital.PiGpioDigitalInputProviderImpl> {com.pi4j.plugin.pigpio.provider.gpio.digital.PiGpioDigitalInputProviderImpl} 
└─I2C: [1] <com.pi4j.io.i2c.I2CProvider> 
  └─PROVIDER: "PiGpio I2C Provider" {pigpio-i2c} <com.pi4j.plugin.pigpio.provider.i2c.PiGpioI2CProviderImpl> {com.pi4j.plugin.pigpio.provider.i2c.PiGpioI2CProviderImpl} 
----------------------------------------------------------

Pi5
Pi4J PROVIDERS
----------------------------------------------------------
PROVIDERS: [6] "I/O Providers" <com.pi4j.provider.impl.DefaultProviders> 
├─ANALOG_OUTPUT: [0] <com.pi4j.io.gpio.analog.AnalogOutputProvider> 
├─DIGITAL_OUTPUT: [1] <com.pi4j.io.gpio.digital.DigitalOutputProvider> 
│ └─PROVIDER: "GpioD Digital Output (GPIO) Provider" {gpiod-digital-output} <com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalOutputProviderImpl> {com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalOutputProviderImpl} 
├─SPI: [1] <com.pi4j.io.spi.SpiProvider> 
│ └─PROVIDER: "PiGpio SPI Provider" {pigpio-spi} <com.pi4j.plugin.pigpio.provider.spi.PiGpioSpiProviderImpl> {com.pi4j.plugin.pigpio.provider.spi.PiGpioSpiProviderImpl} 
├─PWM: [1] <com.pi4j.io.pwm.PwmProvider> 
│ └─PROVIDER: "LinuxFS PWM Provider" {linuxfs-pwm} <com.pi4j.plugin.linuxfs.provider.pwm.LinuxFsPwmProviderImpl> {com.pi4j.plugin.linuxfs.provider.pwm.LinuxFsPwmProviderImpl} 
├─ANALOG_INPUT: [0] <com.pi4j.io.gpio.analog.AnalogInputProvider> 
├─DIGITAL_INPUT: [1] <com.pi4j.io.gpio.digital.DigitalInputProvider> 
│ └─PROVIDER: "GpioD Digital Input (GPIO) Provider" {gpiod-digital-input} <com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInputProviderImpl> {com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInputProviderImpl} 
├─SERIAL: [1] <com.pi4j.io.serial.SerialProvider> 
│ └─PROVIDER: "PiGpio Serial Provider" {pigpio-serial} <com.pi4j.plugin.pigpio.provider.serial.PiGpioSerialProviderImpl> {com.pi4j.plugin.pigpio.provider.serial.PiGpioSerialProviderImpl} 
└─I2C: [1] <com.pi4j.io.i2c.I2CProvider> 
  └─PROVIDER: "LinuxFS I2C Provider" {linuxfs-i2c} <com.pi4j.plugin.linuxfs.provider.i2c.LinuxFsI2CProviderImpl> {com.pi4j.plugin.linuxfs.provider.i2c.LinuxFsI2CProviderImpl} 
eitch commented 5 months ago

Furthermore, the model.getSoc() != Soc.BCM2712 is a bit cryptic, don't we have a convenience method isPi5()?

FDelporte commented 5 months ago

Furthermore, the model.getSoc() != Soc.BCM2712 is a bit cryptic, don't we have a convenience method isPi5()?

Good idea, I will add that to the BoardDetection

FDelporte commented 5 months ago

But if the user is on a Raspberry Pi 4, then it just depends which dependencies are added to their project.

From the tickets it's clear that adding the right dependencies is a problem for a lot of users. So I think the extra priority decision in the plugin can help to tell users to "include all dependencies" and let Pi4J decide which will be used.

taartspi commented 5 months ago

The linuxfs pwm does work on pi4 but only HW and the address having a different meaning I think the old code had linuxfs i2c higher than pigpio I am not sure what is less trouble for users moving to this code base if they have all providers in their pom file. I thought this made sense but Robert u don't and Frank i am not sure your preference I can agree with any plan. So maybe the way to explain your thoughts is us the pi4 output to say what provider u want for each ioType

taartspi commented 5 months ago

@eitch @FDelporte Forgot to add your names so u got notified

eitch commented 5 months ago

Ok, then lets keep it like this