Solutions by Industry

Using a Macro File to Configure a Data Radio Modem

The terminal emulation program Tara Term is an easy-to-use terminal emulator, similar in function to HyperTerminal or Procomm.  But, Raveon finds it is easier to use, more reliable, and has better features.  One of its new features is the ability to process a “Macro File”.  It is a very handy program to communicate with a Raveon data radio modem, and is a good way to automate the configuing your radio modem. 

Tera Term is an open-source terminal emulation program that is easy to use, and very powerful.  Raveon recommends using it over Hyperterminal.  Version 4.7 is currently available for download at logmett.com here: http://logmett.com/index.php?/download/download-tera-term-470-freeware.html   Tera Term has a Macro FIle script processor that allows a person to create a script file of macro commands. The Script file can configure the radio modem, prompt the user for input, and validate the programming of the radio modem.

Tera Term Macro files have an extension .TTL.   When in install Tera Term, the .TTL extension will be associated with Tera Term, so anytime you click on a .TTL file, the Tera Term maco processor should run it.  If it does not, you can manually associate the “TLL” file as described below. 

The macro File with the .TTL extension must be created before you can run it.  Raveon may provide this for you, or you may create this yourself.  Information about Tera Term’s Macro abilities is here:http://ttssh2.sourceforge.jp/manual/en/macro/  although you may have to search the Internet for more details.  A good way to understand it, is to study a macro file provided by Raveon.

When you run a macro file, there will be at least two windows pop-up, and maybe three windows.  The largest window is the Tera Term program itself.  As the macro runs, there will be a small window titled MACRO – xxxxx where xxxxx is the name of the macro file that is running.  You can pause or end the macro execution by clicking on a button on this window. 

At various plces in the macro file script, the user may be promoted to enter a paramter, or answer yes/no to a question.  A good practice at the end of the script is have the macro script close Tera Term so another script may be started.

How to associate “TTL” files with MACRO

Since Tera Term 4.59, you can associate “.TTL” files with MACRO with installer.  To associate the file extension “.TTL” with MACRO, do the following steps.

  1. Execute the [View] Options command of Explorer.
  2. Select the “File Types” tab.
  3. Click the “New Type” button and specify items like the following.
    Description of type: Tera Term macro files Associated extension: TTL
  4. Click the “New” button and specify items like the following.
    Action: Execute Application used to perform action: "C:\Program Files\teraterm\ttpmacro.exe" "%1" (If Tera Term Pro is installed in C:\Program Files\teraterm.)
  5. Close all the dialog boxes by clicking “OK” buttons.

Macro Example

Below is a simple example macro script to program a Raveon M7 radio modem. 

CONNECT '/C=1'
SEND '+++'
:START
;READ UNIT ID
PAUSE 1
SENDLN 'MYID'
PAUSE 1
yesnobox 'CHANGE UNIT ID?' 'CHANGE UNIT ID?' 
if result goto CHANGEID GOTO DESTINATION 
:CHANGEID 
;CHANGE UNIT ID 
inputbox 'ENTER UNIT ID' 'MYID' 
SENDLN 'MYID ' INPUTSTR
:DESTINATION 
;READ DESTINATION ID 
PAUSE 1 
SENDLN 'TOID' 
PAUSE 1   
yesnobox 'CHANGE DESTINATION ID?' 'CHANGE DESTINATION ID?' 
if result goto DESTID GOTO RXFREQ 
:DESTID 
;CHANGE DESTINATION ID 
inputbox 'ENTER DESTINATION ID' 'TOID' 
SENDLN 'TOID ' INPUTSTR
:RXFREQ
;READ RX FREQ
PAUSE 1
SENDLN 'ATFR'
PAUSE 1
yesnobox 'xxx.xxxx' 'CHANGE FREQUENCY?' 
if result goto SETFREQ GOTO ECHOSTEP 
:SETFREQ
;CHANGE FREQUENCY 
inputbox 'ENTER FREQUENCY' 'ATFX' 
SENDLN 'ATFX ' INPUTSTR
;SET ECHO ON 
:ECHOSTEP




SENDLN 'ATE 1'
;SET CARRIER DETECT TO SHOW ON-LINE STATUS (BASE AND REMOTE)
SENDLN 'ATR1 2'
PAUSE 1
;SET ON-LINE AFTER DIAL (DISABLED ON BASE ONLY)
SENDLN 'ATCS 0'
PAUSE 1
SENDLN 'SHOW'
PAUSE 2
yesnobox '"Y"= FINISHED, "N"= RESTART' 'ALL PARAMETERS CORRECT?' 
if result goto CLOSE GOTO START
:CLOSE
disconnect 0 ;disconnect from teraterm, no confirmation
closett ;close tera term window
END

 

Tera Term Macro Language Information

Following is a quick overview of the Tera Term Macro Language.  

Identifiers and reserved words

1) Variable identifiers

The first character must be an alphabetic (A-Z, a-z) or an underscore character "_". Subsequent characters can be alphabetic, underscore or numeric (0-9). Variable identifiers are not case sensitive. The maximum length is 32.

Example:
    VARIABLE
    _flag

2) Label identifiers

Label identifiers consist of alphabetic, underscore or numeric characters, and are not case sensitive. The maximum length is 32.

Example:
    label1
    100

3) Reserved words

The following words are reserved:

[Command] bplusrecv, bplussend, changedir... (see the command list) [Operator] and, not, or, xor [System variable] groupmatchstr1, groupmatchstr2, groupmatchstr3, groupmatchstr4, groupmatchstr5, groupmatchstr6, groupmatchstr7, groupmatchstr8, groupmatchstr9, inputstr, matchstr, param2, param3, param4, param5, param6, param7, param8, param9, result, timeout, mtimeout

