ohmm
Class OHMM

java.lang.Object
  extended by ohmm.OHMM
Direct Known Subclasses:
OHMMDrive

public class OHMM
extends java.lang.Object

OHMM high level processor library.

An instance of this class encapsulates communication with the OHMM monitor firmware.

Several constructors are provided to allow the actual communication link to be implemented in different ways:

The RXTX codepath has the advantage of internally setting the communications parameters (115.2kbps, 8N1, no flow control). The other codepaths will require the serial port to be externally configured (e.g. using stty on Linux). The serial port must be 8-bit clean. This is automatically guaranteed when using RXTX. For the other codepaths it is part of the external port configuration. For example, on Linux the terminal driver associated with the port device needs to be taken out of "cooked" mode (the default) and placed in "raw" mode (again using stty).

listPorts(java.io.PrintStream) may be invoked to get a list of the port names that the RXTX library believes to be available.

The core API maps to the functionality of the firmware monitor. For example, lcdMsg(java.lang.String) maps to the firmware monitor command msg. Delays are added to no-response commands to throttle the maximum command rate.

You can use this either as a subsystem within a larger Java system, or you can use OHMMShell as an interactive or scheme-scripted interface to the hardware.

Bulk-receive methods such as allState(ohmm.OHMM.AllState) are provided, and their use is encouraged for repetitive polling, as they are significantly more efficient than multiple lower-level calls. This is due not only to reduced hlp-to-firmware protocol overhead but also to a reduction in the number of hlp-to-firmware stream flushes that are required to complete the transaction. Such flushes can be relatively expensive on some hlp platforms.

Communication errors including timeouts are internally detected, and the ErrorHandler, if any, is notified.

The lower level send(...) and recv*() methods to send and receive specific datatypes to the firmware are exposed for use if the firmware is extended and for debugging.

Site-Specific Extensions

Both this class and OHMMShell provide hooks to allow site-specific extensions, see OHMM_SITE_CLASS, getOHMMClass(), makeOHMM(java.lang.String[], java.lang.String), and OHMMShell.OHMM_SHELL_SITE.

Typical Usage Recipe

  1. Instantiate an ErrorHandler, e.g.
    ErrorHander h = new DefaultErrorHandler();
    If you require special error handling one option is to subclass DefaultErrorHandler. Convenience constructors such as OHMM(String) are also provided that internally instantiate DefaultErrorHandler.
  2. Construct an OHMM instance, either via makeOHMM(java.lang.String[], java.lang.String) or by direct construction. For example, to use RXTX
    OHMM a = new OHMM(h, rxtxPortName);
    where rxtxPortName is the platform-dependent name of the virtual serial port associated with the OHMM USB serial port. On Linux, this will usually be a string like /dev/ttyACM1.
  3. Call APIs such as lcdMsg(java.lang.String) to invoke monitor commands.
  4. Call close() before application exit.

Thread Safety

This class is designed to be used as a singleton. You should create at most one instance connected to the LLP monitor code at any time. You should not attempt to create multiple instances that talk to the same LLP either within the same Java virtual machine or in different JVMs.

All of the APIs which cause communication with the LLP are synchronized, so using this class should be thread-safe without external synchronization.

Author:
Marsette A. Vona

Nested Class Summary
 class OHMM.AllState
          state data structure for allState(ohmm.OHMM.AllState)
static class OHMM.AnalogChannel
          Analog sensor channels.
 class OHMM.ArmState
          state data structure for armState(ohmm.OHMM.ArmState)
static class OHMM.AXReg
           
 class OHMM.AXState
          state data structure for axState(ohmm.OHMM.AXState)
 class OHMM.BatState
          state data structure for batState(ohmm.OHMM.BatState)
static class OHMM.DigitalPin
          Digital sensor pins.
 class OHMM.MotState
          state data structure for motState(ohmm.OHMM.MotState)
 class OHMM.OHMMState
          state data structure for ohmmState(ohmm.OHMM.OHMMState)
 class OHMM.SenseState
          state data structure for senseState(ohmm.OHMM.SenseState)
 class OHMM.TaskState
          state data structure for taskState(ohmm.OHMM.TaskState)
 
Field Summary
static int ARM_ACTIVE
          status flag for status(int[])
static int ARM_AT_GOAL
          status flag for status(int[])
static int ARM_ELBOW
          Arm joint indices.
static int ARM_ERR_AX
          status flag for status(int[])
static int ARM_FREEZE_CAL
          Freeze the current AX12 goal position as calibration.
static int ARM_GRIPPER
          Arm joint indices.
static int ARM_SHOULDER
          Arm joint indices.
static int ARM_WRIST
          Arm joint indices.
protected  double avgRecvWait
          Avg time spent waiting to receive a single byte, in seconds.
protected  double avgSendWait
          Avg time spent waiting to send a single byte, in seconds.
static int AX_ERR_ANGLE_LIMIT
          AX12 error flags
static int AX_ERR_CHECKSUM
          AX12 error flags
static int AX_ERR_INSTRUCTION
          AX12 error flags
static int AX_ERR_OVERHEATING
          AX12 error flags
static int AX_ERR_OVERLOAD
          AX12 error flags
static int AX_ERR_RANGE
          AX12 error flags
static int AX_ERR_TIMEOUT
          AX12 error flags
static int AX_ERR_TRANSACTION
          Bitmask of AX12 error flags which indicate a failed transaction.
static int AX_ERR_VOLTAGE
          AX12 error flags
static int AX_ID_BCAST
          AX12 broadcast ID.
protected  int bytesReceived
          Total number of bytes received.
protected  int bytesSent
          Total number of bytes sent.
static int CMD_NAME_MAX
          Max command name length.
protected  java.util.Map<java.lang.String,java.lang.Integer> codes
          Command code cache.
protected  double commandDelay
          Time to wait after a no-response command, in seconds.
protected  boolean debug
          Whether to enable debug messages.
static double DEF_COMMAND_DELAY
          Default time to wait after a no-response command, in seconds.
static double DEF_PROCESS_INIT_WAIT
          Default time in seconds to wait for a com process to init.
static double DEF_RECV_POLL_TIME
          Default time to wait between checks for an available byte, in seconds.
static double DEF_TIMEOUT_FILE
          Default time to wait for a response from the firmware, in seconds, when using the file backend.
static double DEF_TIMEOUT_PROXY
          Default time to wait for a response from the firmware, in seconds, when using the command proxy.
static double DEF_TIMEOUT_RXTX
          Default time to wait for a response from the firmware, in seconds, when using the RXTX backend.
static java.text.DecimalFormat DF2
          For formatting with 2 decimal paces.
static java.text.DecimalFormat DF4
          For formatting with 4 decimal paces.
protected  ErrorHandler errorHandler
          The currently installed error handler.
protected  byte[] flushBuf
          Buffer where outgoing bytes are stored until they need to be flushed.
protected  int flushNext
          Next unused byte in flushBuf.
static int HLP_ERR_RECV
          status flag for status(int[])
static int HLP_ERR_SEND
          status flag for status(int[])
static double INIT_DELAY
          Default time to wait during the init() delays, in seconds.
static int INITIAL_FLUSH_BUF_LEN
          Initial length of flushBuf.
protected  java.io.InputStream istream
          Input stream from firmware.
static int LCD_WIDTH
          LCD width.
static int LEFT
          motor indices
protected  double maxRecvWait
          Max time spent waiting to receive a single byte, in seconds.
protected  double maxSendWait
          Max time spent waiting to send a single byte, in seconds.
protected  double minRecvWait
          Min time spent waiting to receive a single byte, in seconds.
protected  double minSendWait
          Min time spent waiting to send a single byte, in seconds.
static int MOT_ERR_ENC_L
          status flag for status(int[])
static int MOT_ERR_ENC_R
          status flag for status(int[])
static int MOT_ERR_VEL_L
          status flag for status(int[])
static int MOT_ERR_VEL_R
          status flag for status(int[])
static int NUM_INIT_ZEROS
          Number of zeros to send the firmware on init.
protected  int numTimeouts
          Total number of timeouts.
static java.lang.String OHMM_SITE_CLASS
          Fully qualified name of the default OHMM Site class.
static java.lang.String OHMM_SITE_CLASS_PROP
          See OHMM_SITE_CLASS.
protected  java.io.OutputStream ostream
          Output stream to firmware.
static int PID_FPF
          Monitor fixed point PID implementation fraction bits.
protected  double recvPollTime
          Time to wait between checks for an available byte, in seconds.
protected  boolean recvTimedOut
          Whether the last recvByte(boolean) timed out.
static int RIGHT
          motor indices
static int RXTX_BAUDRATE
          Serial baudrate for RXTX.
static int RXTX_OPEN_TIMEOUT_MS
          Timeout in ms to wait to open a port with RXTX.
static java.lang.String RXTX_PORT_OWNER_NAME
          RXTX Port owner name.
protected  gnu.io.SerialPort rxtxSerialPort
          RXTX serial port or null if not using RXTX.
static int SCAL_N
          LUT size for senseConfigAnalogLUT(int, int, int[], float[])
static int STATUS_INDEX_ARM
          status index for status(int[])
static int STATUS_INDEX_BAT
          status index for status(int[])
static int STATUS_INDEX_HLP
          status index for status(int[])
static int STATUS_INDEX_MOT
          status index for status(int[])
static int STATUS_INDEX_TASK
          status index for status(int[])
static int STATUS_LEN
          num bytes for status(int[]), see getStatusLength()
static int TASK_ERR_COLLISION
          status flag for status(int[])
