Serial Macro Extensions

Introduction

This plugin provides methods to talk to a device attached to a serial port, directly from the ImageJ Macro language, using the Macro Extension mechanism. You can easily:

  • list the available serial ports
  • establish a serial connection
  • check if the serial connection is alive
  • send commands over the serial connection
  • recieve what is available from the serial port
  • close the connection

It works with any serial device, but was developped to talk with the Arduino board, an open-source electronics prototyping platform (http://arduino.cc/).

See also

  • IJSerial plugin (http://www.eslide.net/) can also be used, but it requires a separate config file, and does not provide persistence to the serial connection.

Authors

Jérôme Mutterer, Tom Mueller, Graeme Awcock, Michael Schmid

Installation

Windows

  • Requires RXTX library (http://rxtx.qbang.org/). In short, copy RXTXcomm.jar to plugins/ and rxtxSerial.dll and rxtxParallel.dll to jre/bin).
  • Download serial_ext.jar to the plugins folder
  • Restart ImageJ

Other platforms

Usage

  • Make the macro interpreter aware of the new extensions:
run("serial ext");
  • Get a list of available serial ports:
ports = Ext.ports();
  • Establish a serial connection to the serial device, using COM8 port and a bitrate of 9600 bps:
Ext.open("COM8",9600,""); // this is enough e.g. for the Arduino, defaults parameters are DATABITS_8,STOPBITS_1,PARITY_NONE
Ext.open("COM1",14400,"DATABITS_8 STOPBITS_2 PARITY_ODD"); // advanced serial port configuration

// Available options

// DEFAULT: 8 data bits, 1 stop bit, no parity
 
// Databits:
// DATABITS_5
// DATABITS_6
// DATABITS_7
// DATABITS_8

// Stopbits:
// STOPBITS_1
// STOPBITS_2
// STOPBITS_1_5

// Parity:
// PARITY_NONE
// PARITY_EVEN
// PARITY_ODD
// PARITY_MARK
// PARITY_SPACE
  • Read what the serial device sends:
data = Ext.read();
  • Send a string command to the serial device:
Ext.write("a");
  • Close the active serial port:
Ext.close();
  • Poll if a serial connection is already there:
active = Ext.alive();
// returns "0" or "1"

Download

  • Install RXTX Library (http://rxtx.qbang.org/). On Windows, copy RXTXcomm.jar to plugins/ and rxtxSerial.dll and rxtxParallel.dll to jre/bin)
  • Download serial_ext.jar to the plugins folder

History

  • 0.12 : GA and MS fixed a byte encoding issue.
plugin/utilities/serial_macro_extensions/start.txt · Last modified: 2015/05/23 21:00 by mutterer
Back to top
CC Attribution-Noncommercial-Share Alike 3.0 Unported
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0