Skip to content

Commit

Permalink
[Major] Refactored gpiod memory handling, and disposing
Browse files Browse the repository at this point in the history
Now can properly stop an IO and change to a different one. At most 10ms are required... This is due to the input listener waiting now only 10ms for a change, which is not interruptible at the moment
  • Loading branch information
eitch committed Feb 19, 2024
1 parent 6eeb129 commit 8f7042e
Show file tree
Hide file tree
Showing 24 changed files with 620 additions and 965 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Objects;

public class CWrapper {
private long cPointer;
private final long cPointer;

public CWrapper(long cPointer) {
this.cPointer = cPointer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,33 @@
package com.pi4j.library.gpiod.internal;

import java.io.Closeable;

/**
* <p>GpioChip</p>
*
* @author Alexander Liggesmeyer (<a href="https://alexander.liggesmeyer.net/">https://alexander.liggesmeyer.net/</a>)
* @version $Id: $Id
*/
public class GpioChip extends CWrapper implements Closeable {
public class GpioChip extends CWrapper {

private boolean open;
private final String name;
private final String label;
private final int numLines;

public GpioChip(long cPointer) {
GpioChip(long cPointer) {
super(cPointer);
this.open = true;
}

public boolean isOpen() {
return this.open;
}

public void close() {
if (!this.open)
return;
GpioD.chipClose(this);
this.open = false;
this.name = GpioD.chipGetName(getCPointer());
this.label = GpioD.chipGetLabel(getCPointer());
this.numLines = GpioD.chipGetNumLines(getCPointer());
}

public String getName() {
return GpioD.chipGetName(this);
return this.name;
}

public String getLabel() {
return GpioD.chipGetLabel(this);
return this.label;
}

public int getNumLines() {
return GpioD.chipGetNumLines(this);
}

public GpioLine getLine(int offset) {
return GpioD.chipGetLine(this, offset);
}

public GpioLineBulk getLines(int[] offsets) {
GpioLineBulk bulk = new GpioLineBulk();
GpioD.chipGetLines(this, offsets, bulk);
return bulk;
}

public GpioLineBulk getLines() {
GpioLineBulk bulk = new GpioLineBulk();
GpioD.chipGetAllLines(this, bulk);
return bulk;
}

public GpioLine getLine(String name) {
return GpioD.chipGetLine(this, name);
return this.numLines;
}
}

This file was deleted.

Loading

0 comments on commit 8f7042e

Please sign in to comment.