var m = require('mraa'); //require mraa
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
var myLed = new m.Gpio(7); //LED hooked up to digital pin 7
myLed.dir(m.DIR_OUT); //set the gpio direction to output
var ledState = true; //Boolean to hold the state of Led
function periodicActivity()
{
myLed.write(ledState?1:0); //if ledState is true then write a '1' (high) otherwise write a '0' (low)
ledState = !ledState; //invert the ledState
setTimeout(periodicActivity,500); //call the indicated function after 1 second (1000 milliseconds)
}
periodicActivity(); //call the periodicActivity function
Ok, the board has arrived.
I started with some tests using the jmraa library but in mraa.Initialize
I have these errors:
B4X:
Waiting for debugger to connect...
Program started.
java.lang.UnsatisfiedLinkError: C:\Users\User\Downloads\tempjars\libmraajava.so: Can't load this .dll (machine code=0x101) on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at anywheresoftware.b4j.objects.MraaController.Initialize(MraaController.java:44)
at b4j.example.main._appstart(main.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccesso
rImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:79)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:70)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.w
in.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: C:\Users\User\Downloads\tempjars\libmraajava.so: Can't load this .dll (machine code=0x101) on a AMD 64-bit platform
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:70)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinAp
plication.java:191)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: C:\Users\User\Downloads\tempjars\libmraajava.so: Can't load this .dll (machine code=0x101) on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at anywheresoftware.b4j.objects.MraaController.Initialize(MraaController.java:44)
at b4j.example.main._appstart(main.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
at anywheresoftware.b4a.s
hell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:79)
... 12 more
If you have wrapped mraa lib for the board intel edison why it does not work with up-board?
I think the problem can only be the matching of the pins but at least it must work
I'm wrong?
Thanks for all.
This link attached is DIO project in C# and use aaeonEAPI.dll and EAPI.cs class.
In Form1.cs you see the calls to the aaeonEAPI.dll and the variuos dll entrypoint.
It seems simple if the program was in C# but with B4j i can not make it.
The C# libraries will not help. It is also not simple to compile the MRAA library. It should be done on the board itself and it requires a very specific configuration.
I recommend you to go with the python approach. It shouldn't be too difficult.
I'm back Erel,
forgive me but I want to see to use the UP-BOARD to the best.
I found this new file with the mraa.jar and various upm*.jar, can you see how to use them with b4j?
Thanks
Hi Erel
I tried to decompile the mraa.jar file of the previous link and your and are identical, but in your mraa.jar there is libmraajava.so file, what is it for?
Is this that show the error when initialize your jmraa library, but i can not see what's inside in this file (libmraajava.so).
Thanks
P.S.
I looked better, they are not exactly the same
The libmraajava.so is refers to linux folders paths.
So I think the problem is not the up-board but the operating system, on my board run windows 10.
It's correct?
The .so file is the native library. The B4J library copies it at runtime to File.DirApp and loads it. This step should work on both Windows and Linux. It is possible that the native library itself needs to be recompiled.