Difference between revisions of "Mce cmd"

From MCEWiki
(Output formatting)
Line 1: Line 1:
= Read and write commands =
+
= Overview =
  
MCE configuration data is stored in blocks at certain card and
+
mce_cmd provides an interface between a linux shell and the MCE.  The application can run interactively (accepting commands from a user and issuing responses to standard out), or can be used to execute scripts containing mce_cmd instructions.
parameter addresses (which we will call "block locations".  The data
+
 
block consists of one or more 32-bit words.
+
= Running mce_cmd =
 +
 
 +
== Interactive mode ==
 +
 
 +
When invoked with the '-i' option, mce_cmd can be used interactively.  A session command history (similar to the one in bash) can be accessed with the up and down arrow keys, and line editing is possible using emacs-based key-mappings.
 +
mce_cmd -i
 +
 
 +
After displaying a version message, mce_cmd will be ready to accept input.  There is no user prompt.
 +
 
 +
== Single command execution ==
 +
 
 +
A single command can be issued using the '-x' option:
 +
mce_cmd -x rb cc fw_rev
 +
The application will execute the command, display any output, and exit.  Currently, only single commands can be executed from the command line.
 +
 
 +
== Script execution ==
 +
 
 +
The '-f' option tell mce_cmd to read lines from the specified file and attempt to execute them.  The '-q' option suppresses unnecessary output.
 +
mce_cmd -q -f my_script.scr
 +
 
 +
When redirecting commands to mce_cmd, the '-r' option should be used to disable the command history/line editing features of mce_cmd and decrease the execution time.
 +
cat my_script.scr | mce_cmd -q -r
 +
 
 +
If a script command fails, mce_cmd will exit.  To suppress that behaviour (and continue attempting commands even after one of them has failed), pass the '-i' option.
 +
 
 +
 
 +
= Commands =
 +
 
 +
We can break the mce_cmd command set into three broad categories: MCE commands, data acquisition commands, and output formatting commands.
 +
 
 +
== MCE data block commands ==
 +
 
 +
MCE configuration data is stored in blocks at certain card and parameter addresses (which we will call "block locations")A typical block address is
 +
rc2 flx_quanta4
 +
This block consists of 41 32-bit words where the user writes the squid-1 flux quantum size for column 4 on readout card 2.
  
 
The most basic data manipulation commands are RB ("read block") and WB
 
The most basic data manipulation commands are RB ("read block") and WB
("write block").  These commands read and write to the entire range of
+
("write block").  These commands read from or write to the entire range of
 
data at the block location, starting at the beginning of the block.
 
data at the block location, starting at the beginning of the block.
  
Line 12: Line 46:
 
read or write particular subranges of the data in a block location.
 
read or write particular subranges of the data in a block location.
  
All read and write commands take a card (or virtual card) name and a
+
All read and write commands take a card (or [[ Virtual cards | virtual card ]]) name and a
parameter name as the first two arguments.  Physical cards are
+
parameter name as the first two arguments.   
associated with particular hardware elements in the system, for
 
example "cc" (clock card) and "rc2" (readout card).  Virtual cards are
 
used to group a set of hardware functions into a single name-space.
 
The data associated with a virtual card parameter may be shared across
 
multiple hardware cards.  Parameters accessible via virtual mappings
 
are also accessible via some set of hardware card addresses.
 
  
== Syntax summary ==
+
=== RB: read block ===
  
 +
Syntax:
 
  rb  <card> <param>
 
  rb  <card> <param>
rra <card> <param> <starting index> <count>
 
wb  <card> <param> [data, ...]
 
wra <card> <param> <starting index> [data, ...]
 
 
== RB command ==
 
  
RB will return all data associated with the block location.
+
The read block command returns the entire contents of a block location.
  
 +
Example:
 
  rb rc1 adc_offset0
 
  rb rc1 adc_offset0
 
  Line  1 : ok : 10 11 9 8 12 13 14 15
 
  Line  1 : ok : 10 11 9 8 12 13 14 15
  
== RRA command ==
 
  
The RRA command returns only the subset of the data that were
+
=== WB: write block ===
asked for.
 
 
 
rra rc1 adc_offset0 2 4
 
Line  1 : ok : 9 8 12 13
 
  
== WB command ==
+
Syntax:
 +
wb  <card> <param> [val0 val1 val2 ...]
  
The WB command will update words in the block location.  If the number
+
The write block command writes the given data to the specified block location.  If the number of data is smaller than block size, the remaining block elements will not be alteredIf the number of data is larger than the block size, the behaviour depends on the implementation of the block location.
of data words given as arguments to the WB command is smaller than the
 
natural size of the block location, only those first few data
 
locations will be updatede.g.,
 
  
 +
Example:
 
  wb rc1 adc_offset0 0 1 2
 
  wb rc1 adc_offset0 0 1 2
 
  Line  1 : ok
 
  Line  1 : ok
Line 55: Line 74:
 
  Line  2 : ok :  0 1 2 8 12 13 14 15
 
  Line  2 : ok :  0 1 2 8 12 13 14 15
  
== WRA command ==
+
=== RRA: read range ===
 +
 
 +
Syntax:
 +
rra <card> <param> <start_index> <count>
 +
 
 +
The read range command returns <count> values from the block location, starting from the value at <start_index> (indexed from 0).
 +
 
 +
Example:
 +
rra rc1 adc_offset0 2 4
 +
Line  1 : ok : 2 8 12 13
 +
 
 +
=== WRA: write range ===
 +
 
 +
Syntax:
 +
wra <card> <param> <start_index> [val0 val1 val2 ...]
  
The WRA command updates words starting at the specified index.
+
The write range command writes the given values into the block location, starting at <start_index> (indexed from 0).  Other block data (i.e. at indices lower than start_index) are not changed.  (This command is implemented as a read-update-write and will usually take twice as long to execute as a WB command.)
  
 +
Example:
 
  wra rc1 adc_offset0 4 100 200
 
  wra rc1 adc_offset0 4 100 200
 
  Line  1 : ok
 
  Line  1 : ok
 
  rb rc1 adc_offset0
 
  rb rc1 adc_offset0
 
  Line  2 : ok :  0 1 2 8 100 200 14 15
 
  Line  2 : ok :  0 1 2 8 100 200 14 15
Please note that WRA and RRA are not more efficient than WB and RB.
 
MAS translates WRA and RRA into the equivalent set of WB and RB
 
commands, and not the other way around.
 
  
  

Revision as of 00:51, 6 March 2008

Overview

mce_cmd provides an interface between a linux shell and the MCE. The application can run interactively (accepting commands from a user and issuing responses to standard out), or can be used to execute scripts containing mce_cmd instructions.

Running mce_cmd

Interactive mode

When invoked with the '-i' option, mce_cmd can be used interactively. A session command history (similar to the one in bash) can be accessed with the up and down arrow keys, and line editing is possible using emacs-based key-mappings.

mce_cmd -i

After displaying a version message, mce_cmd will be ready to accept input. There is no user prompt.

Single command execution

A single command can be issued using the '-x' option:

mce_cmd -x rb cc fw_rev

The application will execute the command, display any output, and exit. Currently, only single commands can be executed from the command line.

Script execution

The '-f' option tell mce_cmd to read lines from the specified file and attempt to execute them. The '-q' option suppresses unnecessary output.

mce_cmd -q -f my_script.scr

When redirecting commands to mce_cmd, the '-r' option should be used to disable the command history/line editing features of mce_cmd and decrease the execution time.

cat my_script.scr | mce_cmd -q -r

If a script command fails, mce_cmd will exit. To suppress that behaviour (and continue attempting commands even after one of them has failed), pass the '-i' option.


Commands

We can break the mce_cmd command set into three broad categories: MCE commands, data acquisition commands, and output formatting commands.

MCE data block commands

MCE configuration data is stored in blocks at certain card and parameter addresses (which we will call "block locations"). A typical block address is

rc2 flx_quanta4

This block consists of 41 32-bit words where the user writes the squid-1 flux quantum size for column 4 on readout card 2.

The most basic data manipulation commands are RB ("read block") and WB ("write block"). These commands read from or write to the entire range of data at the block location, starting at the beginning of the block.

The commands RRA ("read range") and WRA ("write range") can be used to read or write particular subranges of the data in a block location.

All read and write commands take a card (or virtual card ) name and a parameter name as the first two arguments.

RB: read block

Syntax:

rb  <card> <param>

The read block command returns the entire contents of a block location.

Example:

rb rc1 adc_offset0
Line   1 : ok : 10 11 9 8 12 13 14 15


WB: write block

Syntax:

wb  <card> <param> [val0 val1 val2 ...]

The write block command writes the given data to the specified block location. If the number of data is smaller than block size, the remaining block elements will not be altered. If the number of data is larger than the block size, the behaviour depends on the implementation of the block location.

Example:

wb rc1 adc_offset0 0 1 2
Line   1 : ok
rb rc1 adc_offset0
Line   2 : ok :  0 1 2 8 12 13 14 15

RRA: read range

Syntax:

rra <card> <param> <start_index> <count>

The read range command returns <count> values from the block location, starting from the value at <start_index> (indexed from 0).

Example:

rra rc1 adc_offset0 2 4
Line   1 : ok : 2 8 12 13

WRA: write range

Syntax:

wra <card> <param> <start_index> [val0 val1 val2 ...]

The write range command writes the given values into the block location, starting at <start_index> (indexed from 0). Other block data (i.e. at indices lower than start_index) are not changed. (This command is implemented as a read-update-write and will usually take twice as long to execute as a WB command.)

Example:

wra rc1 adc_offset0 4 100 200
Line   1 : ok
rb rc1 adc_offset0
Line   2 : ok :  0 1 2 8 100 200 14 15


Output formatting

The output consists of two or three parts, separated by colons. If in line prefix mode (which is the default) the output is:

Line <line number>: <success> [: auxiliary data]

The <success> indicator will be "ok" if the command succeeded, or "error" otherwise. Successful commands may return data (for example, an RB command). Failed commands will always return an error message as the auxiliary data.

If mce_cmd is invoked with prefixes turned off ('-p'), the output format is

<success> [: auxiliary data]

If mce_cmd is invoked in quiet mode ('q'), then all command responses that have no auxiliary data are suppressed. In quiet mode, "Line 12: ok" will not be displayed.