Hallo,

ich möchte in diesem Forum HaikuVM vorstellen.

HaikuVM ist eine weitere JAVA VM für Micros (ich habe mal mit dem ASURO und deshalb AVRs angefangen). In diesem Forum wurde schon mal NanoVM vorgestellt die das auch ähnlich konnte. Das Besondere ist, dass ich entschieden habe keine eigene Runtime zu bauen (viel zu aufwendig). Statt dessen nutze ich die (von mir) javierte ASURO lib 2.8.0 rc1 und die Runtime von leJOS, einem großen JAVA Projekt für Lego Mindstorms Robotics Invention Kit Bausätze.

HaikuVM ist so klein, dass es sogar auf einem Atmega8 und dem ASURO Roboter läuft.
Und ja, man kann damit einen ASURO Roboter mit JAVA programmieren!

Wer schon mal seinen ASURO mit parallelen Threads programmieren wollte, z.B. einige LEDs mit unterschiedlicher Frequenz blinken lassen ... so geht's:
Code:
package asuro.tutorial;
import static haiku.avr.lib.asuro.lib2_8_0_rc1.AsuroLib2_8_0_rc1.*;

public class BlinkWithThread {
    private static class blink_Task extends Thread {
        public void run() {
            while (true) {
                BackLED(ON, ON);
                Msleep(1000);
                BackLED(OFF, OFF);
                Msleep(1000);
            }
        }
    }

    public static void main(String[] args) {
        Init();                   // initialize the ASURO
        
        new blink_Task().start(); // starts the parallel blink task.

        while (true) {
            StatusLED(GREEN);
            Msleep(500);
            StatusLED(RED);
            Msleep(500);
        }
    }
}
HaikuVM funktioniert indem JAVA bytecode nach C Code konvertiert wird um letztlich durch einen C cross compiler für die Zielplattform kompiliert zu werden.

Notwendige Software:
  1. JAVA 1.6
  2. WinAVR (C cross compiler für AVRs)
  3. HaikuVM
  4. Eclipse IDE (optional)


Features von HaikuVM:
  • Preemptive threads
  • Exceptions
  • Synchronization
  • double and float support
  • Arrays, including multidimensional ones
  • Recursion
  • Garbage collection
  • Supports inheritance and interfaces
  • Runs on AVR ATmega8, AVR ATmega328p (and Windows, UNIX)
  • Configurable 64, 32 or 16 bit data types including half precision float
  • Configurable 16 or 8 bit char type
  • Tested with Suns JAVA 1.6
  • Zero Assembler Code
  • Requires only down to 5k Bytes of code memory (includes HaikuVM and your Java program)
  • Needs only 250 Bytes RAM (the rest is for your JAVA application)
  • About 55k Java opcodes per second on 8 Mhz AVR ATmega8