static int TASK_ERR_MEM
          status flag for status(int[])
protected  double timeout
          Time to wait for a response from the firmware, in seconds.
protected  double totalRecvWait
          Total time spent waiting to receive bytes, in seconds.
protected  double totalSendWait
          Total time spent waiting to send bytes, in seconds.
static java.lang.String USAGE
          makeOHMM(java.lang.String[], java.lang.String) Usage message.
static Version VERSION
          Version info for the OHMM hlp library.
 
Constructor Summary
OHMM()
          Covers OHMM(ErrorHandler) with a new DefaultErrorHandler.
OHMM(double initWait, java.lang.String[] cmdLine)
          Covers OHMM(ErrorHandler, double, String[]) with a new DefaultErrorHandler.
OHMM(ErrorHandler errorHandler)
          Defers initialization to a call to init(double, FileOutputStream, FileInputStream).
OHMM(ErrorHandler errorHandler, double initWait, java.lang.String[] cmdLine)
          Talk to the hardware via the specified process.
OHMM(ErrorHandler errorHandler, java.io.File port)
          Talk to the hardware on the specified serial port, accessed as a file.
OHMM(ErrorHandler errorHandler, java.lang.String portName)
          Similar to OHMM(ErrorHandler, File), but uses RXTX library to access the serial port.
OHMM(ErrorHandler errorHandler, java.lang.String[] cmdLine)
          Covers OHMM(ErrorHandler, double, String[]) with DEF_PROCESS_INIT_WAIT.
OHMM(java.io.File port)
          Covers OHMM(ErrorHandler, File) with a new DefaultErrorHandler.
OHMM(java.lang.String portName)
          Covers OHMM(ErrorHandler, String) with a new DefaultErrorHandler.
OHMM(java.lang.String[] cmdLine)
          Covers OHMM(ErrorHandler, double, String[]) with a new DefaultErrorHandler and DEF_PROCESS_INIT_WAIT.
 
Method Summary
 OHMM.AllState allState()
          covers allState(AllState), always conses
 OHMM.AllState allState(OHMM.AllState state)
          Runs monitor command "allst".
 boolean armActive()
          Runs monitor command "aa".
 boolean armAtGoal()
          Runs monitor command "aag".
 void armCal()
          Runs monitor command "ac".
 void armEnable(boolean enable)
          Runs monitor command "ae".
 boolean armFreezeAllCal()
          Runs monitor command "afac".
 int[] armGetAllCal(boolean freeze)
          Covers armGetAllCal(int[], boolean), always conses.
 int[] armGetAllCal(int[] offset, boolean freeze)
          Runs monitor command "agac".
 int[] armGetAllJoints()
          Covers armGetAllJoints(int[]), always conses.
 int[] armGetAllJoints(int[] counts)
          Runs monitor command "agaj".
 float[] armGetAllJointsDeg()
          Covers armGetAllJointsDeg(float[]), always conses.
 float[] armGetAllJointsDeg(float[] angle)
          Runs monitor command "agajd".
 float[] armGetAllJointsRad()
          Covers armGetAllJointsRad(float[]), always conses.
 float[] armGetAllJointsRad(float[] angle)
          Runs monitor command "agajr".
 int armGetCal(int joint, boolean freeze)
          Runs monitor command "agc".
 float armGetGripper()
          Runs monitor command "agg".
 int armGetJoint(int joint)
          Runs monitor command "agj".
 float armGetJointDeg(int joint)
          Runs monitor command "agjd".
 float armGetJointRad(int joint)
          Runs monitor command "agjr".
 int[] armGetLoads()
          Covers armGetLoads(int[]), always conses.
 int[] armGetLoads(int[] load)
          Runs monitor command "agl".
 int armGetNumAXErrors()
          Runs monitor command "agne".
 int[] armGetTemps()
          Covers armGetTemps(int[]), always conses.
 int[] armGetTemps(int[] temp)
          Runs monitor command "agt".
 void armHome()
          Runs monitor command "ah".
 void armReinit()
          Runs monitor command "ari".
 boolean armSetAllCal(int... offset)
          Runs monitor command "asac".
 boolean armSetAllJoints(int... counts)
          Runs monitor command "asaj".
 boolean armSetAllJointsDeg(float... angle)
          Runs monitor command "asajd".
 boolean armSetAllJointsRad(float... angle)
          Runs monitor command "asajd".
 boolean armSetCal(int joint, int offset)
          Runs monitor command "asc".
 boolean armSetGripper(float state)
          Runs monitor command "asg".
 boolean armSetJoint(int joint, int counts)
          Runs monitor command "asj".
 boolean armSetJointDeg(int joint, float angle)
          Runs monitor command "asjd".
 boolean armSetJointRad(int joint, float angle)
          Runs monitor command "asjr".
 OHMM.ArmState armState()
          covers armState(ArmState), always conses
 OHMM.ArmState armState(OHMM.ArmState state)
          Runs monitor command "armst".
 int axAction(int id)
          Runs the monitor command "axact".
static java.lang.String axErrToString(int err)
          Convert an AX12 error code to a human readable string.
 void axESTOP()
          Runs monitor command "axestop".
 int axGetLoad(int id)
          Runs monitor command "axgl".
 int axGetNumOverflows()
          Runs monitor command "axgno".
 int axGetNumRetries()
          Runs monitor command "axgnr".
 int axGetNumTimeouts()
          Runs monitor command "axgnt".
 int axGetPos(int id)
          Runs monitor command "axgp".
 float axGetPosDeg(int id)
          Runs monitor command "axgpd".
 float axGetPosRad(int id)
          Runs monitor command "axgpr".
 int axGetTemp(int id)
          Runs monitor command "axgt".
 float axGetVolts(int id)
          Runs monitor command "axgv".
 int axPing(int id)
          Runs the monitor command "axpng".
 int axRead(int id, int reg)
          Runs the monitor command "axrd".
 int axRead(int id, OHMM.AXReg reg)
          Like axRead(int, int) but takes an OHMM.AXReg.
 int axRead16(int id, int reg)
          Runs the monitor command "axrd16".
 int axRead16(int id, OHMM.AXReg reg)
          Like axRead16(int, int) but takes an OHMM.AXReg.
 int axRegSetGoal(int id, int goal)
          Like axSetGoal(int, int) but does a reg write.
 int axRegSetGoalDeg(int id, float goal)
          like axRegSetGoal(int, int) but in degrees
 int axRegSetGoalRad(int id, float goal)
          like axRegSetGoal(int, int) but in radians
 int axRegWrite(int id, int reg, int val)
          Runs the monitor command "axrwr".
 int axRegWrite(int id, OHMM.AXReg reg, int val)
          Like axRegWrite(int, int, int) but takes an OHMM.AXReg.
 int axRegWrite11(int id, int reg, int val)
          Runs monitor command "axrwr11".
 int axRegWrite11(int id, OHMM.AXReg reg, int val)
          Like axRegWrite11(int, int, int) but takes an OHMM.AXReg.
 void axReinit()
          Runs the monitor command "axri".
 int axSetAngleLimits(int id, int cwLimit, int ccwLimit)
          Runs monitor command "axsal".
 int axSetGoal(int id, int goal)
          Runs monitor command "axsg".
 int axSetGoalDeg(int id, float goal)
          like axSetGoal(int, int) but in degrees
protected  int axSetGoalImpl(java.lang.String cmd, int id, float goal)
          comon impl of set goal (float) methods
protected  int axSetGoalImpl(java.lang.String cmd, int id, int goal)
          comon impl of set goal (int) methods
 int axSetGoalRad(int id, float goal)
          like axSetGoal(int, int) but in radians
 OHMM.AXState axState()
          covers axState(AXState), always conses
 OHMM.AXState axState(OHMM.AXState state)
          Runs monitor command "axst".
 int axTorqueEnable(int id, boolean enable)
          Runs monitor command "axte".
 int axWrite(int id, int reg, int val)
          Runs monitor command "axwr".
 int axWrite(int id, OHMM.AXReg reg, int val)
          Like axWrite(int, int, int) but takes an OHMM.AXReg.
 int axWrite11(int id, int reg, int val)
          Runs monitor command "axwr11".
 int axWrite11(int id, OHMM.AXReg reg, int val)
          Like axWrite11(int, int, int) but takes an OHMM.AXReg.
protected  int axWriteImpl(java.lang.String cmd, int id, int reg, int val, int len)
          common impl of the ax write methods
 int batMillivolts()
          Runs monitor command "bat".
 OHMM.BatState batState()
          covers batState(BatState), always conses
 OHMM.BatState batState(OHMM.BatState state)
          Runs monitor command "batst".
 void close()
          Close communications with the hardware.
protected  void dbg(java.lang.String prefix, byte b)
          Emit a debug message documenting a comms byte iff debug.
 int drainReceiveBuffer()
          Drain any bytes waiting in the receive buffer from the firware.
 void dumpStats()
          dumpStats(PrintStream) to System.out
 void dumpStats(java.io.PrintStream s)
          Dump a human-readable summary of the comm stats.
 byte echo(byte out)
          Ask the firmware to echo a byte.
 float echo(float out)
          Ask the firmware to echo a float.
 int echo(int nb, int out)
          Ask the firmware to echo an int.
 float echoFix(float out)
          Ask the firmware to echo a fix.
 void estop()
          Runs monitor command "estop".
static java.lang.String fmt2(float f)
          format f with 2 decimal places
