Sam_I_Am -- Program Operation

Andrew Sterian
Padnos College of Engineering and Computing
Grand Valley State University


Top-Level | Connecting the Device | Program Operation | Commands
 
Command-Line Options | Startup Files | Command-Line Commands

Introduction

Sam_I_Am is invoked from the command line within a terminal/shell/console program (rxvt, xterm, Konsole, gnome-terminal, etc.) After opening a console, you should simply be able to type:
    Sam_I_Am --version
This will verify that Sam_I_Am is properly installed and accessible. If this does not work, you need to find out where Sam_I_Am was installed. Type the following:
    python -c "import sys; print sys.prefix+'/lib/python'+sys.version[:3]"
You should see a directory name such as /usr/lib/python2.3. You can then invoke Sam_I_Am as follows:
    python /usr/lib/python2.3/site-packages/Sam_I_Am/samiam.py
If this still does not work, try the Installation instructions again.

Command-Line Options

By default, simply typing Sam_I_Am will perform the following tasks:
  1. Find and execute the commands in any startup script files (see the Startup Files below)
  2. Enter an interactive command mode
The following command-line options modify this default behavior:
-x FILE or --rc-file=FILE
The default startup script file is either .samiamrc in the current directory or, if not found, the file .samiamrc in the HOME directory (i.e., ${HOME}/.samiamrc). With this option specified, however, the startup script file in this option is used instead.
-X or --norc-file
This option prevents Sam_I_Am from executing any startup script files.
-i or --interactive
Normally, when command-line commands are given (see the Command-Line Commands section below) Sam_I_Am will perform those commands and exit. With this option specified, Sam_I_Am will perform the commands and then remain in interactive mode.
Finally, the --help and --version command-line options print a brief help summary and program version, respectively.

Startup Files

Sam_I_Am can execute a sequence of commands stored in a file every time it runs. This behavior can be useful to, for example, automatically connect to SAM-BA, set protected memory regions, and so on.

In its normal mode of operation, Sam_I_Am looks in the current directory for a file named .samiamrc. If found, the commands in this file are executed as if they had been typed by you at the keyboard in interactive mode. Once all commands are executed, Sam_I_Am enters interactive mode in which you can begin typing your own commands.

If no .samiamrc file is found in your current directory, the same file name is loaded, if it exists, from your home directory (i.e., ${HOME}/.samiamrc). If this file does not exist here either, then no startup file is loaded.

Here is a sample .samiamrc file that opens a connection to SAM-BA, prints the SAM-BA version, then sets allowable memory accesses to correspond to the memory map of an AT91SAM7S256 device:

      open /dev/ttyUSB0
      version
      set readallow 0 0x300000
      set ramwriteallow 0x202000 57344
      set flashwriteallow 0x100000 0x40000

Sam_I_Am can be told to either ignore startup files or execute a startup file other than .samiamrc depending upon the command-line options presented in the previous section.

Command-Line Commands

Additional arguments to Sam_I_Am on the command line are interpreted as commands as if they were typed in interactive mode. These commands are performed after executing any startup files. For example:
    Sam_I_Am dump 0x202000
The above command would rely upon the presence of a .samiamrc file that contained an open command so that the dump command would be successful.

Multiple commands can be executed by separating them with isolated commas. After all commands are performed, Sam_I_Am exits (unless the -i or --interactive command-line option is specified).

For example:

    Sam_I_Am open /dev/ttyUSB0 , send program.hex , go
The above command opens the device port (assuming no .samiamrc file does so), uploads a HEX file, and runs the program uploaded. As soon as the GO command is issued, Sam_I_Am exits (though the uploaded program continues to run).

The following example uses the source command to effectively execute two startup files, .samiamrc and run.sam, and then remain in interactive mode to accept more commands:

    Sam_I_Am -i source run.sam

© 2006, Copyright by Andrew Sterian; All Rights Reserved. mailto: steriana@claymore.engineer.gvsu.edu