Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » Kura + External jar (ex :- Pi4j) problem(Runs only once)
Kura + External jar (ex :- Pi4j) problem [message #1496733] Wed, 03 December 2014 08:19 Go to next message
Srinivas channakeshava is currently offline Srinivas channakeshavaFriend
Messages: 15
Registered: November 2014
Junior Member
I tried a simple kura example with pi4j jars and I am facing this problem.
The bundle installs and runs only once , if you stop and rerun it doesn't run, even if you uninstall the bundle and install again also it doesn't even start. However if you reboot pi and install the bundle it runs only once and same problem repeats...

here's the code

import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.RaspiPin;

public class HelloOsgi {

private static final Logger s_logger = LoggerFactory.getLogger(HelloOsgi.class);

private static final String APP_ID = "org.eclipse.kura.example.hello_osgi";


protected void activate(){
GpioController gpio = GpioFactory.getInstance();
GpioPinDigitalOutput led1 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01);
s_logger.info("Bundle " + APP_ID + " has started!");
led1.high();
s_logger.debug(APP_ID + ": This is a debug message.");
/* for (;;) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}*/
}

protected void deactivate() {

s_logger.info("Bundle " + APP_ID + " has stopped!");
led1.low();
gpio.shutdown();

}
}

any solution???

Thanks in advance


