Re: Microscope (stage) controller and serial communication (Javacomm)

Posted by Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/Microscope-stage-controller-and-serial-communication-Javacomm-tp3702708p3702717.html

> The commands are one liners with a carriage return which will
> read/write to the port. Does anyone have example macros with an
> included serial communication example?

The macro language currently does not offer serial I/O support but
ImageJ 1.37c, courtesy of Johannes Schindelin, adds a call() function
that, in effect, allows new macro functions to be added. The call
function calls a public static method, passing an arbitrary number of
String parameters, and returning a String. Here is an example that
calls methods with no arguments, one argument and two arguments:

    call("JavaClass.method0");
    call("JavaClass.method1", "arg1");
    call("JavaClass.method2", "arg1", "arg2");

And this is what the methods in JavaClass.java look like:

     public static String method0() {
         return "method00";
     }

     public static String method1(String arg1) {
         return "method1"+"("+arg1+")";
     }

     public static String method2(String arg1, String arg2) {
         return "method2"+"("+arg1+", "+arg2+")";
     }

-wayne