static java.lang.String fmt4(float f)
          format f with 4 decimal places
 int freeRam()
          Runs monitor command "fr".
 int getBytesReceived()
          Get the total number of bytes received thus far.
 int getBytesSent()
          Get the total number of bytes sent thus far.
 java.lang.Integer getCmdCode(java.lang.String name)
          Get a binary command code corresponding to a monitor command name.
 double getCommandDelay()
          Get the time to wait after a no-response command, in seconds.
 double getCurrentTime()
          get the current time in seconds
 boolean getDebug()
          Get whether to enable debug output to stderr.
 ErrorHandler getErrorHandler()
          Get the error handler.
 java.lang.String getHLPVersion()
          get a human-readable string giving the OHMM hlp library version
 java.lang.String getMonitorVersion()
          Runs monitor command "ver".
 int getNumTimeouts()
          Get the total number of timeouts.
static java.lang.Class<? extends OHMM> getOHMMClass()
          Determine what class makeOHMM(java.lang.String[], java.lang.String) instantiates.
 double getRecvPollTime()
          Get the time to wait between polls for a received byte, in seconds.
 int getStatusIndexArm()
          Get module status(int[]) byte index.
 int getStatusIndexBat()
          Get module status(int[]) byte index.
 int getStatusIndexHLP()
          Get module status(int[]) byte index.
 int getStatusIndexMot()
          Get module status(int[]) byte index.
 int getStatusIndexTask()
          Get module status(int[]) byte index.
 int getStatusLength()
          Get number of bytes expected from llp for status(int[]).
 double getTimeout()
          Get the time to wait for a response from the firmware, in seconds.
 boolean init()
          (Re)initialize communications.
 boolean init(double timeout, java.io.FileOutputStream ostream, java.io.FileInputStream istream)
          Covers init(), first setting timeout, ostream, and istream.
 void lcdAlert(int sec, java.lang.String msgTop, java.lang.String msgBot)
          Runs monitor command "alert".
 void lcdMsg(java.lang.String msg)
          Runs monitor command "msg".
 void lcdMsgClr()
          Runs monitor command "msgclr".
 void lcdSysMsg(int start, int width, java.lang.String msg)
          Runs monitor command "sysmsg".
 void lcdSysMsgClr(int start, int width)
          Runs monitor command "sysmsgclr".
static void listPorts()
          listPorts(PrintStream) to System.out
static void listPorts(java.io.PrintStream s)
          Convenience method to query the list of available ports according to RXTX.
 OHMM.AllState makeAllState()
          Factory method to cons an OHMM.AllState.
static OHMM makeOHMM(java.lang.String[] argv)
          Covers makeOHMM(String[], String), no extra usage.
static OHMM makeOHMM(java.lang.String[] argv, java.lang.String extraUsage)
          Constructs an OHMM from command line parameters.
 void motFree()
          Runs monitor command "mfr".
 byte motGetErrors()
          Runs monitor command "mge".
 float[] motGetGainCmd(float[] gn)
          Runs the monitor command "mggv".
 float[] motGetPos()
          covers motGetPos(float[]), always conses
 float[] motGetPos(float[] lr)
          Runs the monitor command "mgp".
 int[] motGetPosCounts()
          covers motGetPosCounts(int[]), always conses
 int[] motGetPosCounts(int[] lr)
          Runs the monitor command "mgc".
 float[] motGetVel()
          covers motGetVel(float[]), always conses
 float[] motGetVel(float[] lr)
          Runs the monitor command "mgv".
 float[] motGetVelCmd()
          covers motGetVelCmd(float[]), always conses
 float[] motGetVelCmd(float[] lr)
          Runs the monitor command "mgvc".
 void motKick(int l, int r)
          Runs monitor command "mk".
 void motReinit()
          Runs monitor command "mri".
 void motSetDiffVelIGain(float g)
          Runs the monitor command "msdi".
 boolean motSetVelCmd(float l, float r)
          Runs the monitor command "msv".
 void motSetVelDGain(float g)
          Runs the monitor command "msvd".
 void motSetVelIGain(float g)
          Runs the monitor command "msvi".
 void motSetVelPGain(float g)
          Runs the monitor command "msvp".
 OHMM.MotState motState()
          covers motState(MotState), always conses
 OHMM.MotState motState(OHMM.MotState state)
          Runs monitor command "motst".
 void noResponseDelay()
          Delay by the current command delay.
 OHMM.OHMMState ohmmState()
          covers ohmmState(OHMMState), always conses
 OHMM.OHMMState ohmmState(OHMM.OHMMState state)
          Runs monitor command "ohmst".
protected static void printUsage(java.lang.String extra)
          Print USAGE.
 boolean recvBoolean()
          Get a boolean as a byte, 0 false, 1 true.
 byte recvByte()
          Covers recvByte(boolean), timeoutOk = false.
 byte recvByte(boolean timeoutOk)
          Get a byte from the firmware.
 char recvChar()
          Get an ASCII char.
 float recvFix(int f)
          Get a 2 byte fixed point value, MSB first.
 float recvFloat()
          Get a float, MSB first.
 int recvInt(int size)
          Get an integer, MSB first.
 java.lang.String recvString()
          Covers recvString(boolean), does not whitespace terminate
 java.lang.String recvString(boolean wsTerminate)
          Receive a null terminated string.
 void resetStats()
          Reset all comm stats.
 void send(boolean b)
          covers send(boolean, boolean), always flushes
 void send(boolean b, boolean flush)
          Send a boolean to the firmware as a byte (0 or 1).
 void send(byte b)
          covers send(byte, boolean), always flushes
 void send(byte[] bytes)
          covers send(byte[], boolean), always flushes
 void send(byte[] bytes, boolean flush)
          Send an array of bytes to the firmware.
 void send(byte b, boolean flush)
          Send a byte to the firmware.
 void send(char c)
          covers send(char, boolean), always flushes
 void send(char c, boolean flush)
          Send an ASCII char to the firmware.
 void send(float f)
          covers send(float, boolean), always flushes
 void send(float f, boolean flush)
          Send a float to the firmware, MSB first.
 void send(int i, int size)
          covers send(int, int, boolean), always flushes
 void send(int i, int size, boolean flush)
          Send an int to the firmware, MSB first.
 void send(java.lang.String s)
          covers send(String, boolean), always flushes
 void send(java.lang.String s, boolean flush)
          Send a null terminated ASCII string to the firmware.
 void send(java.lang.String s, int len)
          covers send(String, int, boolean), always flushes
 void send(java.lang.String s, int n, boolean flush)
          Send fixed length ASCII string to the firmware.
 void sendCmdCode(java.lang.String cmdName)
          covers sendCmdCode(String, boolean), always flushes
 void sendCmdCode(java.lang.String cmdName, boolean flush)
          Convenience to getCmdCode(java.lang.String) and send(int, int, boolean).
 void sendFix(float x, int f)
          covers sendFix(float, int, boolean), always flushes
 void sendFix(float x, int f, boolean flush)
          Send a 2 byte fixed point value to the firmware, MSB first.
 void sendFlush()
          flush any pending writes
 void sendZeros(int n)
          Send zeros.
 boolean senseConfigAnalog(int channel, int numSamples)
          Runs monitor command "sca".
 boolean senseConfigAnalog(OHMM.AnalogChannel channel, int numSamples)
          Covers senseConfigAnalog(int, int)
 boolean senseConfigAnalogIR(int channel, int numSamples)
          Runs monitor command "scair".
 boolean senseConfigAnalogIR(OHMM.AnalogChannel channel, int numSamples)
          Covers senseConfigAnalogIR(int, int)
 boolean senseConfigAnalogLUT(int channel, int numSamples, int[] lutA, float[] lutO)
          Runs monitor command "scal".
 boolean senseConfigAnalogLUT(OHMM.AnalogChannel channel, int numSamples, int[] lutA, float[] lutO)
          Covers senseConfigAnalogLUT(int, int, int[], float[])
 boolean senseConfigDigital(int pin, boolean pullup, boolean invert)
          Runs monitor command "scd".
 boolean senseConfigDigital(OHMM.DigitalPin pin, boolean pullup, boolean invert)
          Covers senseConfigDigital(int, boolean, boolean)
 float senseReadAnalog(int channel)
          Runs monitor command "sra".
 float senseReadAnalog(OHMM.AnalogChannel channel)
          Covers senseReadAnalog(int).
 boolean senseReadDigital(int pin)
          Runs monitor command "srd".
 boolean senseReadDigital(OHMM.DigitalPin pin)
          Covers senseReadDigital(int).
 void senseReinit()
          Runs monitor command "sri".
 OHMM.SenseState senseState()
          covers senseState(SenseState), always conses
 OHMM.SenseState senseState(OHMM.SenseState state)
          Runs monitor command "snsst".
 void setCommandDelay(double commandDelay)
          Set the time to wait after a no-response command, in seconds.
 void setDebug(boolean debug)
          Set whether to enable debug output to stderr.
 void setErrorHandler(ErrorHandler errorHandler)
          Set the error handler.
 void setRecvPollTime(double recvPollTime)
          Set the time to wait between polls for a received byte, in seconds.
 void setTimeout(double timeout)
          Set the time to wait for a response from the firmware, in seconds.
 void shtdn()
          Runs monitor command "shtdn".
 void sleep(double seconds)
          sleep at least the specfied time in seconds
 int[] status()
          covers status(int[])
 int[] status(int[] status)
          Runs monitor command "status".
 java.lang.String statusToString(int[] status)
          Convert status bytes to a human readable message.
 java.lang.StringBuilder statusToString(int[] status, java.lang.StringBuilder sb)
          helper for statusToString(int[])
 OHMM.TaskState taskState()
          covers taskState(TaskState), always conses
 OHMM.TaskState taskState(OHMM.TaskState state)
          Runs monitor command "tskst".
 int ticks()
          Runs monitor command "tck".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USAGE

