1. Intro
2. Running code on linux
3. Running code on uboot
4. HG Notes
5. Background Resets




1. Intro


pclock2 is Prototype Clocking code for the IRSG controller.
Code is located in /home/sgir/src/pclock2 on the IRTF network.

These files can be compile into pclock(Linux Host) and sgir's uboot.

   ircommand.c/.h - commands for plcock or sgir uboot.
   ir.c/.h - ir arrays genenal functions.
   al.c/.h - aladdin specific functions.
   h2.c/.h - h2rg specific functions
	pnp.c/.h - test code to exercise/test CE and clv stuff.

Other pclock file are linux specific:

plcock.c    - appplication main file. Does the command execution.
common.c/.h - provides common or utility-type C functions.



2. Running code on linux

 1. Recompie for you linux system:
     > make clean
     > make

 2. Command - you can view pclock.c file's Parse_table[] for a list of
    command you can execute at the command prompt (Parse_table[] is
    similiar to uboot's cmd_table[]).

 3. pclock.c's main() contains this call:
       ircommand_initial_setup( IRDEVICE_AL );  /* boot time setup for ircommand */

   Initilaize memory and set up the default IR Device to Aladdin.
   (H2RG clocking code is not ready yet, and will be merged into pclock in the future).



3. Running code on uboot


The code for  ircommand, ir, al, h2 can be execute via the sgir uboot. How?

   1. soft link needed source files. And add to Makefile

      cd gpc/src-ppc405/u-boot/daq3u_apps
      ln -s /home/sgir/src/pclock2/ircommand.h
      ln -s /home/sgir/src/pclock2/ircommand.c
      ln -s /home/sgir/src/pclock2/ir.h
      ln -s /home/sgir/src/pclock2/ir.c
      ln -s /home/sgir/src/pclock2/al.h
      ln -s /home/sgir/src/pclock2/al.c
      ln -s /home/sgir/src/pclock2/h2.h
      ln -s /home/sgir/src/pclock2/h2.c
      ln -s /home/sgir/src/pclock2/pnp.h
      ln -s /home/sgir/src/pclock2/pnp.c

      vi Makefile
         add: DAQ3U_APPS += ircommand ir al h2 pnp # Add to compile sgir code

   2. add command to the commandline interface code.

      cd gpc/src-ppc405/u-boot/common/
      vi cli_comlist.c
        1. Add prototypes, ie: extern Function t1;
        2. Add entries to cmd_table[] , ie: {"t1", t1, "test1"}

   3. Running the code.
      After stage2 is started, the 1st command you should run is 'irinit'.


4. HG notes and source control

clones should be push/pull to /home/sgir/src/pclock2.

4.1. 'sgir' created the HG Repository by: 

   cd /home/sgir/src/pclock2
   hg init
   hg add *.c *.h makefile POA.txt README.html save.me
   hg commit

  Now 'sgir' has a working directory and a repository.
  'sgir' continues modification this working copy.

  When 'sgir' is ready to update his repository with a new version:

  hg status         - summary of changes between repository and working copy.
  hg diff           - diff    of changes between repository and working copy.
  hg commit         - commit all changes to the repository

  If someone pushes an update to 'sgir', then 'sgir' need to do:
     hg  update  - updates the repository's working directory

  It's likely others can't update 'sgir''s repository (permission problems), so
  'sgir' can pull those update:

     hg pull /home/joe/project  - pulls in changes from joe's repository
     hg update                  - update 'sgir''s working copy


4.2. Tony wants to join in.

    To get a copy of sgir's repository (not the working copy):
        hg clone /home/sgir/src/pclock2 pclock2

    To re-synhonize a working copy (Update Tony's copy with sgir's repository):
       hg pull           - to sync the repository
       hg update         - to update the working copy

    Tony modify his working directory. Change can be commit
       hg commit

    To updload changes to sgir's repository:
       hg push

4.3 Other HG commands

   hg  log           - history of repository
   hg  status        - display current status (files that changed).
   hg  diff          - shows changes between repository and working copy.


5. BackGround Resets (BGR)

   The linux host will perform the background resets. Host parameters are:
      bgr.enable { off | on }  - enable BGR
      bgr.period sec - BGR period. Range is 0.2 to 10.0 seconds. Defaults: AL=2.0, H2RG=??.
   Controller commands are:
      bgr.wait.ms ms - minimum time between a BGR and a GO. Range 1 ms to 60,000 ms. 
		                 Defaults: AL=250, H2RG=??
		al.bgr.usec usec - Reset time for AL devices. Default is 40 usec.
      bgr.go - command used by host to do a background reset.

5. Questions