Re: Kura + External jar (ex :- Pi4j) problem [message #1498518 is a reply to message #1496733] Thu, 04 December 2014 13:15 Go to previous messageGo to next message
Luca Dazi is currently offline Luca DaziFriend
Messages: 15
Registered: December 2014
Junior Member
Hello Srinivas,
the issue you are facing could be related to JNI support in Equinox.
Do you have some kind of errors on the kura.log log file, or even in kura-console.log?

Anyway, starting from Kura 1.1.0, we will include OpenJDK Device I/O, so GPIO support will be included directly in the kura build. No more need of Pi4J.

If you wish you can test it on the current snapshot, taking the following steps:

- download the latest kura snapshot
- build the target platform using the "dio" profile (mvn -Pdio clean install inside kura/target_platform)
- include jdk.dio in the manifest dependencies
and edit your bundle as follows:

import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jdk.dio.DeviceManager;
import jdk.dio.DeviceNotFoundException;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.gpio.GPIOPin;

public class HelloOsgi {

private static final Logger s_logger = LoggerFactory.getLogger(HelloOsgi.class);

private static final String APP_ID = "org.eclipse.kura.example.hello_osgi";


protected void activate(){
 
  s_logger.info("Bundle " + APP_ID + " is starting...");
  GPIOPin led1;
  try {
      // 17 indicates GPIO_GEN_0 on Raspberry P B+
      led1 = DeviceManager.open(17);

      led1.setValue(true);
    } catch (DeviceNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (UnavailableDeviceException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  s_logger.info("Bundle " + APP_ID + " has started!");
}

protected void deactivate() {
  led1.setValue(false);
  led1.close();
  s_logger.info("Bundle " + APP_ID + " has stopped!");
}
}


Further references on Device I/O can be found on the Kura Documentation.
Re: Kura + External jar (ex :- Pi4j) problem [message #1505599 is a reply to message #1496733] Wed, 10 December 2014 06:52 Go to previous messageGo to next message
Srinivas channakeshava is currently offline Srinivas channakeshavaFriend
Messages: 15
Registered: November 2014
Junior Member
Thank you Luca..
I have one more problem . I am using a serial communication between arduino and Rasberry pi using Kura and external library RXTXj.jar ... every thing works fine on first deployment of package .. the bundle stops , starts etc... But once you uninstall the bundle and Re-Install it shows active but doesnt work... any solution?

Thanks in advance.
Re: Kura + External jar (ex :- Pi4j) problem [message #1505604 is a reply to message #1498518] Wed, 10 December 2014 06:57 Go to previous messageGo to next message
Srinivas channakeshava is currently offline Srinivas channakeshavaFriend
Messages: 15
Registered: November 2014
Junior Member
Thank you Luca..
I have one more problem . I am using a serial communication between arduino and Rasberry pi using Kura and external library RXTXj.jar ... every thing works fine on first deployment of package .. the bundle stops , starts etc... But once you uninstall the bundle and Re-Install it shows active but doesnt work... any solution?

Thanks in advance.
Re: Kura + External jar (ex :- Pi4j) problem [message #1506120 is a reply to message #1505604] Wed, 10 December 2014 15:48 Go to previous messageGo to next message
Luca Dazi is currently offline Luca DaziFriend
Messages: 15
Registered: December 2014
Junior Member
Srinivas, can you provide the console-log file?
If there is some issue with native libraries, then we should find some related entry there.

Moreover... why are you using RXTX?
Kura ships with Soda DK Comm. In other words: no need of external serial libraries.
You can just use the CommConnectionFactory declarative service, or you can import org.eclipse.soda.dk.comm into the manifest file, and then directly use SerialPort objects.

In order to understand how the CommConnectionFactory works, you can have a look at the example.serial.publisher module.

Let me know,
Luca
Re: Kura + External jar (ex :- Pi4j) problem [message #1703797 is a reply to message #1506120] Wed, 05 August 2015 05:50 Go to previous messageGo to next message
Serhiy Povoroznyuk is currently offline Serhiy PovoroznyukFriend
Messages: 2
Registered: August 2015
Junior Member
Hello Luca,

I tried to compile org.eclipse.kura.example.serial.publisher for my Raspberry but I get error:

\org.eclipse.kura.example.serial.publisher\src\main\java\org\eclipse\kura\example\serial\publisher\ExampleSerialPublisher.java (at line 297)
m_commConnection = (CommConnection) m_connectionFactory.createConnection(uri, 1, false);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The type javax.microedition.io.Connection cannot be resolved. It is indirectly referenced from required .class files

I had problem with jdk.dio.uart also. Uart works in Pi4j but after including this lib to bundle it doesn't work.

Any solution for using uart in Kura???

Thanks in advance

P.S. using kura : kura_downloads/raspbian/release/1.2.0/kura_1.2.0_raspberry-pi-2_armv7.deb


Re: Kura + External jar (ex :- Pi4j) problem [message #1704939 is a reply to message #1703797] Tue, 11 August 2015 00:42 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
Hello,

For the serial connection, please be sure to follow this example [1] very closely. In particular pay close attention to the build.properties file.

If you need help with the UART problem, please post the errors from your kura.log and kura-console.log files.

[1] http://eclipse.github.io/kura/doc/serial-example.html

Thanks,
--Dave
Re: Kura + External jar (ex :- Pi4j) problem [message #1705089 is a reply to message #1704939] Wed, 12 August 2015 04:35 Go to previous messageGo to next message
Serhiy Povoroznyuk is currently offline Serhiy PovoroznyukFriend
Messages: 2
Registered: August 2015
Junior Member
Hello David,
I have compilation error in this case ( eclipse.github.io/kura/doc/serial-example.html ):

\org.eclipse.kura.example.serial.publisher\src\main\java\org\eclipse\kura\example\serial\publisher\ExampleSerialPublisher.java (at line 297)
m_commConnection = (CommConnection) m_connectionFactory.createConnection(uri, 1, false);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The type javax.microedition.io.Connection cannot be resolved. It is indirectly referenced from required .class files

Thanks in advance
Re: Kura + External jar (ex :- Pi4j) problem [message #1706679 is a reply to message #1705089] Fri, 28 August 2015 15:17 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
Hello,

I don't know if you still need support for this. If so, please post the content of your projects build.properties file.

Thanks,
--Dave
Re: Kura + External jar (ex :- Pi4j) problem [message #1707086 is a reply to message #1705089] Wed, 02 September 2015 08:09 Go to previous messageGo to next message
Alessandro Da Rugna is currently offline Alessandro Da RugnaFriend
Messages: 43
Registered: December 2014
Member
Serhiy Povoroznyuk wrote on Wed, 12 August 2015 06:35
I have compilation error in this case ( eclipse.github.io/kura/doc/serial-example.html ):

\org.eclipse.kura.example.serial.publisher\src\main\java\org\eclipse\kura\example\serial\publisher\ExampleSerialPublisher.java (at line 297)
m_commConnection = (CommConnection) m_connectionFactory.createConnection(uri, 1, false);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The type javax.microedition.io.Connection cannot be resolved. It is indirectly referenced from required .class files

Just a shot in the dark: this could be a conflict between Eclipse and Maven.
If the project is open in Eclipse IDE, it is compiled on-the-fly. Maven is not rebuilding those files and the Maven compiler has some issues with Eclipse-compiled class files. Disable the "Automatic build" feature of Eclipse, clean the project with mvn clean and try to compile again.


My project: Kura web log level changer https://github.com/darugnaa/kura-web-log
My blog: http://darugnaa.github.io
Re: Kura + External jar (ex :- Pi4j) problem [message #1720647 is a reply to message #1707086] Wed, 20 January 2016 07:50 Go to previous messageGo to next message
Said Ucar is currently offline Said UcarFriend
Messages: 56
Registered: June 2015
Member
Hi,

I know this topic is really old but I faced same problem today and I found the solution. I wanted to write the solution here for someone who may need.
Actually it was written in the example [1], when you try to export your bundle;
Quote:

Under Options, select the checkbox Use class files compiled in the workspace in addition to the checkboxes already enabled, and click Finish.


[1] = http://eclipse.github.io/kura/doc/serial-example.html
Re: Kura + External jar (ex :- Pi4j) problem [message #1792464 is a reply to message #1498518] Wed, 18 July 2018 10:07 Go to previous message
shubh wade is currently offline shubh wadeFriend
Messages: 28
Registered: July 2018
Junior Member
Hello
I haved include jdk.dio in the manifest dependencie.
I want to used i2c bus.
but i got this error java.lang.NoClassDefFoundError: Could not initialize class jdk.dio.DeviceManager

this is my code

GPIOPinConfig pinConfig = new GPIOPinConfig(
				DeviceConfig.DEFAULT, 						//GPIO Controller number or name
				17, 												//GPIO Pin number
				GPIOPinConfig.DIR_INPUT_ONLY,				//Pin direction
				GPIOPinConfig.MODE_INPUT_PULL_DOWN, 	//Pin resistor
				GPIOPinConfig.TRIGGER_BOTH_EDGES, 		//Triggers
				false 											//initial value (for outputs)
			);

		pin=  DeviceManager.open(GPIOPin.class, pinConfig);





Previous Topic:Missing artifact org.eclipse.kura:org.eclipse.kura.api:jar:1.1.0
Next Topic:BACnet protocol
Goto Forum:
  


Current Time: Tue Apr 16 12:14:37 GMT 2024

Powered by FUDForum. Page generated in 0.46069 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top