public static final java.lang.String USAGE

makeOHMM(java.lang.String[], java.lang.String) Usage message.

See Also:
Constant Field Values

OHMM_SITE_CLASS

public static final java.lang.String OHMM_SITE_CLASS

Fully qualified name of the default OHMM Site class.

May be overriden by the java property OHMM_SITE_CLASS_PROP.

If this class is present, it must be a subclass of OHMM. makeOHMM(java.lang.String[], java.lang.String) will use it instead of OHMM.

See Also:
Constant Field Values

OHMM_SITE_CLASS_PROP

public static final java.lang.String OHMM_SITE_CLASS_PROP

See OHMM_SITE_CLASS.

See Also:
Constant Field Values

VERSION

public static final Version VERSION

Version info for the OHMM hlp library.

getHLPVersion() is a convenience; getMonitorVersion() asks the firmware for its version, which may differ.


DF2

public static final java.text.DecimalFormat DF2
For formatting with 2 decimal paces.


DF4

public static final java.text.DecimalFormat DF4
For formatting with 4 decimal paces.


DEF_TIMEOUT_RXTX

public static final double DEF_TIMEOUT_RXTX

Default time to wait for a response from the firmware, in seconds, when using the RXTX backend.

See Also:
Constant Field Values

DEF_TIMEOUT_FILE

public static final double DEF_TIMEOUT_FILE

Default time to wait for a response from the firmware, in seconds, when using the file backend.

See Also:
Constant Field Values

DEF_TIMEOUT_PROXY

public static final double DEF_TIMEOUT_PROXY

Default time to wait for a response from the firmware, in seconds, when using the command proxy.

See Also:
Constant Field Values

DEF_RECV_POLL_TIME

public static final double DEF_RECV_POLL_TIME

Default time to wait between checks for an available byte, in seconds.

See Also:
Constant Field Values

DEF_COMMAND_DELAY

public static final double DEF_COMMAND_DELAY

Default time to wait after a no-response command, in seconds.

See Also:
Constant Field Values

DEF_PROCESS_INIT_WAIT

public static final double DEF_PROCESS_INIT_WAIT

Default time in seconds to wait for a com process to init.

See Also:
Constant Field Values

NUM_INIT_ZEROS

public static final int NUM_INIT_ZEROS

Number of zeros to send the firmware on init.

See Also:
Constant Field Values

INIT_DELAY

public static final double INIT_DELAY

Default time to wait during the init() delays, in seconds.

See Also:
Constant Field Values

RXTX_PORT_OWNER_NAME

public static final java.lang.String RXTX_PORT_OWNER_NAME

RXTX Port owner name.

See Also:
Constant Field Values

RXTX_OPEN_TIMEOUT_MS

public static final int RXTX_OPEN_TIMEOUT_MS

Timeout in ms to wait to open a port with RXTX.

See Also:
Constant Field Values

RXTX_BAUDRATE

public static final int RXTX_BAUDRATE

Serial baudrate for RXTX.

See Also:
Constant Field Values

INITIAL_FLUSH_BUF_LEN

public static final int INITIAL_FLUSH_BUF_LEN

Initial length of flushBuf.

See Also:
Constant Field Values

CMD_NAME_MAX

public static final int CMD_NAME_MAX

Max command name length.

See Also:
Constant Field Values

SCAL_N

public static final int SCAL_N
LUT size for senseConfigAnalogLUT(int, int, int[], float[])

See Also:
Constant Field Values

LCD_WIDTH

public static final int LCD_WIDTH
LCD width.

See Also:
Constant Field Values

PID_FPF

public static final int PID_FPF
Monitor fixed point PID implementation fraction bits.

See Also:
Constant Field Values

codes

protected java.util.Map<java.lang.String,java.lang.Integer> codes

Command code cache.


STATUS_LEN

public static final int STATUS_LEN
num bytes for status(int[]), see getStatusLength()

See Also:
Constant Field Values

STATUS_INDEX_BAT

public static final int STATUS_INDEX_BAT
status index for status(int[])

See Also:
Constant Field Values

STATUS_INDEX_TASK

public static final int STATUS_INDEX_TASK
status index for status(int[])

See Also:
Constant Field Values

STATUS_INDEX_HLP

public static final int STATUS_INDEX_HLP
status index for status(int[])

See Also:
Constant Field Values

STATUS_INDEX_MOT

public static final int STATUS_INDEX_MOT
status index for status(int[])

See Also:
Constant Field Values

STATUS_INDEX_ARM

public static final int STATUS_INDEX_ARM
status index for status(int[])

See Also:
Constant Field Values

TASK_ERR_COLLISION

public static final int TASK_ERR_COLLISION
status flag for status(int[])

See Also:
Constant Field Values

TASK_ERR_MEM

public static final int TASK_ERR_MEM
status flag for status(int[])

See Also:
Constant Field Values

HLP_ERR_SEND

public static final int HLP_ERR_SEND
status flag for status(int[])

See Also:
Constant Field Values

HLP_ERR_RECV

public static final int HLP_ERR_RECV
status flag for status(int[])

See Also:
Constant Field Values

MOT_ERR_ENC_L

public static final int MOT_ERR_ENC_L
status flag for status(int[])

See Also:
Constant Field Values

MOT_ERR_ENC_R

public static final int MOT_ERR_ENC_R
status flag for status(int[])

See Also:
Constant Field Values

MOT_ERR_VEL_L

public static final int MOT_ERR_VEL_L
status flag for status(int[])

See Also:
Constant Field Values

MOT_ERR_VEL_R

public static final int MOT_ERR_VEL_R
status flag for status(int[])

See Also:
Constant Field Values

ARM_ERR_AX

public static final int ARM_ERR_AX
status flag for status(int[])

See Also:
Constant Field Values

ARM_ACTIVE

public static final int ARM_ACTIVE
status flag for status(int[])

See Also:
Constant Field Values

ARM_AT_GOAL

public static final int ARM_AT_GOAL
status flag for status(int[])

See Also:
Constant Field Values

AX_ERR_TIMEOUT

public static final int AX_ERR_TIMEOUT
AX12 error flags

See Also:
Constant Field Values

AX_ERR_INSTRUCTION

public static final int AX_ERR_INSTRUCTION
AX12 error flags

See Also:
Constant Field Values

AX_ERR_OVERLOAD

public static final int AX_ERR_OVERLOAD
AX12 error flags

See Also:
Constant Field Values

AX_ERR_CHECKSUM

public static final int AX_ERR_CHECKSUM
AX12 error flags

See Also:
Constant Field Values

AX_ERR_RANGE

public static final int AX_ERR_RANGE
AX12 error flags

See Also:
Constant Field Values

AX_ERR_OVERHEATING

public static final int AX_ERR_OVERHEATING
AX12 error flags

See Also:
Constant Field Values

AX_ERR_ANGLE_LIMIT

public static final int AX_ERR_ANGLE_LIMIT
AX12 error flags

See Also:
Constant Field Values

AX_ERR_VOLTAGE

public static final int AX_ERR_VOLTAGE
AX12 error flags

See Also:
Constant Field Values

AX_ERR_TRANSACTION

public static final int AX_ERR_TRANSACTION
Bitmask of AX12 error flags which indicate a failed transaction.

See Also:
Constant Field Values

AX_ID_BCAST

public static final int AX_ID_BCAST
AX12 broadcast ID.

See Also:
Constant Field Values

ARM_SHOULDER

public static final int ARM_SHOULDER
Arm joint indices.

See Also:
Constant Field Values

ARM_ELBOW

public static final int ARM_ELBOW
Arm joint indices.

See Also:
Constant Field Values

ARM_WRIST

public static final int ARM_WRIST
Arm joint indices.

See Also:
Constant Field Values

ARM_GRIPPER

public static final int ARM_GRIPPER
Arm joint indices.

See Also:
Constant Field Values

ARM_FREEZE_CAL

public static final int ARM_FREEZE_CAL
Freeze the current AX12 goal position as calibration.

See Also:
Constant Field Values

LEFT

public static final int LEFT
motor indices

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
motor indices

See Also:
Constant Field Values

flushNext

protected int flushNext

Next unused byte in flushBuf.


flushBuf

protected byte[] flushBuf

Buffer where outgoing bytes are stored until they need to be flushed.

Will be grown as necessary.


rxtxSerialPort

protected gnu.io.SerialPort rxtxSerialPort

RXTX serial port or null if not using RXTX.


ostream

protected java.io.OutputStream ostream

Output stream to firmware.


istream

protected java.io.InputStream istream

Input stream from firmware.


errorHandler

protected ErrorHandler errorHandler

The currently installed error handler.


recvTimedOut

protected boolean recvTimedOut

Whether the last recvByte(boolean) timed out.


debug

protected boolean debug

Whether to enable debug messages.


bytesSent

protected int bytesSent

Total number of bytes sent.


bytesReceived

protected int bytesReceived

Total number of bytes received.


numTimeouts

protected int numTimeouts

Total number of timeouts.


minRecvWait

protected double minRecvWait

Min time spent waiting to receive a single byte, in seconds.


maxRecvWait

protected double maxRecvWait

Max time spent waiting to receive a single byte, in seconds.


totalRecvWait

protected double totalRecvWait

