<< Click to Display Table of Contents >>

Navigation:  Program use > Scripts >

Script Language

The basic syntax of the script language of Advanced Serial Port Monitor (ASPM) is:

 

<command> <data1> <data2>          ;<comment>

 

where <command> describes the action to perform, <data1> and <data2> are optional arguments, and <comment> is an optional comment. The format of the arguments vary among commands. The various components of each line must be separated by at least one space or a comma. Additional spaces are permitted but ignored. Commands are not case-sensitive.

 

The following is a list of supported commands followed by brief descriptions and discussions of the relationships between various commands:

 

:<label>

 

;<comment>

 

INITPORT <COM1..COM99>

 

 

IF CONNECTED <label>

 

DONEPORT

 

SEND 'XXXXXX'

 

WAIT 'XXXX' <timeout in ms>

 

IF SUCCESS <label>

 

IF TIMEOUT <label>

 

IF FAIL <label>

 

WAITMULT 'XXX|YYY|ZZZ' <timeout in ms>

 

IF 1,2,3...127

 

GOTO <label>

 

DISPLAY 'XX XX'

 

SENDBREAK <duration in ms>

 

DELAY <duration in ms>

 

SET <option> <data>

 

 

 

RUN <command> <wait>

 

 

 

:<label>

 

A point in the script file that can be jumped to via a GOTO or IF instruction. A label name can be any type of string without embedded spaces. For example ':TopOfLoop', ':TOP_OF_LOOP' are both acceptable; ':top of loop' is not.

 

;<comment>

 

Any line that starts with a semicolon is considered a comment. Blank lines are also considered comments and may be freely added for readability.

 

INITPORT <COM1..COM99>

 

Opens the specified port. Only one port at a time may be opened.

 

DONEPORT

 

Closes a port previously opened with INITPORT.

 

SEND 'XXXXXX'

 

Transmits the string 'XXXXXX'. Control characters may transmitted by preceding a character with '^'. For example, a control C character is represented by ^C. You'll use this feature most often when sending carriage returns. For example, SEND 'myname^M' might be an appropriate response to a logon prompt where you would normally type your name and press <Enter>. NOTE: The control characters must be inside the quote marks, if quote marks are necessary. If the string does not contain any embedded blanks the beginning and ending quotes can be omitted. The quotes are required if the string has embedded blanks. Here are some examples to illustrate this point:

 

SEND ABC      sends ABC

SEND 'ABC'    sends ABC

SEND A B C    sends only the A ('B C' is considered a comment)

SEND 'A B C'  sends A B C

 

WAIT 'XXXXX' <timeout in ms>

 

Waits up to <timeout in ms> milliseconds for a particular received string. The string comparison is always case insensitive. However, the string comparison need not be complete. If, for example, a host returns the string 'Host XXXX ready' where XXXX might vary from session to session, the WAIT command should wait for 'ready' only. As with the SEND command, beginning and ending quotes are only required if the string contains embedded blanks. This command sets one of three conditions: SUCCESS, FAIL or TIMEOUT, which can be tested with the IF command. SUCCESS is set if the string is received before the timeout. TIMEOUT is set if the timeout expires before the string is received. FAIL is set if the timeout expires and all retries are exhausted.

 

IF SUCCESS/TIMEOUT/FAIL/RING/RTS/CTS/DTR/DSR <label>

 

Tests the condition set by the last command and, if the tested condition is true, script execution jumps to <label>. If the condition is not true then execution continues with the next statement.

 

RING/RTS/CTS/DTR/DSR condition tests corresponding pin state.

 

WAITMULTI 'XXX|ZZZ|YYY', <timeout in ms>

 

Waits up to <timeout in ms> milliseconds for one of several substrings. The bar character (|) separates the substrings. The comparisons are always case insensitive. The maximum length of the entire string is 255 characters. As with the SEND command, beginning and ending quotes are only required if the string contains embedded blanks.

This command sets a numeric condition result based on the substring received: '1' is set if the first substring is received, '2' is set if the second substring is received, and so on. If none of the strings are received then TIMEOUT is set; if all retries have been exhausted then FAIL is set.

 

Note: YYY is being tested first then ZZZ and XXX. ZZZ is being tested first then XXX. If YYY is a part of ZZZ or XXX, but a serial port received ZZZ or XXX, then YYY condition will be executed.

 