Line formats

There are four kinds of line formats for macro files. Any line can contain a comment which begins with a ";" character. Also, a user can use the C language style comment(/* - */).
Comments give no effect on the execution of MACRO.
One line can contain up to 500 characters. The part that exceeded 500 characters is ignored.

1) Empty lines

Lines which have no character or contain only space or tab characters or a comment. They give no effect on the execution of the macro.

Example:
    ; Tera Term Language
Example: showtt 0 MessageBox 'message 1' 'title 1' /* This is 'comment' "string" */ MessageBox 'message 2' 'title 2' closett

2) Command lines

Lines containing a single command with parameters.

Format: <command> <parameter> ... Example: connect'myhost' wait 'OK' 'ERROR' if result=2 goto error sendln 'cat' pause A*10 end

3) Assignment lines

Lines which contain an assignment statement.

Format: <Variable> = <Value (constant, variable, expression)> Example: A = 33 B = C C must already have a value. VAL = I*(I+1) A=B=C The value of B=C (0 for false, 1 for true) is assigned to A. Error=0<J Username='MYNAME'

4) Label lines

Lines which begin with a ':' character followed by a label identifier.

Format:
    :<Label>

Example:
    :dial
    :100

Communication commands

  • bplusrecv
  • bplussend
  • callmenu (version 4.56 or later)
  • changedir
  • clearscreen
  • closett
  • connect
  • cygconnect (version 4.57 or later)
  • disconnect
  • dispstr (version 4.67 or later)
  • enablekeyb
  • flushrecv
  • gethostname (version 4.61 or later)
  • gettitle
  • kmtfinish
  • kmtget
  • kmtrecv
  • kmtsend
  • loadkeymap
  • logclose
  • logopen
  • logpause
  • logstart
  • logwrite
  • quickvanrecv
  • quickvansend
  • recvln
  • restoresetup
  • scprecv (version 4.57 or later)
  • scpsend (version 4.57 or later)
  • send
  • sendbreak
  • sendbroadcast (version 4.62 or later)
  • sendfile
  • sendkcode
  • sendln
  • sendlnbroadcast (version 4.62 or later)
  • sendmulticast (version 4.62 or later)
  • setbaud (version 4.58 or later)
  • setdebug (version 4.64 or later)
  • setdtr (version 4.59 or later)
  • setecho
  • setmulticastname (version 4.62 or later)
  • setrts (version 4.59 or later)
  • setsync
  • settitle
  • showtt
  • testlink
  • unlink
  • wait
  • wait4all (version 4.63 or later)
  • waitevent
  • waitln
  • waitn (version 4.62 or later)
  • waitrecv
  • waitregex (version 4.21 or later)
  • xmodemrecv
  • xmodemsend
  • ymodemrecv (version 4.66 or later)
  • ymodemsend (version 4.66 or later)
  • zmodemrecv
  • zmodemsend

Control commands

  • break (version 4.53 or later)
  • call
  • do, loop (version 4.56 or later)
  • end
  • execcmnd
  • exit
  • for, next
  • goto
  • if, then, elseif, else, endif
  • include
  • mpause (version 4.27 or later)
  • pause
  • return
  • until, enduntil (version 4.56 or later)
  • while, endwhile

String operation commands

  • code2str
  • expandenv (version 4.71 or later)
  • int2str
  • sprintf (version 4.52 or later)
  • sprintf2 (version 4.62 or later)
  • str2code
  • str2int
  • strcompare
  • strconcat
  • strcopy
  • strinsert (version 4.67 or later)
  • strjoin (version 4.67 or later)
  • strlen
  • strmatch (version 4.59 or later)
  • strremove (version 4.67 or later)
  • strreplace (version 4.67 or later)
  • strscan
  • strspecial (version 4.67 or later)
  • strsplit (version 4.67 or later)
  • strtrim (version 4.67 or later)
  • tolower (version 4.53 or later)
  • toupper (version 4.53 or later)

File operation commands

  • basename (version 4.69 or later)
  • dirname (version 4.69 or later)
  • fileclose
  • fileconcat
  • filecopy
  • filecreate
  • filedelete
  • filemarkptr
  • fileopen
  • filereadln
  • fileread (version 4.48 or later)
  • filerename
  • filesearch
  • fileseek
  • fileseekback
  • filestat (version 4.66 or later)
  • filestrseek
  • filestrseek2
  • filetruncate (version 4.67 or later)
  • filewrite
  • filewriteln
  • findfirst, findnext, findclose
  • foldercreate (version 4.69 or later)
  • folderdelete (version 4.69 or later)
  • foldersearch (version 4.69 or later)
  • getdir
  • getfileattr (version 4.69 or later)
  • makepath
  • setdir
  • setfileattr (version 4.69 or later)

Password commands

  • delpassword
  • getpassword
  • passwordbox

Miscellaneous commands

  • beep
  • closesbox
  • clipb2var (version 4.46 or later)
  • crc32 (version 4.60 or later)
  • crc32file (version 4.60 or later)
  • exec
  • filenamebox (version 4.54 or later)
  • getdate
  • getenv
  • gettime
  • getttdir (version 4.60 or later)
  • getver (version 4.58 or later)
  • ifdefined (version 4.46 or later)
  • inputbox
  • messagebox
  • random (version 4.27 or later)
  • rotateleft (version 4.54 or later)
  • rotateright (version 4.54 or later)
  • setdate
  • setdlgpos
  • setenv (version 4.54 or later)
  • setexitcode
  • settime
  • show
  • statusbox
  • var2clipb (version 4.46 or later)
  • yesnobox

PAUSE 1

Filed under: Programming and Configuring | Posted on August 24th, 2011 by John Sonnenberg

Leave a Reply

You must be logged in to post a comment.