GetSync (Serial port interface plugin for ImageJ)

Authors: François GANNIER (gannier at univ-tours dot fr) - Côme PASQUALIN University of Tours (France)
See also: Others productions for ImageJ from the authors
PCCV group main page
History: 2017/04/07: 0.1 - First version
Source: src.zip. Link to GitHub
Requires: Tested on ImageJ 1.51g but should works on older.
Limitations:Should works on Mac OS, Linux and Windows
Installation:This work is based on the RXTX library and use a short and easy to build electric circuit.
Download the last version of RXTX then copy RXTXcomm.jar in the jars folder and the rxtxserial library (dll, so or jnilib) corresponding to your operating system in the ImageJ directory. (Rq: the plugin was tested with version 2.1.7 and 2.2.0.1)
Download and copy GetSync.jar in the jars folder then restart ImageJ.
On linux, you can use apt/zypper to install rxtx-java; don't forget to add user on dialout and lock groups.
Description:This plugin is provided to listen the serial port (COM) on DSR and CTS line, and set state of RTS and DTR.
With it, you can receive signals from 2 separate sources (like synchro and event) and send two distincts TTL command with the corresponding electronical circuit.
Usage in macro:

	// Initialisation
	if (call("GetSync.init",1)==0) {
	// Initialisation failed
		IJ.log("Available serial ports :")
		call("GetSync.ListSerialPorts");
		exit();
	}
	// Action to do if DSR is ON
	if (call("GetSync.IsDSR")==1) {
		// to do if DSR is ON
	}
	// Action to do if CTS is ON
	if (call("GetSync.IsCTS")==1) {
		// to do if CTS is ON
	}
	// Switch the state of RTS
	call("GetSync.switchRTS");
	// DO NOT FORGET at end to close the serial port
	call("GetSync.done");
Usage in JAVA: In JAVA, this plugin works in multithreading with the second class listenCOM

	// Initialisation 
	listenCOM sync = new listenCOM();
	//Set the serial port used
	sync.setPort(1);
	//start the thread
	sync.start();
	// test with a time out of 3s
	if (!sync.isStarted(3000)) {
		IJ.showMessage("Warning", "Cannot initialize COM port!!!");
		sync.interrupt();
		sync = null;
		break;
	}

	//set the RTS line ON
	sync.sendRTS(true);
	//test the DSR state
	while (...) {
		if (sync.isDSR()) {
			//todo when synchro come
		}
	}
	// DO NOT FORGET at end to stop the thread (this close serial port)
	sync.interrupt();
	sync = null;
Functions in GetSync : ListSerialPorts(); init(int); init(string); done();
isDSR(); isDTS(); isCTS(); isRTS();
setCTS(boolean); setDTR(boolean);
switchRTS(); switchDTR();
Functions in ListenCOM : setPort(int);isStarted((int);
isDSR();isCTS();
resetCTS(); resetDSR();
switchRTS(); switchDTR();
sendDTR(boolean); sendRTS(boolean);

|Plugins | Home |