Total time spent waiting to receive bytes, in seconds.


avgRecvWait

protected double avgRecvWait

Avg time spent waiting to receive a single byte, in seconds.


minSendWait

protected double minSendWait

Min time spent waiting to send a single byte, in seconds.


maxSendWait

protected double maxSendWait

Max time spent waiting to send a single byte, in seconds.


totalSendWait

protected double totalSendWait

Total time spent waiting to send bytes, in seconds.


avgSendWait

protected double avgSendWait

Avg time spent waiting to send a single byte, in seconds.


timeout

protected double timeout

Time to wait for a response from the firmware, in seconds.


recvPollTime

protected double recvPollTime

Time to wait between checks for an available byte, in seconds.


commandDelay

protected double commandDelay

Time to wait after a no-response command, in seconds.

Constructor Detail

OHMM

public OHMM(ErrorHandler errorHandler,
            java.io.File port)

Talk to the hardware on the specified serial port, accessed as a file.

Parameters:
errorHandler - the ErrorHandler, null if none
port - the file representing the port connected to the hardware. Must already be configured for correct data rate, format, etc.

OHMM

public OHMM(java.io.File port)

Covers OHMM(ErrorHandler, File) with a new DefaultErrorHandler.


OHMM

public OHMM(ErrorHandler errorHandler,
            java.lang.String portName)

Similar to OHMM(ErrorHandler, File), but uses RXTX library to access the serial port.

Parameters:
portName - an os-dependent port name as used by RXTX. Use listPorts(java.io.PrintStream) to show all available names on your system.

OHMM

public OHMM(java.lang.String portName)

Covers OHMM(ErrorHandler, String) with a new DefaultErrorHandler.


OHMM

public OHMM(ErrorHandler errorHandler,
            double initWait,
            java.lang.String[] cmdLine)

Talk to the hardware via the specified process.

Parameters:
errorHandler - the ErrorHandler, null if none
initWait - time in seconds to wait for the process to init
cmdLine - the command and its arguments to start the communication process

OHMM

public OHMM(ErrorHandler errorHandler,
            java.lang.String[] cmdLine)

Covers OHMM(ErrorHandler, double, String[]) with DEF_PROCESS_INIT_WAIT.


OHMM

public OHMM(double initWait,
            java.lang.String[] cmdLine)

Covers OHMM(ErrorHandler, double, String[]) with a new DefaultErrorHandler.


OHMM

public OHMM(java.lang.String[] cmdLine)

Covers OHMM(ErrorHandler, double, String[]) with a new DefaultErrorHandler and DEF_PROCESS_INIT_WAIT.


OHMM

public OHMM(ErrorHandler errorHandler)

Defers initialization to a call to init(double, FileOutputStream, FileInputStream).


OHMM

public OHMM()

Covers OHMM(ErrorHandler) with a new DefaultErrorHandler.

Method Detail

init

public boolean init()

(Re)initialize communications.

Clears the command code cache and resets stats.

This will block for at least INIT_DELAY sec, and further by up to twice timeout sec if the monitor was already in quiet or binary mode.

Returns:
true on success

init

public boolean init(double timeout,
                    java.io.FileOutputStream ostream,
                    java.io.FileInputStream istream)

Covers init(), first setting timeout, ostream, and istream.

For use with the deferred initialization constructor OHMM().

Parameters:
timeout - see timeout
ostream - see ostream
istream - see istream

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)

Set the error handler.

Parameters:
errorHandler - the new error handler, null for none

getErrorHandler

public ErrorHandler getErrorHandler()

Get the error handler.

Returns:
the error handler, null for none

setDebug

public void setDebug(boolean debug)

Set whether to enable debug output to stderr.

Parameters:
debug - whether to enable debug output to stderr

getDebug

public boolean getDebug()

Get whether to enable debug output to stderr.

Returns:
whether to enable debug output to stderr

setTimeout

public void setTimeout(double timeout)

Set the time to wait for a response from the firmware, in seconds.

Parameters:
timeout - the time to wait for a response from the firmware, in seconds

getTimeout

public double getTimeout()

Get the time to wait for a response from the firmware, in seconds.

Returns:
the time to wait for a response from the firmware, in seconds

setRecvPollTime

public void setRecvPollTime(double recvPollTime)

Set the time to wait between polls for a received byte, in seconds.

Parameters:
recvPollTime - the time to wait between polls for a received byte, in seconds

getRecvPollTime

public double getRecvPollTime()

Get the time to wait between polls for a received byte, in seconds.

Returns:
the time to wait between polls for a received byte, in seconds

setCommandDelay

public void setCommandDelay(double commandDelay)

Set the time to wait after a no-response command, in seconds.

Parameters:
commandDelay - the time to wait after a no-response command, in seconds

getCommandDelay

public double getCommandDelay()

Get the time to wait after a no-response command, in seconds.

Returns:
the time to wait after a no-response command, in seconds

getHLPVersion

public java.lang.String getHLPVersion()
get a human-readable string giving the OHMM hlp library version


estop

public void estop()
Runs monitor command "estop".


shtdn

public void shtdn()
Runs monitor command "shtdn".


getMonitorVersion

public java.lang.String getMonitorVersion()
Runs monitor command "ver".

Returns:
the monitor version string

getStatusLength

public int getStatusLength()

Get number of bytes expected from llp for status(int[]).

Subclasses may override this.


getStatusIndexBat

public int getStatusIndexBat()

Get module status(int[]) byte index.

Subclasses may override this.


getStatusIndexTask

public int getStatusIndexTask()

Get module status(int[]) byte index.

Subclasses may override this.


getStatusIndexHLP

public int getStatusIndexHLP()

Get module status(int[]) byte index.

Subclasses may override this.


getStatusIndexMot

public int getStatusIndexMot()

Get module status(int[]) byte index.

Subclasses may override this.


getStatusIndexArm

public int getStatusIndexArm()

Get module status(int[]) byte index.

Subclasses may override this.


status

public int[] status(int[] status)
Runs monitor command "status".

Parameters:
status - up to getStatusLength() bytes of status is returned here, or null to cons
Returns:
status Returned floats are indexed by STATUS_INDEX_*.

status

public int[] status()
covers status(int[])


statusToString

public java.lang.String statusToString(int[] status)
Convert status bytes to a human readable message.

Parameters:
status - up to getStatusLength() bytes
Returns:
a corresponding message

statusToString

public java.lang.StringBuilder statusToString(int[] status,
                                              java.lang.StringBuilder sb)
helper for statusToString(int[])


ticks

public int ticks()
Runs monitor command "tck".


ohmmState

public OHMM.OHMMState ohmmState(OHMM.OHMMState state)
Runs monitor command "ohmst".

Parameters:
state - the state is returned here, or null to cons
Returns:
state

ohmmState

public OHMM.OHMMState ohmmState()
covers ohmmState(OHMMState), always conses


makeAllState

public OHMM.AllState makeAllState()

Factory method to cons an OHMM.AllState.

May be overridden by subclasses that also need to subclass OHMM.AllState.


allState

public OHMM.AllState allState(OHMM.AllState state)
Runs monitor command "allst".

Parameters:
state - the state is returned here, or null to cons with makeAllState()
Returns:
state

allState

public OHMM.AllState allState()
covers allState(AllState), always conses


freeRam

public int freeRam()
Runs monitor command "fr".

Returns:
estimated bytes free

taskState

public OHMM.TaskState taskState(OHMM.TaskState state)
Runs monitor command "tskst".

Parameters:
state - the state is returned here, or null to cons
Returns:
state

taskState

public OHMM.TaskState taskState()
covers taskState(TaskState), always conses


lcdMsg

public void lcdMsg(java.lang.String msg)
Runs monitor command "msg".

Parameters:
msg - the message to display, up to the first LCD_WIDTH chars are used

lcdSysMsg

public void lcdSysMsg(int start,
                      int width,
                      java.lang.String msg)
Runs monitor command "sysmsg".

Parameters:
start - the start column in the range 0 to LCD_WIDTH-1
width - the width in the range 1 to LCD_WIDTH
msg - the message to display, up to the first width chars are used

lcdAlert

public void lcdAlert(int sec,
                     java.lang.String msgTop,
                     java.lang.String msgBot)
Runs monitor command "alert".

Parameters:
sec - alert duration in seconds, max 255
msgTop - the message to display on the top line of the LCD, up to the first LCD_WIDTH chars are used
msgBot - the message to display on the bottom line of the LCD, up to the first LCD_WIDTH chars are used

lcdMsgClr

public void lcdMsgClr()
Runs monitor command "msgclr".


lcdSysMsgClr

public void lcdSysMsgClr(int start,
                         int width)
Runs monitor command "sysmsgclr".

Parameters:
start - the start column in the range 0 to LCD_WIDTH-1
width - the width in the range 1 to LCD_WIDTH

batMillivolts

public int batMillivolts()
Runs monitor command "bat".

Returns:
the current battery millivolts

batState

public OHMM.BatState batState(OHMM.BatState state)
Runs monitor command "batst".

Parameters:
state - the state is returned here, or null to cons
Returns:
state

batState

public OHMM.BatState batState()
covers batState(BatState), always conses


senseReinit

public void senseReinit()
Runs monitor command "sri".


senseConfigDigital

public boolean senseConfigDigital(int pin,
                                  boolean pullup,
                                  boolean invert)
Runs monitor command "scd".

Parameters:
pin - the digital pin index, an OrangutanDigital IO_<port><pin> value
pullup - whether to enable the pullup resistor
invert - whether to invert the reading
Returns:
true iff the config was valid

senseConfigDigital

public boolean senseConfigDigital(OHMM.DigitalPin pin,
                                  boolean pullup,
                                  boolean invert)
Covers senseConfigDigital(int, boolean, boolean)


senseConfigAnalog

public boolean senseConfigAnalog(int channel,
                                 int numSamples)
Runs monitor command "sca".

Parameters:
channel - the analog channel
numSamples - number of samples to average per reading
Returns:
true iff the config was valid

senseConfigAnalog

public boolean senseConfigAnalog(OHMM.AnalogChannel channel,
                                 int numSamples)
Covers senseConfigAnalog(int, int)


senseConfigAnalogLUT

public boolean senseConfigAnalogLUT(int channel,
                                    int numSamples,
                                    int[] lutA,
                                    float[] lutO)
Runs monitor command "scal".

Parameters:
channel - the analog channel
numSamples - number of samples to average per reading
lutA - SCAL_N LUT abssissas in the range 0 to 1023
lutO - SCAL_N LUT ordinates
Returns:
true iff the config was valid

senseConfigAnalogLUT

public boolean senseConfigAnalogLUT(OHMM.AnalogChannel channel,
                                    int numSamples,
                                    int[] lutA,
                                    float[] lutO)
Covers senseConfigAnalogLUT(int, int, int[], float[])


senseConfigAnalogIR

public boolean senseConfigAnalogIR(int channel,
                                   int numSamples)
Runs monitor command "scair".

Parameters:
channel - the analog channel
numSamples - number of samples to average per reading
Returns:
true iff the config was valid

senseConfigAnalogIR

public boolean senseConfigAnalogIR(OHMM.AnalogChannel channel,
                                   int numSamples)
Covers senseConfigAnalogIR(int, int)


senseReadDigital

public boolean senseReadDigital(int pin)
Runs monitor command "srd".

See note about configuring trhe digital input channel in the doc for senseReadDigital(DigitalPin), which is preferred over this method.

Parameters:
pin - the digital pin index, an OrangutanDigital IO_<port><pin> value as a raw integer. Note: it is usually better to use senseReadDigital(DigitalPin) which takes one of the OHMM.DigitalPin constants instead of a raw integer.
Returns:
the digital value

senseReadDigital

public boolean senseReadDigital(OHMM.DigitalPin pin)
Covers senseReadDigital(int).

Note: you must call senseConfigDigital(DigitalPin, boolean, boolean) for the corresponding pin before you call this, especially if the hardware setup you are using requires the pullup resistor for the input port to be enabled (a common arrangement especially when interfacing to switches). If you do not, you may read unreliable data.

Example:


 import static ohmm.OHMM.DigitalPin.*;
 ...
 ohmm.senseConfigDigital(IO_A0, true, false); //configure once 
 ...
 ohmm.senseReadDigital(IO_A0); //read as many times as needed
 

Parameters:
pin - one of the OHMM.DigitalPin constants

senseReadAnalog

public float senseReadAnalog(int channel)
Runs monitor command "sra".

See note about configuring the analog input channel in the doc for senseReadAnalog(AnalogChannel), which is preferred over this method.

Parameters:
channel - the analog channel as a raw integer. Note: it is usually better to use senseReadAnalog(AnalogChannel) which takes one of the OHMM.AnalogChannel constants instead of a raw integer.
Returns:
the analog value

senseReadAnalog

public float senseReadAnalog(OHMM.AnalogChannel channel)
Covers senseReadAnalog(int).

Note: you must call senseConfigAnalog(AnalogChannel, int), senseConfigAnalogLUT(int, int, int[], float[]), or senseConfigAnalogIR(AnalogChannel, int) for the corresponding channel before you call this. If you do not, you may read unreliable data.

Example:


 import static ohmm.OHMM.AnalogChannel.*;
 ...
 //configure once 
 ohmm.senseConfigAnalog(CH_0, 1); //no lookup table
 ohmm.senseConfigAnalogIR(CH_0, 1); //use lookup table for Sharp IR to mm
 ohmm.senseConfigAnalogLUT(CH_0, ...); //use arbitrary lookup table
 ...
 ohmm.senseReadAnalog(CH_0); //read as many times as needed
 

Parameters:
channel - one of the OHMM.AnalogChannel constants

senseState

public OHMM.SenseState senseState(OHMM.SenseState state)
Runs monitor command "snsst".

Parameters:
state - the state is returned here, or null to cons
Returns:
state

senseState

public OHMM.SenseState senseState()
covers senseState(SenseState), always conses


motReinit

public void motReinit()
Runs monitor command "mri".


motGetErrors

public byte motGetErrors()
Runs monitor command "mge".


motSetVelCmd

public boolean motSetVelCmd(float l,
                            float r)
Runs the monitor command "msv".

Parameters:
l - the left motor velocity in rev/sec
r - the right motor velocity in rev/sec
Returns:
true iff either velocity was clamped to limits

motGetVelCmd

public float[] motGetVelCmd(float[] lr)
Runs the monitor command "mgvc".

Parameters:
lr - the velocities are returned here, or null to cons
Returns:
lr

motGetVelCmd

public float[] motGetVelCmd()
covers motGetVelCmd(float[]), always conses


motGetVel

public float[] motGetVel(float[] lr)
Runs the monitor command "mgv".

Parameters:
lr - the velocities are returned here, or null to cons
Returns:
lr

motGetVel

public float[] motGetVel()
covers motGetVel(float[]), always conses


motFree

public void motFree()
Runs monitor command "mfr".


motKick

public void motKick(int l,
                    int r)
Runs monitor command "mk".

Parameters:
l - direction to pulse the left motor, or 0 for none
r - direction to pulse the right motor, or 0 for none

motGetPos

public float[] motGetPos(float[] lr)
Runs the monitor command "mgp".

Parameters:
lr - the positions are returned here, or null to cons
Returns:
lr

motGetPos

public float[] motGetPos()
covers motGetPos(float[]), always conses


motGetPosCounts

public int[] motGetPosCounts(int[] lr)
Runs the monitor command "mgc".

Parameters:
lr - the positions are returned here, or null to cons
Returns:
lr

motGetPosCounts

public int[] motGetPosCounts()
covers motGetPosCounts(int[]), always conses


motSetVelPGain

public void motSetVelPGain(float g)
Runs the monitor command "msvp".

Parameters:
g - the gain

motSetVelIGain

public void motSetVelIGain(float g)
Runs the monitor command "msvi".

Parameters:
g - the gain

motSetVelDGain

public void motSetVelDGain(float g)
Runs the monitor command "msvd".

Parameters:
g - the gain

motSetDiffVelIGain

public void motSetDiffVelIGain(float g)
Runs the monitor command "msdi".

Parameters:
g - the gain

motState

public OHMM.MotState motState(OHMM.MotState state)
Runs monitor command "motst".

Parameters:
state - the state is returned here, or null to cons
Returns:
state

motState

public OHMM.MotState motState()
covers motState(MotState), always conses


motGetGainCmd

public float[] motGetGainCmd(float[] gn)
Runs the monitor command "mggv".

Parameters:
gn - the gains are returned here, or null to cons
Returns:
gn

axErrToString

public static java.lang.String axErrToString(int err)
Convert an AX12 error code to a human readable string.

Parameters:
err - the error code
Returns:
the string

axReinit

public void axReinit()
Runs the monitor command "axri".


axPing

public int axPing(int id)
Runs the monitor command "axpng".

Parameters:
id - the AX12 id, less than AX_ID_BCAST

axWriteImpl

protected int axWriteImpl(java.lang.String cmd,
                          int id,
                          int reg,
                          int val,
                          int len)
common impl of the ax write methods


axWrite

public int axWrite(int id,
                   int reg,
                   int val)
Runs monitor command "axwr".

Parameters:
id - the AX12 id, less than 255
reg - the target register
val - the new value
Returns:
zero or error code

axWrite

public int axWrite(int id,
                   OHMM.AXReg reg,
                   int val)
Like axWrite(int, int, int) but takes an OHMM.AXReg.


axRegWrite

public int axRegWrite(int id,
                      int reg,
                      int val)
Runs the monitor command "axrwr".

Parameters:
id - the AX12 id, less than 255
Returns:
zero or error code

axRegWrite

public int axRegWrite(int id,
                      OHMM.AXReg reg,
                      int val)
Like axRegWrite(int, int, int) but takes an OHMM.AXReg.


axRead

public int axRead(int id,
                  int reg)
Runs the monitor command "axrd".

Parameters:
id - the AX12 id, less than 255
reg - the target register
Returns:
requested byte or error code if negative

axRead

public int axRead(int id,
                  OHMM.AXReg reg)
Like axRead(int, int) but takes an OHMM.AXReg.


axAction

public int axAction(int id)
Runs the monitor command "axact".

Parameters:
id - the AX12 id, less than 255
Returns:
zero or error code

axRead16

public int axRead16(int id,
                    int reg)
Runs the monitor command "axrd16".

Parameters:
id - the AX12 id, less than 255
reg - the target register
Returns:
requested word or error code if negative

axRead16

public int axRead16(int id,
                    OHMM.AXReg reg)
Like axRead16(int, int) but takes an OHMM.AXReg.


axWrite11

public int axWrite11(int id,
                     int reg,
                     int val)
Runs monitor command "axwr11".

Parameters:
id - the AX12 id, less than 255
reg - the target register
val - the new value
Returns:
zero or error code

axWrite11

public int axWrite11(int id,
                     OHMM.AXReg reg,
                     int val)
