--- /dev/null
+This folder is to support the trbnet commands (trbcmd, trbflash, etc.) with
+the zsh autocompletion.
+
+The autocompletion files are located in the "completion" folder. The files can
+be edited to extend the autocompletion functionality. The following lines
+should be copied to the .zshrc file:
+
+
+###########################################################
+# COMPLETION SETTINGS
+## add custom completion scripts
+fpath=(~/trbsoft/trbnettools/zsh/completion $fpath)
+# compsys initialization
+
+zmodload zsh/complist
+autoload -U compinit
+compinit
+
+zstyle ':completion:*' special-dirs true
+
+# show completion menu when number of options is at least 2
+zstyle ':completion:*' menu select=2
+zstyle ":completion:*:descriptions" format "%B%d%b"
+###########################################################
--- /dev/null
+#compdef trbcmd
+
+
+# variables
+_command=(
+ 'r[read register]'\
+ 'rt[read register&TimeStamp]'\
+ 'w[write register]'\
+ 'rm[read register-memory]'\
+ 'rmt[read register-memory&TimeStamp]'\
+ 'wm[write to register-memory from ASCII-file ('-' = stdin)]'\
+ 'i[read unique ID]'\
+ 's[set trb-address]'\
+ 'T[send trigger]'\
+ 'TR[send trigger to RICH only]'\
+ 'I[read IPU data]'\
+ 'setbit[set bits of a register]'\
+ 'clearbit[clear bits of a register]'\
+ 'loadbit[load bits of a register]'\
+ 'nettrace[trace TRBNet-Path of an endpoint]'\
+ 'reload[reload FPGA]'\
+ 'reset[reset TRBNetwork]'\
+ 'comreset[reset Etrax-FIFO Logic]'\
+ 'f[flush FIFO of channel]'\
+ 'R[read register of the FPGA]'\
+ 'W[write to register of the FPGA]'\
+ 'exit[disconnect from server (tcp-server mode only)]'\
+ 'quit[disconnect from server (tcp-server mode only)]'
+)
+
+_broadcast_address=(
+ '0xffff[broadcast all]'
+ '0xfe40[broadcast central]'
+ '0xfe45[broadcast peripheral]'
+ '0xfe48[broadcast TDC on peripheral]'
+ '0xfe49[broadcast Nxyter addon]'
+ '0xfe4a[broadcast GeneralPurpose addon]'
+ '0xfe4b[broadcast ADC addon]'
+ '0xfe4c[broadcast ADDON_4CONN2 addon (padiwa)]'
+ '0xfe4d[broadcast MAPS readout]'
+ '0xfe4e[broadcast Hades Start Detector]'
+ '0xfe4f[broadcast Panda Straw Tube]'
+ '0xfe50[broadcast CBM-Rich & CBM-TOF]'
+ '0xfe60[broadcast TRB3sc]'
+)
+_endpoint_address=(
+ ${(f)"$(trbcmd i 0xffff | awk '{print $1}')"}
+)
+
+_register=(
+ '0x1[some register]'
+ '0x50[up time]'
+ '0xc801[tdc trigger window config]'
+ '0xc802[tdc channel enable 1-32]'
+ '0xc803[tdc channel enable 33-64]'
+ '0xc804[tdc channel ring buffer size (max 124)]'
+ '0xc805[tdc channel invert 1-32]'
+ '0xc806[tdc channel invert 33-64]'
+ '0xc102[tdc trigger time]'
+
+)
+
+_endpoint=(
+ '0x0'
+ '0x1'
+ '0x2'
+ '0x3'
+ '0x4'
+ '0x5'
+)
+
+_mode=(
+ '0'
+ '1'
+)
+
+_debugLevel=(
+ '1'
+ '2'
+)
+
+_time=(
+ '100'
+ '200'
+ '500'
+ '1000'
+ '5000'
+ '10000'
+)
+
+
+
+# work block
+_trbcmd() {
+ _arguments \
+ -C -A"-*"\
+ '-h[give this help]'\
+ '-f[execute commands given in script-file]:script-files:->files'\
+ '-n[repeat COMMAND number times, -1 = endless loop]:repeat number:(-1)'\
+ '-s[only if running in -n mode, sleep time in ms]:sleep time:->time'\
+ '-d[turn on Debugging Information level 1: TRB_Package debugging level 2: +FIFO debugging]:debug level:->debugLevel'\
+ '-H[hex-mode\: all arguments will be interpreted as hexadecimal-numbers]'\
+ '-D[dec-mode\: display register values as decimal numbers]'\
+ '-V[version number]'\
+ '1:commmand:->command'\
+ '2::arg2:->arg2'\
+ '3::arg3:->arg3'\
+ '4::arg4:->arg4'\
+ '5::arg5:->arg5'\
+
+
+
+ case "$state" in
+ files)
+ _files
+ ;;
+ time)
+ _values 'sleep time' $_time
+ ;;
+ debugLevel)
+ _values 'debug level' $_debugLevel
+ ;;
+ command)
+ _values 'command' $_command
+ ;;
+ arg2)
+ case $line[1] in
+ reset | comreset)
+
+ ;;
+ r | rt | w | rm | rmt | wm | i | setbit | clearbit | loadbit | nettrace | reload)
+ _values 'trbaddress' $_broadcast_address $_endpoint_address\
+ ;;
+ s)
+ :uid:uid:((\:\:))
+ ;;
+ T | I | f | R | W)
+
+ ;;
+ esac
+ ;;
+ arg3)
+ case $line[1] in
+ i | nettrace | reload)
+
+ ;;
+ r | rt | w | rm | rmt | wm | setbit | clearbit | loadbit)
+ _values 'register' $_register\
+ ;;
+ s)
+ _values 'endpoint' $_endpoint\
+ ;;
+ esac
+ ;;
+ arg4)
+ case $line[1] in
+ w)
+ :data:data:((\:\:))
+ ;;
+ rm | rmt)
+ :size:size:((\:\:))
+ ;;
+ wm)
+ _values 'mode' $_mode\
+ ;;
+ setbit | clearbit | loadbit)
+ :bitmask:bitmask:((\:\:))
+ ;;
+ s)
+ :trbaddress:trbaddress:((\:\:))
+ ;;
+ esac
+ ;;
+ arg5)
+ case $line[1] in
+ rm | rmt)
+ _values 'mode' $_mode\
+ ;;
+ loadbit)
+ :value:value:((\:\:))
+ ;;
+ esac
+ ;;
+ esac
+
+}
+
+case "$service" in
+ trbcmd)
+ _trbcmd "$@" && return 0
+ ;;
+esac
+
+
--- /dev/null
+#compdef trbflash
+
+
+# variables
+_command=(
+ 'program[bit-file to flash-memory]'\
+ 'verify[compare bit-file with flash-memory]'\
+ 'backup[write entire flash-memory to raw-file]'\
+ 'restore[write backuped raw-file to flash-memory]'\
+ 'info[dump content of info-page to stdout]'\
+ 'dumppage[dump one flash-memory page to stdout]'\
+)
+
+_broadcast_address=(
+ '0xffff[broadcast all]'
+ '0xfe40[broadcast central]'
+ '0xfe45[broadcast peripheral]'
+ '0xfe48[broadcast TDC on peripheral]'
+ '0xfe49[broadcast Nxyter addon]'
+ '0xfe4a[broadcast GeneralPurpose addon]'
+ '0xfe4b[broadcast ADC addon]'
+ '0xfe4c[broadcast ADDON_4CONN2 addon (padiwa)]'
+ '0xfe4d[broadcast MAPS readout]'
+ '0xfe4e[broadcast Hades Start Detector]'
+ '0xfe4f[broadcast Panda Straw Tube]'
+ '0xfe50[broadcast CBM-Rich & CBM-TOF]'
+ '0xfe60[broadcast TRB3sc]'
+)
+_endpoint_address=(
+ ${(f)"$(trbcmd i 0xffff | awk '{print $1}')"}
+)
+
+
+
+# work block
+_trbflash() {
+ _arguments \
+ -C -A"-*"\
+ '-s[set user-string of info page (default: empty string)]:string:'\
+ '-g[select \"FlashRom #0\" (the \"Golden Image\") (MDC only, default = no)]'\
+ '-y[assume yes to all questions which might will be asked]'\
+ '-f[do not validate FirmwareId of ImageFile (DON\"T USE, for EXPERTS ONLY)]'\
+ '-v[skip verify after programming]'\
+ '-h[give this help]'\
+ '-V[version number]'\
+ '1:commmand:->command'\
+ '2:trbaddress:->trbaddress'\
+ '3::arg3:->arg3'\
+
+ case "$state" in
+ command)
+ _values 'command' $_command
+ ;;
+ trbaddress)
+ _values 'trbaddress' $_broadcast_address $_endpoint_address\
+ ;;
+ arg3)
+ case $line[1] in
+ program | verify)
+ local -a bit_files
+ bit_files=( *.{bit,jed} )
+ _multi_parts / bit_files
+ ;;
+ backup | restore)
+ _files
+ ;;
+ dumppage)
+
+ ;;
+ esac
+ ;;
+ esac
+}