Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Problem #6

Open
BYBDR opened this issue May 4, 2023 · 12 comments
Open

Running Problem #6

BYBDR opened this issue May 4, 2023 · 12 comments

Comments

@BYBDR
Copy link

BYBDR commented May 4, 2023

Hi, Im new at pi4j v2, Im using pi 4b and netbeans when i try to compile always get same problem,
[AWT-EventQueue-0] INFO com.pi4j.Pi4J - New auto context [AWT-EventQueue-0] INFO com.pi4j.Pi4J - New context builder [AWT-EventQueue-0] INFO com.pi4j.platform.impl.DefaultRuntimePlatforms - adding platform to managed platform map [id=raspberrypi; name=RaspberryPi Platform; priority=5; class=com.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform] [AWT-EventQueue-0] ERROR com.pi4j.library.pigpio.util.NativeLibraryLoader - Unable to load [libpi4j-pigpio.so] using path: [/lib/armhf/libpi4j-pigpio.so] java.lang.UnsatisfiedLinkError: /tmp/libpi4j-pigpio5652675114124001500.so: libpigpio.so.1: cannot open shared object file: No such file or directory

is there solution to fix it ?

Thank you

@FDelporte
Copy link
Member

Are you starting your application with sudo?

@BYBDR
Copy link
Author

BYBDR commented May 4, 2023

Hi, Thanks for your quick response,
Im try to run it at Netbeans so ı cant start it with sudo, i try all solutions for it but always stuck at 'libpi4j-pigpio.so' file

@FDelporte
Copy link
Member

just to be sure, can you build it in netbeans (as jar) and start that one with sudo java -jar your-app.jarto check if the problem is fixed?

@BYBDR
Copy link
Author

BYBDR commented May 4, 2023

now the problem is different

[AWT-EventQueue-0] INFO com.pi4j.Pi4J - New auto context [AWT-EventQueue-0] INFO com.pi4j.Pi4J - New context builder [AWT-EventQueue-0] INFO com.pi4j.platform.impl.DefaultRuntimePlatforms - adding platform to managed platform map [id=raspberrypi; name=RaspberryPi Platform; priority=5; class=com.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform] [AWT-EventQueue-0] WARN com.pi4j.library.pigpio.impl.PiGpioNativeImpl - PIGPIO ERROR: PI_INIT_FAILED; pigpio initialisation failed Exception in thread "AWT-EventQueue-0" java.lang.reflect.UndeclaredThrowableException

I have pigpio "pigpio (1.79-1+rpt1)"

@FDelporte
Copy link
Member

what dependencies do you have in your project?

@BYBDR
Copy link
Author

BYBDR commented May 5, 2023

Hi, Im just gonna use Gpio Output pins for relay control.

@BYBDR
Copy link
Author

BYBDR commented May 5, 2023

package pintest;

/**
 *
 * @author pi
 */
import com.pi4j.Pi4J;
import com.pi4j.io.gpio.digital.DigitalInput;
import com.pi4j.io.gpio.digital.DigitalOutput;
import com.pi4j.io.gpio.digital.DigitalState;
import com.pi4j.io.gpio.digital.PullResistance;
import com.pi4j.util.Console;

public class Pintest {

    /**
     * @param args the command line arguments
     */
    

    private static final int PIN_LED = 22; // PIN 15 = BCM 22

 
    public static void main(String[] args) throws InterruptedException {
        // TODO code application logic here
                var pi4j = Pi4J.newAutoContext();
          var ledConfig = DigitalOutput.newConfigBuilder(pi4j)
                .id("led")
                .name("LED Flasher")
                .address(PIN_LED)
                .shutdown(DigitalState.LOW)
                .initial(DigitalState.LOW)
                .provider("pigpio-digital-output");
        var led = pi4j.create(ledConfig);  
    led.high();
    Thread.sleep(1000);    
     led.low();
    }
    
}

Thats the code

@FDelporte
Copy link
Member

And you have these dependencies included?

    <!-- include Pi4J Core -->
    <dependency>
        <groupId>com.pi4j</groupId>
        <artifactId>pi4j-core</artifactId>
        <version>${pi4j.version}</version>
    </dependency>

    <!-- include Pi4J Plugins (Platforms and I/O Providers) -->
    <dependency>
        <groupId>com.pi4j</groupId>
        <artifactId>pi4j-plugin-raspberrypi</artifactId>
        <version>${pi4j.version}</version>
    </dependency>
    <dependency>
        <groupId>com.pi4j</groupId>
        <artifactId>pi4j-plugin-pigpio</artifactId>
        <version>${pi4j.version}</version>
    </dependency>

@BYBDR
Copy link
Author

BYBDR commented May 5, 2023

SOrry for that question but where i have to add these dependencys ?

@FDelporte
Copy link
Member

Are you using Maven or Gradle? See
https://pi4j.com/getting-started/minimal-example-application/

@BYBDR
Copy link
Author

BYBDR commented May 5, 2023

Are you using Maven or Gradle? See https://pi4j.com/getting-started/minimal-example-application/

Im using Gradle

@FDelporte
Copy link
Member

Please take a look at this example:
https://github.com/Pi4J/pi4j-example-minimal/blob/main/build.gradle#L37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants