#include "isisclient.h"
#include "client.h"
#include "commands.h"
#include <readline/readline.h>
#include <readline/history.h>
Functions | |
int | cmd_quit (char *args, MsgType msgtype, char *reply) |
QUIT command - terminate the client session. | |
int | cmd_ping (char *args, MsgType msgtype, char *reply) |
PING command - communication handshaking request. | |
int | cmd_pong (char *args, MsgType msgtype, char *reply) |
PONG command - communication handshaking acknowledgment. | |
int | cmd_version (char *args, MsgType msgtype, char *reply) |
VERSION command - report application version and compilation info. | |
int | cmd_verbose (char *args, MsgType msgtype, char *reply) |
VERBOSE command - toggle verbose console output on/off. | |
int | cmd_debug (char *args, MsgType msgtype, char *reply) |
DEBUG command - toggle debugging (super-verbose) console output on/off. | |
int | cmd_info (char *args, MsgType msgtype, char *reply) |
INFO command - report client application runtime information. | |
int | cmd_help (char *args, MsgType msgtype, char *reply) |
HELP command - print a list of commands on the client console. | |
int | cmd_sclcmds (char *args, MsgType msgtype, char *reply) |
CMDS command - print a list of SCL microstep drive commands. | |
int | cmd_history (char *args, MsgType msgtype, char *reply) |
HISTORY command - show the application's interactive command history. | |
int | cmd_ports (char *args, MsgType msgtype, char *reply) |
PORTS command - report info about open mechanism comm comm ports. | |
int | cmd_mstatus (char *args, MsgType msgtype, char *reply) |
MSTATUS command - report detailed microstep drive status. | |
int | cmd_status (char *args, MsgType msgtype, char *reply) |
STATUS command - report microstep drive motion status. | |
int | cmd_rdpos (char *args, MsgType msgtype, char *reply) |
RDPOS command - read filter wheel position encoders. | |
int | cmd_setsp (char *args, MsgType msgtype, char *reply) |
SPEED command - set/query drive speed in rev/sec. | |
int | cmd_setcur (char *args, MsgType msgtype, char *reply) |
CURRENT command - set/query drive current in Amps. | |
int | cmd_seticur (char *args, MsgType msgtype, char *reply) |
IDLECUR command - set/query idle current in Amps. | |
int | cmd_setacc (char *args, MsgType msgtype, char *reply) |
ACCEL command - set/query move acceleration in rev/sec/sec. | |
int | cmd_setdec (char *args, MsgType msgtype, char *reply) |
DECEL command - set/query move deceleration in rev/sec/sec. | |
int | cmd_setdist (char *args, MsgType msgtype, char *reply) |
DIST command - set/query the motion profile move distance in steps. | |
int | cmd_setto (char *args, MsgType msgtype, char *reply) |
TIMEOUT command - set/query the communication timeout interval in seconds. | |
int | cmd_setpt (char *args, MsgType msgtype, char *reply) |
POLLTIME command - set/query the microstep drive polling interval in msec. | |
int | cmd_ndata (char *args, MsgType msgtype, char *reply) |
NDATA command - set/query the number of encoder data bits. | |
int | cmd_inpos (char *args, MsgType msgtype, char *reply) |
INPOS command - set/query the address of the in-position sensor input. | |
int | cmd_homeaddr (char *args, MsgType msgtype, char *reply) |
HOMEADDR command - set/query the address of the home sensor input. | |
int | cmd_ismask (char *args, MsgType msgtype, char *reply) |
ISMASK command - set/query the input status bitmask. | |
int | cmd_limits (char *args, MsgType msgtype, char *reply) |
LIMITS command - set/query the limit switch settings. | |
int | cmd_moveit (char *args, MsgType msgtype, char *reply) |
MOVE command - execute a generic move with verbose feedback. | |
int | cmd_moveto (char *args, MsgType msgtype, char *reply) |
MOVETO command - move to indexed position N. | |
int | cmd_findpos (char *args, MsgType msgtype, char *reply) |
FINDPOS command - seek the nearest valid indexed position. | |
int | cmd_moveabs (char *args, MsgType msgtype, char *reply) |
MOVEABS command - move mechanism to an absolute step-count position. | |
int | cmd_moverel (char *args, MsgType msgtype, char *reply) |
MOVEREL command - move mechanism relative to the current position. | |
int | cmd_idle (char *args, MsgType msgtype, char *reply) |
IDLE command - enable/disable the microstep drive idle current. | |
int | cmd_settopo (char *args, MsgType msgtype, char *reply) |
TOPOLOGY command - set/query the mechanism topology. | |
int | cmd_reset (char *args, MsgType msgtype, char *reply) |
RESET command - reload the runtime config paramters and re-initialize the microstep drive. | |
int | cmd_init (char *args, MsgType msgtype, char *reply) |
INIT command - (re)initialize the microstep drive. | |
int | cmd_abort (char *args, MsgType msgtype, char *reply) |
ABORT command - abort a move in progress. | |
void | KeyboardCommand (char *line) |
Process a command from the client's console keyboard. | |
void | SocketCommand (char *buf) |
Process a message/command from a remote ISIS server/client application. |
This module contains the command "action" functions called to service sitool commands. These consist of a suite of
These 3 commands are REQUIRED of all ISIS client apps:
cmd_quit()
terminate a client session (QUIT) cmd_ping()
communications handshaking request (PING) from a remote ISIS node cmd_pong()
communications handshaking acknowledgment (PONG) from a remote ISIS nodecmd_version()
Report application version information (VERSION) cmd_info()
Report client runtime configuration (INFO, sometimes CONFIG in legacy apps).cmd_verbose()
Toggle verbose output to the client console on/off (VERBOSE) cmd_debug()
Toggle debugging (super-verbose) output to console on/off (DEBUG) cmd_help()
List interactive client commands (HELP or ?) cmd_history()
Print the recent interactive command history (HISTORY)At the end of this file are the template I/O handlers used by the command interpreter:
|
QUIT command - terminate the client session.
|
|
PING command - communication handshaking request.
PINGs are actually handled separately in the SocketCommand() handler (nothing is done by the KeyboardCommand() handler) because the PONG sent back acknowledging the comm handshaking request is, in effect, a pseudo-command (implicit REQ:), not a "DONE:" response to a command request. This exception to the general messaging syntax has to be handled carefully to prevent problems, especially to ensure backwards compatibility with older IMPv applications.
|
|
PONG command - communication handshaking acknowledgment.
cmd_pong doesn't do anything except return a CMD_NOOP (since this "command" must NOT result in a reply back to the sender). In more sophisticated apps, we might actually use receipt of a pong to do something useful (e.g., help build up a node table), so at the very least this module works as a placeholder for future expansion.
|
|
VERSION command - report application version and compilation info.
Example output: Version=v1.0 CompileDate=2004-Jun-11 CompileTime=17:08:15 |
|
VERBOSE command - toggle verbose console output on/off.
In general "Verbose" output refers only to client application level output (i.e., echoing socket message traffic, printing status update info, etc.). An more chatty DEBUG mode is provided that prints more engineering-level info for detailed low-level system debugging.
|
|
DEBUG command - toggle debugging (super-verbose) console output on/off.
DEBUG mode is a super-verbose mode that spews lots of I/O chatter onto the application console, useful during client debugging or for troubleshooting. For example, in client applications that control stepper motors, the full motor control chatter is echoed to the console during DEBUG mode to enable the user to follow the steps the system is (or is not) taking, watch encoder and limit switches assert (or not), etc. DEBUG is normally disabled during normal user operations.
|
|
INFO command - report client application runtime information.
The format of cmd_info should be tailored specifically for the particular client application. If a client controls specific instrument or interface functions, the state of those functions should be reported in the info string, making it an omnibus "what is your status" command. Example Output: ID=SCL2 Host=darkstar:10702 Mode=STANDALONE SCLPort=172.16.1.56:8002 Verbose -DEBUG rcfile=port2.ini |
|
HELP command - print a list of commands on the client console.
If an argument is given, it tries to find that string in the command list, and if successful, prints a brief description and usage message. Help is meant to be simple. It can give help on particular commands (really a reminder of the command's function and syntax), or a list of all commands. |
|
CMDS command - print a list of SCL microstep drive commands.
For a list of client commands, see HELP (cmd_help()).
|
|
HISTORY command - show the application's interactive command history.
|
|
PORTS command - report info about open mechanism comm comm ports.
FWPort=/dev/ttyS0 Open |
|
MSTATUS command - report detailed microstep drive status.
This is low-level stuff, meaningful only to people who know the SCL command set, or have the manual at hand. If you have to look at mstatus, you have to be ready to get down to the nitty-gritty. Use the STATUS command if you only want to view the motion and input parameters. MSTATUS shows everything... Example:
|
|
STATUS command - report microstep drive motion status.
The report is formatted as IMPv2-compliant message with the parameters given as keyword=value pairs. For example: For the current microstep drive internal parameters, use the MSTATUS command (cmd_mstatus()).
|
|
RDPOS command - read filter wheel position encoders.
Typical output: RawIn=01111111 Inputs=10000000 ISMask=00000000 IPos=63737This shows the raw input bits, the masked input bits, the input status mask used (see cmd_ismask()), and the step count position. |
|
SPEED command - set/query drive speed in rev/sec.
Speeds must be in the range #SI_MINVEL to #SI_MAXVEL (defined in siutils.h) |
|
CURRENT command - set/query drive current in Amps.
The default idle current (CI parameter) is 50% of the drive current. If we are using a non-default idle current, we need to restore that value after setting CC (since CI is recomputed by the CC set command). A default idle current is denoted by scl.IdleCurrent<0.0 amps. NOTE: the maximum current is not specified a priori, so we need to find some way to set this in the header. At present, until we work this out, this could allow dangerously high currents to be set.
|
|
IDLECUR command - set/query idle current in Amps.
If the idle current is set to -1, the default idle current, which is 50% of the drive current, is used. NOTE: the maximum current is not specified a priori, so we need to find some way to set this in the header. At present, until we work this out, this could allow dangerously high currents to be set.
|
|
ACCEL command - set/query move acceleration in rev/sec/sec.
Accelerations are in integer steps from #SI_MINVDOT to #SI_MAXVDOT (defined in siutils.h). |
|
DECEL command - set/query move deceleration in rev/sec/sec.
Decelerations are in integer steps from #SI_MINVDOT to #SI_MAXVDOT (defined in siutils.h), in units of rev/s/s. |
|
DIST command - set/query the motion profile move distance in steps.
Move distances are in integer units of steps, + or -, with value in the range #SI_MAXMOVE (see scutils.h) |
|
TIMEOUT command - set/query the communication timeout interval in seconds.
This is an internal variable, no microstep controller setting is required. |
|
POLLTIME command - set/query the microstep drive polling interval in msec.
In practice, roundtrip communications via 9600 baud serial to this family of microstep drives is around 40-50msec for a typical parameter query or parameter setting operation. The polling time should not be so fast as to harrass the controller, possibly intefering with its ability to execute a move. A typical polling time we use is 100-200msec, providing 5 status messages/second which seems more than sufficient when debugging drive performance. |
|
NDATA command - set/query the number of encoder data bits.
If NDATA was given without arguments, it returns the current number of data bits. The command "NDATA 0" disabled sensing position with the inputs. The input status mask (ISMask) needs to be set correctly to interpret the input sensors. See cmd_ismask() for the gory details.
|
|
INPOS command - set/query the address of the in-position sensor input.
If INPOS was given without arguments, it returns the current address of the in-position bit. The input status mask (ISMask) needs to be set correctly to interpret the input sensors. See cmd_ismask() for the gory details.
|
|
HOMEADDR command - set/query the address of the home sensor input.
If HOMEADDR was given without arguments, it returns the current address of the home sensor input. The input status mask (ISMask) needs to be set correctly to interpret the input sensors. See cmd_ismask() for the gory details.
|
|
ISMASK command - set/query the input status bitmask.
The input status mask (ISMask) needs to be set correctly to interpret the input sensors, since in practice inputs may be either normally open or normally closed depending on the application. The input status mask is a string of eight (8) 1s and 0s, defined as follows. For the i-th mask bit, 0 means the input is asserted (true) when INi=0 (closed) 1 means the input is asserted (true) when INi=1 (open)Beware: the order of bits in ismask is identical to the order of bits in the raw controller IS string (i.e., IN8..IN1).
ismask 00001111; IN1..IN4 is 1 if there is a hole under the proximity sensor (binary 1 = "asserted"), and 0 if there is metal under the sensor (binary 0 = "deasserted"). We mask IN5..IN8 as 0 so that they always be deasserted 0 since they are unused. The result of using this mask on the above IS string is as follows: raw status = 11111001 ismask = 00001111 result = 00001001The masked status bits make it easy to see that only IN1 (position 1s bit) and IN4 (the in-position bit) are asserted.
|
|
LIMITS command - set/query the limit switch settings.
|
|
MOVE command - execute a generic move with verbose feedback.
The argument must be a valid raw move command (FL, FP, etc.) which it is to execute then monitor to completion. If MOVE is given with no arguments a usage error message is printed. |
|
MOVETO command - move to indexed position N.
In a rotary indexed mechanism, it moves to the requested position via the least path clockwise or counterclockwise. If MOVETO is issued without arguments, it reports the current indexed position. |
|
FINDPOS command - seek the nearest valid indexed position.
|
|
MOVEABS command - move mechanism to an absolute step-count position.
|
|
MOVEREL command - move mechanism relative to the current position.
|
|
IDLE command - enable/disable the microstep drive idle current.
Sets the scl.Idle flag (1=enabled, 0=disabled), and uploads either the "MD" ("Motor Disable") or "ME" ("Motor Enable") commands to the Si controller. Note that a move can in fact be launched even if the drive is "disabled", as all that is disabled is the idle current (i.e., ME sets the idle current to 50% of the drive current and turns the drive on, while MD sets the idle current to 0 and turns the drive off. The next FL or other "move" command will start the drive at full current). If IDLE is given with no arguments, it reports the current idle setting (as it is known) |
|
TOPOLOGY command - set/query the mechanism topology.
The drive topology tells the system how to move between fixed ("indexed") positions. In a linear drive, it simply moves directly to the position requested, but in a rotary drive, which can approach a position from clockwise or counter-clockwise around the circle, it selects the shortest path to that position. |
|
RESET command - reload the runtime config paramters and re-initialize the microstep drive.
This provides the client application with a warm restart facility. |
|
INIT command - (re)initialize the microstep drive.
|
|
ABORT command - abort a move in progress.
It then queries the drive status after sending the abort to try to determine the drive status. |
|
Process a command from the client's console keyboard.
This function parses the interactive command line and calls the appropriate low-level cmd_xxx() command action functions for excuting most commands, as well as servicing ">XX msgtype: command" format raw IMPv2 message sending requests. A feature of this variant for SiTool is that once it gets past the main command tree, instead of griping about an unknown command, it assumes that it might be a raw SCL command, and ships it to the controller via SCLSendCommand(). Syntax errors or unknown commands result in gripes from the controller, but no badness we've yet encountered. All keyboard commands are treated as EXEC: type IMPv2 messages. This makes the downstream cmd_xxx() action functions insensitive to whether or not the command came from the keyboard or from a remote ISIS server or client application.
|
|
Process a message/command from a remote ISIS server/client application.
More sophisticated handlers might pass such messages on to parsers/handlers of their own if the inputs were actually used for something other than "visual" information for the user of this application. All messages received from an ISIS node are assumed to be in the proper IMPv2 messaging syntax. Note that EXEC: is new to IMPv2. It allows remote nodes to transmit protected "executive" commands to clients, giving them access to commands that would otherwise only be available on the console keyboard (e.g., the "quit" command). Thus a remote EXEC: command means "act as if this was typed at the keyboard". It is the responsibility of the remote application to make sure that EXEC: is used with care, as you could do something stupid (though your client application should not allow actions that would be physically unsafe to personnel or equipment).
|