IF 1,2,3...127 <label>

 

Tests the condition set by the last WAITMULTI command and, if the tested condition is true, script execution jumps to <label>. If the condition is not true then execution continues with the next statement.

The following example sends a modem dial command, then waits for one of CONNECT, NO CARRIER, or BUSY responses. If none of the responses are received then control falls through to the GOTO statement:

 

send 'atdt260-9726^m'

waitmulti 'connect|no carrier|busy' 60000

if 1 HandleConnect

if 2 HandleNoConnect

if 3 HandleBusy

goto HandleTimeout

:HandleConnect

 ...proceed with session

:HandleNoConnect

 ...handle noconnect error

:HandleBusy

 ...handle busy error

...

 

GOTO <label>

 

Unconditionally jumps to <label>.

 

DISPLAY 'Just did something'

 

This can be used to monitor the progress of the script and to aid in debugging.

 

EXIT

 

Exit the program.

 

SENDBREAK <duration in ms>

 

Transmits a break of <duration in ms> milliseconds.

 

DELAY <duration in ms>

 

Delays for <duration in ms> milliseconds. The script doesn't yield during delays so keep the delays as short as possible.

 

PLUGIN START <file name>

 

Execute plugin module with <file name> file name. This plugin must exists in the Plugins folder of ASPM.

 

PLUGIN STOP <file name>

 

Stop <file name> plugin's execution. This plugin must exists in the Plugins folder of ASPM.

 

PLUGIN SHOW <file name>

 

Sets the plugin's main window to normal state.

 

PLUGIN HIDE <file name>

 

Sets the plugin's main window to minimized state.

 

MODE <mode>

 

Value:

manual - manual mode;
spy - spy mode.

 

SOURCE <data source>

 

Value:

•        string - use the input string as a data source;

•        file - use file as a data source.

 

CLEAR - clear data in the screen.

 

SET BAUD <number>

 

Sets the Baud property of ASPM.

 

SET DATABITS <5,6,7,8>

 

Sets the DataBits property of the ASPM. Allowable values are 5, 6, 7 or 8.

 

SET FLOW <RTS/CTS,XON/XOFF,NONE>

 

Sets flow control options for the ASPM. Allowable values are RTS/CTS for hardware flow control, XON/XOFF for software flow control, and NONE to turn off all flow control.

 

SET PARITY <NONE,ODD,EVEN,MARK,SPACE>

 

Sets the Parity property of the ASPM. Allowable values are NONE, ODD, EVEN, MARK or SPACE.

 

SET STOPBITS <1,2>

 

Sets the StopBits property of the ASPM. Allowable values are 1 and 2.

 

SET RETRY <data>

 

Sets an internal retry count that is incremented whenever WAIT or WAITMULTI result in a TIMEOUT condition. When <retry count> TIMEOUTs have occurred the FAIL condition is set. The default is 1, meaning no retries are attempted.

 

SET LEFT <data>

Sets the position of main window on screen.

 

SET TOP <data>

Sets the position of main window on screen.

 

SET WIDTH <data>

Sets the main window width in pixels.

 

SET HEIGHT <data>

Sets the main window height in pixels.

 

SET WINDOWSTATE <data>

Sets the main window state. 0 - maximized, 1 - minimized, 2 - normal state.

 

 

RUN <command> <wait>

 

Executes the specified command, batch file or program. <wait> can be true or false; and determines whether the script waits for the command to complete its execution. <wait> is true by default.

 

Note: the command should contain full path to batch file or program. If the path contains spaces then the command should be enclosed by "".

 

Command example: RUN "c:\Program Files\Advanced Serial Port Monitor\command.bat" false

 

 

Here's an example logon script showing how these commands might be used to log into a host or terminal server:

 

SET RETRY 10                   ;Try 10 times

:Again

SEND ^C                        ;Send an attention character

WAIT 'READY' 182               ;Wait 10 seconds for response

IF SUCCESS Logon               ;Got prompt, continue with logon

IF TIMEOUT Again               ;Try again if we timed out

IF FAIL, Done                  ;Give up after 10 tries

:Logon

SEND 'Name, password^M'        ;Send name and password

 

...

 

:Done

SEND 'Bye^M'