Skip to content

Commit

Permalink
fix(io): IOBase constructor do not update the fields id, name & descr…
Browse files Browse the repository at this point in the history
…iption

The classes extending IOBase were already updating those fields (except SerialBase).
SerialBase was the only class missing this change.

These changes allow the user to use multiple Serial interface at the same time. It
was impossible before, as Pi4J would throws IOAlreadyExistsException.

This commit "moves" the fixes for the similar issues in the SPI interface.

Ref: Pi4J#244, Pi4J#257
Closes: Pi4J#257
  • Loading branch information
fusetim committed Apr 14, 2024
1 parent dc13031 commit 102a9fd
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 12 deletions.
3 changes: 3 additions & 0 deletions pi4j-core/src/main/java/com/pi4j/io/IOBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public PROVIDER_TYPE provider(){
*/
public IOBase(PROVIDER_TYPE provider, CONFIG_TYPE config){
super();
this.id = config.id();
this.name = config.name();
this.description = config.description();
this.provider = provider;
this.config = config;
}
Expand Down
3 changes: 0 additions & 3 deletions pi4j-core/src/main/java/com/pi4j/io/gpio/GpioBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ public abstract class GpioBase<IO_TYPE extends Gpio<IO_TYPE, CONFIG_TYPE, PROVID
*/
public GpioBase(PROVIDER_TYPE provider, CONFIG_TYPE config){
super(provider, config);
this.name = config.name();
this.id = config.id();
this.description = config.description();
}

/** {@inheritDoc} */
Expand Down
3 changes: 0 additions & 3 deletions pi4j-core/src/main/java/com/pi4j/io/i2c/I2CBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public abstract class I2CBase extends IOBase<I2C, I2CConfig, I2CProvider> implem
*/
public I2CBase(I2CProvider provider, I2CConfig config) {
super(provider, config);
this.name = config.name();
this.id = config.id();
this.description = config.description();
this.isOpen = true;
}

Expand Down
3 changes: 0 additions & 3 deletions pi4j-core/src/main/java/com/pi4j/io/pwm/PwmBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ public abstract class PwmBase extends IOBase<Pwm, PwmConfig, PwmProvider> implem
*/
public PwmBase(PwmProvider provider, PwmConfig config) {
super(provider, config);
this.name = config.name();
this.id = config.id();
this.description = config.description();
for(PwmPreset preset : config.presets()){
this.presets.put(preset.name().toLowerCase().trim(), preset);
}
Expand Down
3 changes: 0 additions & 3 deletions pi4j-core/src/main/java/com/pi4j/io/spi/SpiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public abstract class SpiBase extends IOBase<Spi, SpiConfig, SpiProvider> implem
*/
public SpiBase(SpiProvider provider, SpiConfig config) {
super(provider, config);
this.name = config.name();
this.id = config.id();
this.description = config.description();
}

/** {@inheritDoc} */
Expand Down

0 comments on commit 102a9fd

Please sign in to comment.