Like axWrite11(int, int, int) but takes an OHMM.AXReg.


axRegWrite11

public int axRegWrite11(int id,
                        int reg,
                        int val)
Runs monitor command "axrwr11".

Parameters:
id - the AX12 id, less than 255
reg - the target register
val - the new value
Returns:
zero or error code The new value will take effect on the next axAction(int).

axRegWrite11

public int axRegWrite11(int id,
                        OHMM.AXReg reg,
                        int val)
Like axRegWrite11(int, int, int) but takes an OHMM.AXReg.


axSetAngleLimits

public int axSetAngleLimits(int id,
                            int cwLimit,
                            int ccwLimit)
Runs monitor command "axsal".

Parameters:
id - the AX12 id, less than 255
cwLimit - clockwise limit
ccwLimit - counterclockwise limit
Returns:
error code

axTorqueEnable

public int axTorqueEnable(int id,
                          boolean enable)
Runs monitor command "axte".

Parameters:
id - the AX12 id, less than 255
Returns:
error code

axESTOP

public void axESTOP()
Runs monitor command "axestop".


axSetGoalImpl

protected int axSetGoalImpl(java.lang.String cmd,
                            int id,
                            int goal)
comon impl of set goal (int) methods


axSetGoalImpl

protected int axSetGoalImpl(java.lang.String cmd,
                            int id,
                            float goal)
comon impl of set goal (float) methods


axSetGoal

public int axSetGoal(int id,
                     int goal)
Runs monitor command "axsg".

Parameters:
id - the AX12 id, less than 255
goal - goal position to set
Returns:
current position or error code if negative Enables torque.

axRegSetGoal

public int axRegSetGoal(int id,
                        int goal)
Like axSetGoal(int, int) but does a reg write. The new value will take effect on the next axAction(int).


axSetGoalDeg

public int axSetGoalDeg(int id,
                        float goal)
like axSetGoal(int, int) but in degrees


axRegSetGoalDeg

public int axRegSetGoalDeg(int id,
                           float goal)
like axRegSetGoal(int, int) but in degrees


axSetGoalRad

public int axSetGoalRad(int id,
                        float goal)
like axSetGoal(int, int) but in radians


axRegSetGoalRad

public int axRegSetGoalRad(int id,
                           float goal)
like axRegSetGoal(int, int) but in radians


axGetPos

public int axGetPos(int id)
Runs monitor command "axgp".

Parameters:
id - the AX12 id, less than AX_ID_BCAST
Returns:
current position or error code if negative

axGetPosDeg

public float axGetPosDeg(int id)
Runs monitor command "axgpd".

Parameters:
id - the AX12 id, less than AX_ID_BCAST
Returns:
current position in degrees or error code if negative

axGetPosRad

public float axGetPosRad(int id)
Runs monitor command "axgpr".

Parameters:
id - the AX12 id, less than AX_ID_BCAST
Returns:
current position in radians or error code if negative

axGetLoad

public int axGetLoad(int id)
Runs monitor command "axgl".

Parameters:
id - the AX12 id, less than AX_ID_BCAST
Returns:
load or error code if less than or equal to -1024

axGetVolts

public float axGetVolts(int id)
Runs monitor command "axgv".

Parameters:
id - the AX12 id, less than AX_ID_BCAST
Returns:
voltage or error code if negative

axGetTemp

public int axGetTemp(int id)
Runs monitor command "axgt".

Parameters:
id - the AX12 id, less than AX_ID_BCAST
Returns:
temp in deg C or error code if negative

axGetNumRetries

public int axGetNumRetries()
Runs monitor command "axgnr".

Returns:
number of AX12 transaction retries since last axReinit()

axGetNumTimeouts

public int axGetNumTimeouts()
Runs monitor command "axgnt".

Returns:
number of AX12 transaction timeouts since last axReinit()

axGetNumOverflows

public int axGetNumOverflows()
Runs monitor command "axgno".

Returns:
number of AX12 bus receiver overflows since last axReinit()

axState

public OHMM.AXState axState(OHMM.AXState state)
Runs monitor command "axst".

Parameters:
state - the state is returned here, or null to cons
Returns:
state

axState

public OHMM.AXState axState()
covers axState(AXState), always conses


armReinit

public void armReinit()
Runs monitor command "ari".


armEnable

public void armEnable(boolean enable)
Runs monitor command "ae".


armHome

public void armHome()
Runs monitor command "ah".


armCal

public void armCal()
Runs monitor command "ac".


armSetJoint

public boolean armSetJoint(int joint,
                           int counts)
Runs monitor command "asj".

Parameters:
joint - the joint index, ARM_SHOULDER, ARM_ELBOW, ARM_WRIST
counts - the joint angle in AX12 counts
Returns:
true unless the value was clamped to limits

armSetJointDeg

public boolean armSetJointDeg(int joint,
                              float angle)
Runs monitor command "asjd". Like armSetJoint(int, int) but in degrees.


armSetJointRad

public boolean armSetJointRad(int joint,
                              float angle)
Runs monitor command "asjr". Like armSetJoint(int, int) but in radians.


armSetAllJoints

public boolean armSetAllJoints(int... counts)
Runs monitor command "asaj". Like armSetJoint(int, int) but sets all three joints.


armSetAllJointsDeg

public boolean armSetAllJointsDeg(float... angle)
Runs monitor command "asajd". Like armSetAllJoints(int...) but in degrees.


armSetAllJointsRad

public boolean armSetAllJointsRad(float... angle)
Runs monitor command "asajd". Like armSetAllJoints(int...) but in radians.


armGetJoint

public int armGetJoint(int joint)
Runs monitor command "agj".

Parameters:
joint - the joint index, ARM_SHOULDER, ARM_ELBOW, ARM_WRIST
Returns:
the joint angle in AX12 counts

armGetJointDeg

public float armGetJointDeg(int joint)
Runs monitor command "agjd". Like armGetJoint(int) but in degrees.


armGetJointRad

public float armGetJointRad(int joint)
Runs monitor command "agjr". Like armGetJoint(int) but in radians.


armGetAllJoints

public int[] armGetAllJoints(int[] counts)
Runs monitor command "agaj".

Parameters:
counts - the 3 angles are stored here, if not null, else cons Like armGetJoint(int) but gets all joints.

armGetAllJoints

public int[] armGetAllJoints()
Covers armGetAllJoints(int[]), always conses.


armGetAllJointsDeg

public float[] armGetAllJointsDeg(float[] angle)
Runs monitor command "agajd". Like armGetAllJoints(int[]) but in degrees.


armGetAllJointsDeg

public float[] armGetAllJointsDeg()
Covers armGetAllJointsDeg(float[]), always conses.


armGetAllJointsRad

public float[] armGetAllJointsRad(float[] angle)
Runs monitor command "agajr". Like armGetAllJoints(int[]) but in radians.


armGetAllJointsRad

public float[] armGetAllJointsRad()
Covers armGetAllJointsRad(float[]), always conses.


armSetGripper

public boolean armSetGripper(float state)
Runs monitor command "asg".

Parameters:
state - the griper state, 0.0 for closed, 1.0 for open
Returns:
true unless the value was clamped to limits

armGetGripper

public float armGetGripper()
Runs monitor command "agg".

Returns:
the griper state, 0.0 for closed, 1.0 for open

armSetCal

public boolean armSetCal(int joint,
                         int offset)
Runs monitor command "asc".

Parameters:
joint - ARM_SHOULDER, ARM_ELBOW, ARM_WRIST, or ARM_GRIPPER
offset - the calibration offset in AX12 counts or ARM_FREEZE_CAL to use the current AX12 goal position
Returns:
true unless the value was clamped to limits

armGetCal

public int armGetCal(int joint,
                     boolean freeze)
Runs monitor command "agc".

Parameters:
joint - ARM_SHOULDER, ARM_ELBOW, ARM_WRIST, or ARM_GRIPPER
freeze - whether to read the current AX12 goal position instead of the stored calibration offset
Returns:
the calibration offset in AX12 counts

armSetAllCal

public boolean armSetAllCal(int... offset)
Runs monitor command "asac". Like armSetCal(int, int) but sets all 4 calibration values.


armFreezeAllCal

public boolean armFreezeAllCal()
Runs monitor command "afac".


armGetAllCal

public int[] armGetAllCal(int[] offset,
                          boolean freeze)
Runs monitor command "agac".

Parameters:
offset - the 4 offsets are stored here, if not null, else cons
freeze - whether to read the current AX12 goal position instead of the stored calibration offset
Returns:
offset

armGetAllCal

public int[] armGetAllCal(boolean freeze)
Covers armGetAllCal(int[], boolean), always conses.


armGetTemps

public int[] armGetTemps(int[] temp)
Runs monitor command "agt".

Parameters:
temp - the 4 temps are stored here, if not null, else cons
Returns:
temp

armGetTemps

public int[] armGetTemps()
Covers armGetTemps(int[]), always conses.


armGetLoads

public int[] armGetLoads(int[] load)
Runs monitor command "agl".

Parameters:
load - the 4 loads are stored here, if not null, else cons
Returns:
load

armGetLoads

public int[] armGetLoads()
Covers armGetLoads(int[]), always conses.


armActive

public boolean armActive()
Runs monitor command "aa".


armAtGoal

public boolean armAtGoal()
Runs monitor command "aag".


armGetNumAXErrors

public int armGetNumAXErrors()
Runs monitor command "agne".

Returns:
number of AX comm errors since last armReinit().

armState

