This DFRobot shield has two parts: the 6 keys that are read via an analog input pin and an LCD display.
I want to start with the LCD display. There is a driver in the Arduino IDE (LiquidCrystal). The initialisation for the DFRobot is a different, as it uses different pins:
// initialize the library with the numbers of the interface pins
// original shield LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// DFRobot shield
LiquidCrystal lcd(8,9,4,5,6,7);
What I tried to do is, copy the whole libraries directory from Arduino IDE to the HaikuVM/HaikuVM directory and I hope all subdirectories will be compiled to .o files by HaikuVM.
And I made a start with translating LiquidCrystal.h and LiquidCrystal.cpp to Java (LiquidCrystal.java in bootstrap, haiku.avr.lib.arduino.liquidcrystal).
I put the definition for pinMode in HaikuMicroKernelLib.java.
In the past I prepared an article about HaikuVM for the javamagazin, which ate up my spare time. Trying to make HaikuVM more popular.
Now, back to your post:
1) You are on the right track: As a first step I would love to resemble the original LiquidCrystal-HelloWorld example like this as well:
public class HelloWorld {
static private LiquidCrystal lcd = new LiquidCrystal(12, 11, 5, 4, 3, 2);
// DFRobot shield
//static private LiquidCrystal lcd = new LiquidCrystal(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
}
2) This is my alternative track: Why copy all the source?
Just copy 'arduino-1.0.2\libraries\LiquidCrystal'. For the rest use 'haikuVM-1.0.3\lib\clibs\libleonardo.a'. (Official version of haikuVM-1.0.3 - including Leonardo support - is comming soon.)
3) You are not on the right track: Why copy into 'haikuVM-1.0.3\haikuVM'?
Doing so will "pollute" the source of the Haiku VM itself. In my understanding, LiquidCrystal is just another project. So, copy into 'haikuVM-1.0.3\myCProject\LiquidCrystal' would be right.
4) Instead of mimic the LiquidCrystal.cpp one-to-one in LiquidCrystal.java I would make shortcuts by using JNI roughly like this:
public class LiquidCrystal extends Print {
public LiquidCrystal(int rs, int enable, int d0, int d1, int d2, int d3) {
constructor(rs, enable, d0, d1, d2, d3);
}
public static native constructor(int rs, int enable, int d0, int d1, int d2, int d3);
@Override
public native byte write(byte c);
public native void begin(int cols, int rows);
public native void setCursor(int col, int row);
}
Implementing this 4 native functions in C is easy when assuming that only one single instance of a LCD is instantiated per runtime.
What do you think about this roadmap? Any critics?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Downloaded HaikuVM-1.0.5 and got totally lost.
1) The hello world lcd example. Did you manage to get it working?
2) Why copy all the sources? I hoped to build the arduino sources with the c compiler of haikuVM, to be sure the libraries used by haikuVM are compiled with the same compiler. But I realize this is not necessary.
3) In my view, the LiquidCrystal.class should be part of a "runtime" jar file, like the java.net.socket.Socket is a part of the pc jre.
The file LiquidCrystalHelloWorld.class should not go into the runtime jar.
The ultimate goal is to be able to create an Eclipse (or Netbeans) environment with these jars to make development more comfortable (with true error checking, javadoc, runconfigurations, ...).
4) You are probably right about native methods, but I would not choose to limit the system to only one lcd display.
I also have started to write some code for the keypad (the 5-key keypad). Nothing tested yet, I will attach it to this post.
When I follow the updated recipe in your web site, on haikuVM-1.0.5:
C:\haikuVM\bin\haiku -v --Config leonardo.UsingCLIB C:\haikuVM\examples\src\main\java\arduino\tutorial\HelloWorldJava.java
there is an error. You changed something in generating the class files. That change looks very good to me: now you call javac directly. But the discovery of javac is a bit cumbersome, especially when there is a space in the path name, and that is an understatement: after an hour of trying what environment variable to set I did not manage to get it working. Here is my error message:
(hoi.bat contains:
D:\downloads\HaikuVM-1.0.5\haikuVM\bin\haiku.bat -v --Config leonardo.UsingCLIB D:\downloads\HaikuVM-1.0.5\haikuVM\examples\src\main\java\arduino\tutorial\HelloWorldJava.java
-- end of hoi.bat
)
d:\downloads\HaikuVM-1.0.5\haikuVM\myCProject>ECHO %LEJOS_NXT_JAVA_HOME%
C:/Program Files/Java/jdk1.7.0_40/
d:\downloads\HaikuVM-1.0.5\haikuVM\myCProject>hoi
d:\downloads\HaikuVM-1.0.5\haikuVM\myCProject>D:\downloads\HaikuVM-1.0.5\haikuVM\bin\haiku.bat -v --Config leonardo.UsingCLIB D:\do
wnloads\HaikuVM-1.0.5\haikuVM\examples\src\main\java\arduino\tutorial\HelloWorldJava.java
D:\downloads\HaikuVM-1.0.5\haikuVM\bin\haiku.bat -v --Config leonardo.UsingCLIB D:\downloads\HaikuVM-1.0.5\haikuVM\examples\src\mai
n\java\arduino\tutorial\HelloWorldJava.java
Internal error. The following directory does not exist:
"D:\downloads\HaikuVM-1.0.5\haikuVM\bin\..\lib\haikuvm"
Could not loaded HaikuVM.properties from 'D:\downloads\HaikuVM-1.0.5\haikuVM\myCProject\HaikuVM.properties'.
Loaded HaikuVM.properties from 'D:\downloads\HaikuVM-1.0.5\haikuVM\config\HaikuVM.properties'
$Version 1.0.5 $ $Date: 2013-09-27 21:58:48 +0200 (Fr, 27 Sep 2013) $
D:\downloads\HaikuVM-1.0.5\haikuVM\bin../bin/haikuc D:\downloads\HaikuVM-1.0.5\haikuVM\examples\src\main\java\arduino\tutorial\Hell
oWorldJava.java
generating class files
C:/Program Files/Java/jdk1.7.0_40//bin/javac.exe -bootclasspath "" -extdirs "" -classpath 'D:\downloads\HaikuVM-1.0.5\haikuVM\bin..
\haikuRT\src\main\java;D:\downloads\HaikuVM-1.0.5\haikuVM\bin..\lib\nxt\classes.jar;D:\downloads\HaikuVM-1.0.5\haikuVM\bin..\boots
trap\src\main\java;D:\downloads\HaikuVM-1.0.5\haikuVM\bin..\examples\src\main\java;D:\downloads\HaikuVM-1.0.5\haikuVM\bin..\haikuB
ench\src\main\java;C:\Users\cdn\AppData\Local\Temp\haikuvm' -d 'C:\Users\cdn\AppData\Local\Temp\haikuvm' 'D:\downloads\HaikuVM-1.0.5
\haikuVM\examples\src\main\java\arduino\tutorial\HelloWorldJava.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\ha
iku\avr\lib\arduino\HaikuMicroKernel.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\arduino\HaikuMi
croKernel4ArduinoIDE.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\arduino\HaikuMicroKernelEx.java
' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\arduino\HaikuMicroKernelLib.java' 'D:\downloads\HaikuVM-
1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\arduino\HaikuMicroKernelProcessing.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\boo
tstrap\src\main\java\haiku\avr\lib\asuro\lib2_8_0_rc1\HaikuMicroKernel.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\
java\haiku\avr\lib\asuro\lib2_8_0_rc1\HaikuMicroKernelEx.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr
\lib\asuro\nanovm\HaikuMicroKernel.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\simple010\HaikuMi
croKernel.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\pc\lib\HaikuMicroKernel.java' 'D:\downloads\HaikuV
M-1.0.5\haikuVM\bootstrap\src\main\java\haiku\vm\MicroKernel.java'
/usr/bin/sh: C:/Program: No such file or directory
make: *** [all] Error 127
Error 2 while generating class file(s)
java.lang.Exception: Script 'D:\downloads\HaikuVM-1.0.5\haikuVM\bin../bin/haikuc.bat' exited with errorcode=2
at haikuvm.pc.tools.HaikuVM.executeBlocking(HaikuVM.java:550)
at haikuvm.pc.tools.HaikuVM.call(HaikuVM.java:212)
at haikuvm.pc.tools.HaikuVM.haikuc0(HaikuVM.java:167)
at haikuvm.pc.tools.HaikuVM.haiku0(HaikuVM.java:135)
at haikuvm.pc.tools.HaikuVM.main(HaikuVM.java:97)
d:\downloads\HaikuVM-1.0.5\haikuVM\myCProject>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for pointing out that s p a c e s in a javac path are not handled correct, like in:
"C:/Program Files/Java/jdk1.7.0_40//bin/javac.exe"
In my (only two) test systems I was never faced with this circumstance.
I will fix this issues asap (I expect to do this in the next few days).
Coming back to 1, 2, 3 and 4:
1) No, it does not run yet. I will try to get it compiled at least (remember, that I don't own an LCD shield).
2) This is my solution now - of which I'm very proud: I enabled HaikuVM 1.0.5 to copy/merge all its generated files into the Arduino IDE files. So, my spare time was absorbed by integrating the output of HaikuVM 1.0.5 into the Arduino IDE, to support any Arduino (not only Leonrado :) etc.). Did you read http://haiku-vm.sourceforge.net/#[[Arduino%20IDE]]?
And yes, the c/c++ compiler of HaikuVM is the same as the c/c++ compiler of the Arduino IDE. (Which, in turn, is nothing else as WINAVR.)
But criticism is welcome as always!
3) When it comes down to Arduino compatibility (which is not my primary goal, because HaikuVM should be open for other micros too), my idea is to distinguish between three levels:
i) (mostly native) JAVA runtime (which is Arduino agnostic)
ii) Arduino IDE library level
iii) Arduino sketch level
4) "assuming that only one single instance of a LCD is instantiated per runtime"
This statement is only a defensive approach. Shortly I want to use C++ objects as JAVA objects in a transparent way. (Which will be the next big thing for HaikuVM.) But for me this is hard to accomplish in all aspects. Currently I'm attracted to the idea of http://www.swig.org/Doc1.3/Java.html#imclass.
5) I try to look into your code for the keypad (the 5-key keypad) next week. So, sadly I have no statement on this now. (Is there any corresponding keypad C++ code in an Arduino library?)
Last edit: genom2 2013-10-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is a preview file:
'HaikuVM-1.1.0.zip'
in the download area for you. To check out other oddities.
In addition:
1) LiquidCrystalHelloWorld
The file:
'gallerie/src/main/java/arduino/libraries/liquidcrystal/LiquidCrystalHelloWorld.java'
does now compile.
5) Keypad.java
The main problem of your Keypad class is its linkage to the SUN JAVA rt!
I recommend to use the leJOS JAVA rt - to be find in 'lib/nxt/classes.jar'. (And BTW, you will run into trouble if you mix SUN rt and leJOS rt.) For instance: leJOS rt does not offer the package 'java.awt.event'.
You have to exclude SUN rt and have to include leJOS rt instead in your IDE, to avoid future use of SUN rt.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to compile LiquidCrystalHalloWorld.java, but it failed, see the attachment.
About architecture (points 2 and 3) on haikuVM: I think you are more expert than I am, so I will leave that to you.
Keypad.java: I will try to sort out how to change the runtime platform in Eclipse to use leJOS rt and change the source of Keypad.java accordingly. That can take a few weeks, as coming week is quite busy with other things. In the Arduino library I found keyboard.cpp, but that is not very complete (it has no possibility to add listeners).
Thank you for checking and sending 'output_201310120_1.txt'. (Sorry, before your observation I only tested with duemilanove.UsingCLIB.)
6) LiquidCrystalHalloWorld failed
I analized 2 problems:
6.1) undefined references for functions
to `native_lejos_nxt_VM_memPeek_IIII'
to `native_lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI'
.
6.2) undefined references for constants
to `UCSR0A'
to `UDR0'
I was able to fix 6.2 (see new 'HaikuVM-1.1.0-rc3.zip').
I don't understand 6.1 !?!
I'm not able to reproduce it!
Did you changed your file 'haikuRT/src/main/java/java/lang/Throwable.java'? I expect the following source snipped (see the comments on the assignment):
Problem seems to concentrate on haikuJava.c, haikuJava.h, haikuJNI.c and haikuJava.o.
(maybe this is the time to start with SWIG?)
I attached my /cygdrive/d/downloads/HaikuVM-1.1.0-rc3/haikuVM/myCProject/target/cross/HaikuVM/utility/haikuJava.o. The offending symbol is marked UND (that means "undefined" I assume).
Part in haikuJava.c:
/*
public static native int[] createStackTrace(Thread arg0, Object arg1)/
No, for me the problem starts earlier.
6.1) undefined references for functions
to `native_lejos_nxt_VM_memPeek_IIII'
to `native_lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI'
These undefined references are not part of my/any JAVA source code!!
So, please check and answer the question I asked, which I re-iterate here:
Did you changed your file 'haikuRT/src/main/java/java/lang/Throwable.java'? Because if you uncomment
No, I did not change any file, I downloaded HaikuVM-1.1.0-rc3, copied and changed my hoi.bat to use this version and started hoi.bat in the HaikuVM-1.1.0-rc3/myCProject directory.
hoi.bat:
rem Setting LEJOS_NXT_JAVA_HOME to a path that contains spaces is not allowed (2013-10-22)
/** * Capture a stack trace. Note that the frames containing this (and other * calls directly relating to the Throwable object). will be omitted. * @return The Throwable object. */
publicThrowablefillInStackTrace(){//_stackTrace=VM.createStackTrace(Thread.currentThread(),this);returnthis;}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Support for this LCD/keypad is available in the Arduino IDE. A port to HaikuVM could be done with the existing C++ files in the original Arduino IDE.
This DFRobot shield has two parts: the 6 keys that are read via an analog input pin and an LCD display.
I want to start with the LCD display. There is a driver in the Arduino IDE (LiquidCrystal). The initialisation for the DFRobot is a different, as it uses different pins:
// initialize the library with the numbers of the interface pins
// original shield LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// DFRobot shield
LiquidCrystal lcd(8,9,4,5,6,7);
What I tried to do is, copy the whole libraries directory from Arduino IDE to the HaikuVM/HaikuVM directory and I hope all subdirectories will be compiled to .o files by HaikuVM.
And I made a start with translating LiquidCrystal.h and LiquidCrystal.cpp to Java (LiquidCrystal.java in bootstrap, haiku.avr.lib.arduino.liquidcrystal).
I put the definition for pinMode in HaikuMicroKernelLib.java.
Am I on the right track?
Last edit: genom2 2013-07-05
In the past I prepared an article about HaikuVM for the javamagazin, which ate up my spare time. Trying to make HaikuVM more popular.
Now, back to your post:
1) You are on the right track: As a first step I would love to resemble the original LiquidCrystal-HelloWorld example like this as well:
2) This is my alternative track: Why copy all the source?
Just copy 'arduino-1.0.2\libraries\LiquidCrystal'. For the rest use 'haikuVM-1.0.3\lib\clibs\libleonardo.a'. (Official version of haikuVM-1.0.3 - including Leonardo support - is comming soon.)
3) You are not on the right track: Why copy into 'haikuVM-1.0.3\haikuVM'?
Doing so will "pollute" the source of the Haiku VM itself. In my understanding, LiquidCrystal is just another project. So, copy into 'haikuVM-1.0.3\myCProject\LiquidCrystal' would be right.
4) Instead of mimic the LiquidCrystal.cpp one-to-one in LiquidCrystal.java I would make shortcuts by using JNI roughly like this:
Implementing this 4 native functions in C is easy when assuming that only one single instance of a LCD is instantiated per runtime.
What do you think about this roadmap? Any critics?
Back from holiday...
Downloaded HaikuVM-1.0.5 and got totally lost.
1) The hello world lcd example. Did you manage to get it working?
2) Why copy all the sources? I hoped to build the arduino sources with the c compiler of haikuVM, to be sure the libraries used by haikuVM are compiled with the same compiler. But I realize this is not necessary.
3) In my view, the LiquidCrystal.class should be part of a "runtime" jar file, like the java.net.socket.Socket is a part of the pc jre.
The file LiquidCrystalHelloWorld.class should not go into the runtime jar.
The ultimate goal is to be able to create an Eclipse (or Netbeans) environment with these jars to make development more comfortable (with true error checking, javadoc, runconfigurations, ...).
4) You are probably right about native methods, but I would not choose to limit the system to only one lcd display.
I also have started to write some code for the keypad (the 5-key keypad). Nothing tested yet, I will attach it to this post.
When I follow the updated recipe in your web site, on haikuVM-1.0.5:
C:\haikuVM\bin\haiku -v --Config leonardo.UsingCLIB C:\haikuVM\examples\src\main\java\arduino\tutorial\HelloWorldJava.java
there is an error. You changed something in generating the class files. That change looks very good to me: now you call javac directly. But the discovery of javac is a bit cumbersome, especially when there is a space in the path name, and that is an understatement: after an hour of trying what environment variable to set I did not manage to get it working. Here is my error message:
(hoi.bat contains:
D:\downloads\HaikuVM-1.0.5\haikuVM\bin\haiku.bat -v --Config leonardo.UsingCLIB D:\downloads\HaikuVM-1.0.5\haikuVM\examples\src\main\java\arduino\tutorial\HelloWorldJava.java
-- end of hoi.bat
)
d:\downloads\HaikuVM-1.0.5\haikuVM\myCProject>ECHO %LEJOS_NXT_JAVA_HOME%
C:/Program Files/Java/jdk1.7.0_40/
d:\downloads\HaikuVM-1.0.5\haikuVM\myCProject>hoi
d:\downloads\HaikuVM-1.0.5\haikuVM\myCProject>D:\downloads\HaikuVM-1.0.5\haikuVM\bin\haiku.bat -v --Config leonardo.UsingCLIB D:\do
wnloads\HaikuVM-1.0.5\haikuVM\examples\src\main\java\arduino\tutorial\HelloWorldJava.java
D:\downloads\HaikuVM-1.0.5\haikuVM\bin\haiku.bat -v --Config leonardo.UsingCLIB D:\downloads\HaikuVM-1.0.5\haikuVM\examples\src\mai
n\java\arduino\tutorial\HelloWorldJava.java
Internal error. The following directory does not exist:
"D:\downloads\HaikuVM-1.0.5\haikuVM\bin\..\lib\haikuvm"
Could not loaded HaikuVM.properties from 'D:\downloads\HaikuVM-1.0.5\haikuVM\myCProject\HaikuVM.properties'.
Loaded HaikuVM.properties from 'D:\downloads\HaikuVM-1.0.5\haikuVM\config\HaikuVM.properties'
$Version 1.0.5 $ $Date: 2013-09-27 21:58:48 +0200 (Fr, 27 Sep 2013) $
D:\downloads\HaikuVM-1.0.5\haikuVM\bin../bin/haikuc D:\downloads\HaikuVM-1.0.5\haikuVM\examples\src\main\java\arduino\tutorial\Hell
oWorldJava.java
generating class files
C:/Program Files/Java/jdk1.7.0_40//bin/javac.exe -bootclasspath "" -extdirs "" -classpath 'D:\downloads\HaikuVM-1.0.5\haikuVM\bin..
\haikuRT\src\main\java;D:\downloads\HaikuVM-1.0.5\haikuVM\bin..\lib\nxt\classes.jar;D:\downloads\HaikuVM-1.0.5\haikuVM\bin..\boots
trap\src\main\java;D:\downloads\HaikuVM-1.0.5\haikuVM\bin..\examples\src\main\java;D:\downloads\HaikuVM-1.0.5\haikuVM\bin..\haikuB
ench\src\main\java;C:\Users\cdn\AppData\Local\Temp\haikuvm' -d 'C:\Users\cdn\AppData\Local\Temp\haikuvm' 'D:\downloads\HaikuVM-1.0.5
\haikuVM\examples\src\main\java\arduino\tutorial\HelloWorldJava.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\ha
iku\avr\lib\arduino\HaikuMicroKernel.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\arduino\HaikuMi
croKernel4ArduinoIDE.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\arduino\HaikuMicroKernelEx.java
' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\arduino\HaikuMicroKernelLib.java' 'D:\downloads\HaikuVM-
1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\arduino\HaikuMicroKernelProcessing.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\boo
tstrap\src\main\java\haiku\avr\lib\asuro\lib2_8_0_rc1\HaikuMicroKernel.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\ java\haiku\avr\lib\asuro\lib2_8_0_rc1\HaikuMicroKernelEx.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr
\lib\asuro\nanovm\HaikuMicroKernel.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\avr\lib\simple010\HaikuMi
croKernel.java' 'D:\downloads\HaikuVM-1.0.5\haikuVM\bootstrap\src\main\java\haiku\pc\lib\HaikuMicroKernel.java' 'D:\downloads\HaikuV
M-1.0.5\haikuVM\bootstrap\src\main\java\haiku\vm\MicroKernel.java'
/usr/bin/sh: C:/Program: No such file or directory
make: *** [all] Error 127
Error 2 while generating class file(s)
java.lang.Exception: Script 'D:\downloads\HaikuVM-1.0.5\haikuVM\bin../bin/haikuc.bat' exited with errorcode=2
at haikuvm.pc.tools.HaikuVM.executeBlocking(HaikuVM.java:550)
at haikuvm.pc.tools.HaikuVM.call(HaikuVM.java:212)
at haikuvm.pc.tools.HaikuVM.haikuc0(HaikuVM.java:167)
at haikuvm.pc.tools.HaikuVM.haiku0(HaikuVM.java:135)
at haikuvm.pc.tools.HaikuVM.main(HaikuVM.java:97)
d:\downloads\HaikuVM-1.0.5\haikuVM\myCProject>
Hello Carl, nice to here from you again.
Thank you for pointing out that s p a c e s in a javac path are not handled correct, like in:
"C:/Program Files/Java/jdk1.7.0_40//bin/javac.exe"
In my (only two) test systems I was never faced with this circumstance.
I also wonder about phrases like:
Because I expect something more precise like:
I will fix this issues asap (I expect to do this in the next few days).
Coming back to 1, 2, 3 and 4:
1) No, it does not run yet. I will try to get it compiled at least (remember, that I don't own an LCD shield).
2) This is my solution now - of which I'm very proud: I enabled HaikuVM 1.0.5 to copy/merge all its generated files into the Arduino IDE files. So, my spare time was absorbed by integrating the output of HaikuVM 1.0.5 into the Arduino IDE, to support any Arduino (not only Leonrado :) etc.). Did you read http://haiku-vm.sourceforge.net/#[[Arduino%20IDE]]?
And yes, the c/c++ compiler of HaikuVM is the same as the c/c++ compiler of the Arduino IDE. (Which, in turn, is nothing else as WINAVR.)
But criticism is welcome as always!
3) When it comes down to Arduino compatibility (which is not my primary goal, because HaikuVM should be open for other micros too), my idea is to distinguish between three levels:
i) (mostly native) JAVA runtime (which is Arduino agnostic)
ii) Arduino IDE library level
iii) Arduino sketch level
4) "assuming that only one single instance of a LCD is instantiated per runtime"
This statement is only a defensive approach. Shortly I want to use C++ objects as JAVA objects in a transparent way. (Which will be the next big thing for HaikuVM.) But for me this is hard to accomplish in all aspects. Currently I'm attracted to the idea of http://www.swig.org/Doc1.3/Java.html#imclass.
5) I try to look into your code for the keypad (the 5-key keypad) next week. So, sadly I have no statement on this now. (Is there any corresponding keypad C++ code in an Arduino library?)
Last edit: genom2 2013-10-18
Hi Carl,
I fixed the points (spaces) you mentioned.
There is a preview file:
'HaikuVM-1.1.0.zip'
in the download area for you. To check out other oddities.
In addition:
1) LiquidCrystalHelloWorld
The file:
'gallerie/src/main/java/arduino/libraries/liquidcrystal/LiquidCrystalHelloWorld.java'
does now compile.
5) Keypad.java
The main problem of your Keypad class is its linkage to the SUN JAVA rt!
I recommend to use the leJOS JAVA rt - to be find in 'lib/nxt/classes.jar'. (And BTW, you will run into trouble if you mix SUN rt and leJOS rt.) For instance: leJOS rt does not offer the package 'java.awt.event'.
You have to exclude SUN rt and have to include leJOS rt instead in your IDE, to avoid future use of SUN rt.
I tried to compile LiquidCrystalHalloWorld.java, but it failed, see the attachment.
About architecture (points 2 and 3) on haikuVM: I think you are more expert than I am, so I will leave that to you.
Keypad.java: I will try to sort out how to change the runtime platform in Eclipse to use leJOS rt and change the source of Keypad.java accordingly. That can take a few weeks, as coming week is quite busy with other things. In the Arduino library I found keyboard.cpp, but that is not very complete (it has no possibility to add listeners).
SWIG looks promising!
Last edit: Carl van Denzen 2013-10-20
Thank you for checking and sending 'output_201310120_1.txt'. (Sorry, before your observation I only tested with duemilanove.UsingCLIB.)
6) LiquidCrystalHalloWorld failed
I analized 2 problems:
6.1) undefined references for functions
.
6.2) undefined references for constants
I was able to fix 6.2 (see new 'HaikuVM-1.1.0-rc3.zip').
I don't understand 6.1 !?!
I'm not able to reproduce it!
Did you changed your file 'haikuRT/src/main/java/java/lang/Throwable.java'? I expect the following source snipped (see the comments on the assignment):
But 6.1 symptoms are looking as if the source snipped looks like without comments:
Any idea?
Last edit: genom2 2013-10-21
Problem seems to concentrate on haikuJava.c, haikuJava.h, haikuJNI.c and haikuJava.o.
(maybe this is the time to start with SWIG?)
I attached my /cygdrive/d/downloads/HaikuVM-1.1.0-rc3/haikuVM/myCProject/target/cross/HaikuVM/utility/haikuJava.o. The offending symbol is marked UND (that means "undefined" I assume).
Part in haikuJava.c:
/*
public static native int[] createStackTrace(Thread arg0, Object arg1)/
ifndef native_lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI
const NativCode lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI PROGMEM ={0xff, &native_lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI};
endif
Part in haikuJava.h:
ifndef native_lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI
extern const NativCode lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI;
extern void native_lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI(void);
endif
Part in haikuJNI.c:
/
* Proprietary HaikuVM stack to JNI interface function.
* DO NOT EDIT THIS FUNCTION – it is machine generated.
*
* Class: lejos.nxt.VM
* Method: createStackTrace
* Signature: (Ljava/lang/Thread;Ljava/lang/Object;)[I
/
JNIEXPORT void native_lejos_nxt_VM_createStackTrace_Ljava_lang_Thread_Ljava_lang_Object_YI(void) {
pushTop(); // Save variable top onto stack.
{
jobject arg2 = pop()->a;
jobject arg1 = pop()->a;
jclass obj = NULL;
JNIEnv *env = NULL; // not used in HaikuVM
top.s1.a = Java_lejos_nxt_VM_createStackTrace(env, obj, arg1, arg2);
}
// Variable top holds the return value.
}
No, for me the problem starts earlier.
6.1) undefined references for functions
These undefined references are not part of my/any JAVA source code!!
So, please check and answer the question I asked, which I re-iterate here:
Did you changed your file 'haikuRT/src/main/java/java/lang/Throwable.java'? Because if you uncomment
Then it might explain the symptom.
No, I did not change any file, I downloaded HaikuVM-1.1.0-rc3, copied and changed my hoi.bat to use this version and started hoi.bat in the HaikuVM-1.1.0-rc3/myCProject directory.
hoi.bat:
rem Setting LEJOS_NXT_JAVA_HOME to a path that contains spaces is not allowed (2013-10-22)
set LEJOS_NXT_JAVA_HOME=
D:\downloads\HaikuVM-1.1.0-rc3\haikuVM\bin\haiku.bat -v --Config leonardo.UsingCLIB D:\downloads\HaikuVM-1.1.0-rc3\haikuVM\gallerie\src\main\java\arduino\libraries\liquidcrystal\LiquidCrystalHelloWorld.java
Part of Throwable.java in the 1.1.0-rc3 release:
Please, see under Tickets.