public OHMM.ArmState armState(OHMM.ArmState state)
Runs monitor command "armst".

Parameters:
state - the state is returned here, or null to cons
Returns:
state

armState

public OHMM.ArmState armState()
covers armState(ArmState), always conses


getCmdCode

public java.lang.Integer getCmdCode(java.lang.String name)

Get a binary command code corresponding to a monitor command name.

Memoized to minimize communication.

Parameters:
name - the command name, at most CMD_NAME_MAX chars
Returns:
the command code

echo

public byte echo(byte out)

Ask the firmware to echo a byte.

Any registered ErrorHandler will be notified on timeout or I/O error.

Parameters:
out - the byte to echo
Returns:
the return byte, or 0 on timeout or error

echo

public int echo(int nb,
                int out)

Ask the firmware to echo an int.

Any registered ErrorHandler will be notified on timeout or I/O error.

Parameters:
nb - number of bytes, see send(int, int, boolean)
out - the int to echo
Returns:
the return byte, or 0 on timeout or error

echo

public float echo(float out)

Ask the firmware to echo a float.

Any registered ErrorHandler will be notified on timeout or I/O error.

Parameters:
out - the float to echo
Returns:
the return float, or 0 on timeout or error

echoFix

public float echoFix(float out)

Ask the firmware to echo a fix.

Any registered ErrorHandler will be notified on timeout or I/O error.

Parameters:
out - the fix to echo, see sendFix(float, int, boolean)
Returns:
the return fix, or 0 on timeout or error

sendCmdCode

public void sendCmdCode(java.lang.String cmdName,
                        boolean flush)
Convenience to getCmdCode(java.lang.String) and send(int, int, boolean).


sendCmdCode

public void sendCmdCode(java.lang.String cmdName)
covers sendCmdCode(String, boolean), always flushes


send

public void send(java.lang.String s,
                 int n,
                 boolean flush)

Send fixed length ASCII string to the firmware.

Any registered ErrorHandler will be notified on I/O error.

Exactly n bytes will always be sent. If s is too short, nulls will be sent to fill in the remaining space.

Parameters:
s - the string to send
n - the total number of characters to send
flush - whether to flush this write as well as any that were previously pending, at the last byte

send

public void send(java.lang.String s,
                 int len)
covers send(String, int, boolean), always flushes


send

public void send(java.lang.String s,
                 boolean flush)

Send a null terminated ASCII string to the firmware.

Any registered ErrorHandler will be notified on I/O error.

Parameters:
s - the string to send
flush - whether to flush this write as well as any that were previously pending, at the last byte

send

public void send(java.lang.String s)
covers send(String, boolean), always flushes


send

public void send(byte[] bytes,
                 boolean flush)

Send an array of bytes to the firmware.

Any registered ErrorHandler will be notified on I/O error.

Parameters:
bytes - the bytes to send
flush - whether to flush this write as well as any that were previously pending, at the last byte

send

public void send(byte[] bytes)
covers send(byte[], boolean), always flushes


send

public void send(char c,
                 boolean flush)

Send an ASCII char to the firmware.

Any registered ErrorHandler will be notified on I/O error.

Parameters:
c - the char to send
flush - whether to flush this write as well as any that were previously pending

send

public void send(char c)
covers send(char, boolean), always flushes


send

public void send(boolean b,
                 boolean flush)

Send a boolean to the firmware as a byte (0 or 1).

Any registered ErrorHandler will be notified on I/O error.

Parameters:
b - the boolean to send
flush - whether to flush this write as well as any that were previously pending

send

public void send(boolean b)
covers send(boolean, boolean), always flushes


sendFix

public void sendFix(float x,
                    int f,
                    boolean flush)

Send a 2 byte fixed point value to the firmware, MSB first.

Any registered ErrorHandler will be notified on I/O error.

Parameters:
x - the value to send
f - number of fraction bits
flush - whether to flush this write as well as any that were previously pending, at the last byte

sendFix

public void sendFix(float x,
                    int f)
covers sendFix(float, int, boolean), always flushes


send

public void send(float f,
                 boolean flush)

Send a float to the firmware, MSB first.

Any registered ErrorHandler will be notified on I/O error.

Parameters:
f - the float to send
flush - whether to flush this write as well as any that were previously pending, at the last byte

send

public void send(float f)
covers send(float, boolean), always flushes


send

public void send(int i,
                 int size,
                 boolean flush)

Send an int to the firmware, MSB first.

Any registered ErrorHandler will be notified on I/O error.

Parameters:
i - the int to send
size - the number of LS bytes of i to send, leq 4
flush - whether to flush this write as well as any that were previously pending, at the last byte

send

public void send(int i,
                 int size)
covers send(int, int, boolean), always flushes


send

public void send(byte b,
                 boolean flush)

Send a byte to the firmware.

Any registered ErrorHandler will be notified on I/O error.

Parameters:
b - the byte to send
flush - whether to flush this write as well as any that were previously pending

send

public void send(byte b)
covers send(byte, boolean), always flushes


sendFlush

public void sendFlush()
flush any pending writes


sendZeros

public void sendZeros(int n)

Send zeros.

Parameters:
n - number of zeros to send

recvString

public java.lang.String recvString(boolean wsTerminate)

Receive a null terminated string.

Any registered ErrorHandler will be notified on timeout or I/O error.

Parameters:
wsTerminate - whether to terminate on whitespace or null; if not only terminates on null
Returns:
the received string, null on timeout or error

recvString

public java.lang.String recvString()
Covers recvString(boolean), does not whitespace terminate


recvChar

public char recvChar()

Get an ASCII char.

Any registered ErrorHandler will be notified on timeout or I/O error.

Returns:
the received character, 0 on timeout or error

recvBoolean

public boolean recvBoolean()

Get a boolean as a byte, 0 false, 1 true.

Any registered ErrorHandler will be notified on timeout or I/O error.

Returns:
the received boolean, false on timeout or error

recvFix

public float recvFix(int f)

Get a 2 byte fixed point value, MSB first.

Any registered ErrorHandler will be notified on timeout or I/O error.

Parameters:
f - number of fraction bits
Returns:
the received float, or 0 on timeout

recvFloat

public float recvFloat()

Get a float, MSB first.

Any registered ErrorHandler will be notified on timeout or I/O error.

Returns:
the received float, or 0 on timeout

recvInt

public int recvInt(int size)

Get an integer, MSB first.

Any registered ErrorHandler will be notified on timeout or I/O error.

Parameters:
size - the number of bytes to expect in the int, absolute value at most 4, sign extend iff neg
Returns:
the received int, or 0 on timeout

recvByte

public byte recvByte(boolean timeoutOk)

Get a byte from the firmware.

Parameters:
timeoutOk - iff false then any registered ErrorHandler will be notified on timeout
Returns:
the received byte, or 0 on timeout or error

recvByte

public byte recvByte()

Covers recvByte(boolean), timeoutOk = false.


drainReceiveBuffer

public int drainReceiveBuffer()

Drain any bytes waiting in the receive buffer from the firware.

Returns:
the number of bytes that were drained, zero if none, negative if there was an error trying to drain the bytes (in which case any registered ErrorHandler will be notified as well).

noResponseDelay

public void noResponseDelay()

Delay by the current command delay.


close

public void close()

Close communications with the hardware.

It is ok to call this more than once.


getBytesSent

public int getBytesSent()

Get the total number of bytes sent thus far.

Returns:
the total number of bytes sent thus far

getBytesReceived

public int getBytesReceived()

Get the total number of bytes received thus far.

Returns:
the total number of bytes received thus far

getNumTimeouts

public int getNumTimeouts()

Get the total number of timeouts.

Returns:
the total number of timeouts

resetStats

public void resetStats()

Reset all comm stats.


dumpStats

public void dumpStats(java.io.PrintStream s)

Dump a human-readable summary of the comm stats.


dumpStats

public void dumpStats()
dumpStats(PrintStream) to System.out


listPorts

public static void listPorts(java.io.PrintStream s)

Convenience method to query the list of available ports according to RXTX.


listPorts

public static void listPorts()
listPorts(PrintStream) to System.out


getOHMMClass

public static java.lang.Class<? extends OHMM> getOHMMClass()

Determine what class makeOHMM(java.lang.String[], java.lang.String) instantiates.

See OHMM_SITE_CLASS.


makeOHMM

public static OHMM makeOHMM(java.lang.String[] argv,
                            java.lang.String extraUsage)
                     throws java.io.IOException

Constructs an OHMM from command line parameters.

See USAGE.

The returned object may actually be an instance of a subclass of OHMM, see getOHMMClass().

Parameters:
argv - the command line arguments to parse
extraUsage - optional extra usage info or null
Throws:
java.io.IOException

makeOHMM

public static OHMM makeOHMM(java.lang.String[] argv)
                     throws java.io.IOException

Covers makeOHMM(String[], String), no extra usage.

Throws:
java.io.IOException

printUsage

protected static void printUsage(java.lang.String extra)

Print USAGE.

Parameters:
extra - optional extra usage

sleep

public void sleep(double seconds)
           throws java.lang.InterruptedException
sleep at least the specfied time in seconds

Throws:
java.lang.InterruptedException

getCurrentTime

public double getCurrentTime()
get the current time in seconds


dbg

protected void dbg(java.lang.String prefix,
                   byte b)

Emit a debug message documenting a comms byte iff debug.


fmt2

public static java.lang.String fmt2(float f)
format f with 2 decimal places


fmt4

public static java.lang.String fmt4(float f)
format f with 4 decimal places