diff --git a/.gitattributes b/.gitattributes
index 57a4521083e6435bc9df1681e3e5d6c553366748..84cd1ac8037e935cc4020af98ae0d0292b32393f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -722,135 +722,136 @@ LCU/Firmware/tools/src/rsuctl3 -text
 LCU/Firmware/tools/src/rsuctl3.pl -text
 LCU/Firmware/tools/src/rsuctl3_reset -text
 LCU/Firmware/tools/src/view_images.sh -text
-LCU/StationTest/README.txt -text
-LCU/StationTest/crc_dir_test.py -text
-LCU/StationTest/gold/prbs_dir_test.gold -text
-LCU/StationTest/gold/prbs_dir_test_int.gold -text
-LCU/StationTest/gold/rsp_version.gold -text
-LCU/StationTest/gold/rsp_version_int.gold -text
-LCU/StationTest/gold/tbb_memory.gold -text
-LCU/StationTest/gold/tbb_memory0.gold -text
-LCU/StationTest/gold/tbb_memory1.gold -text
-LCU/StationTest/gold/tbb_memory10.gold -text
-LCU/StationTest/gold/tbb_memory11.gold -text
-LCU/StationTest/gold/tbb_memory2.gold -text
-LCU/StationTest/gold/tbb_memory3.gold -text
-LCU/StationTest/gold/tbb_memory4.gold -text
-LCU/StationTest/gold/tbb_memory5.gold -text
-LCU/StationTest/gold/tbb_memory6.gold -text
-LCU/StationTest/gold/tbb_memory7.gold -text
-LCU/StationTest/gold/tbb_memory8.gold -text
-LCU/StationTest/gold/tbb_memory9.gold -text
-LCU/StationTest/gold/tbb_size.gold -text
-LCU/StationTest/gold/tbb_size_int.gold -text
-LCU/StationTest/gold/tbb_version.gold -text
-LCU/StationTest/gold/tbb_version_int.gold -text
-LCU/StationTest/gold/xst.m -text
+LCU/StationTest/CMakeLists.txt eol=lf
+LCU/StationTest/README.txt eol=lf
+LCU/StationTest/crc_dir_test.py eol=lf
+LCU/StationTest/gold/prbs_dir_test.gold eol=lf
+LCU/StationTest/gold/prbs_dir_test_int.gold eol=lf
+LCU/StationTest/gold/rsp_version.gold eol=lf
+LCU/StationTest/gold/rsp_version_int.gold eol=lf
+LCU/StationTest/gold/tbb_memory.gold eol=lf
+LCU/StationTest/gold/tbb_memory0.gold eol=lf
+LCU/StationTest/gold/tbb_memory1.gold eol=lf
+LCU/StationTest/gold/tbb_memory10.gold eol=lf
+LCU/StationTest/gold/tbb_memory11.gold eol=lf
+LCU/StationTest/gold/tbb_memory2.gold eol=lf
+LCU/StationTest/gold/tbb_memory3.gold eol=lf
+LCU/StationTest/gold/tbb_memory4.gold eol=lf
+LCU/StationTest/gold/tbb_memory5.gold eol=lf
+LCU/StationTest/gold/tbb_memory6.gold eol=lf
+LCU/StationTest/gold/tbb_memory7.gold eol=lf
+LCU/StationTest/gold/tbb_memory8.gold eol=lf
+LCU/StationTest/gold/tbb_memory9.gold eol=lf
+LCU/StationTest/gold/tbb_size.gold eol=lf
+LCU/StationTest/gold/tbb_size_int.gold eol=lf
+LCU/StationTest/gold/tbb_version.gold eol=lf
+LCU/StationTest/gold/tbb_version_int.gold eol=lf
+LCU/StationTest/gold/xst.m eol=lf
 LCU/StationTest/gold/xst_160.gold -text
 LCU/StationTest/gold/xst_200_even.gold -text
 LCU/StationTest/gold/xst_200_odd.gold -text
-LCU/StationTest/hbacontrol.txt -text
-LCU/StationTest/i2c_spu.py -text
-LCU/StationTest/i2c_td.py -text
-LCU/StationTest/ledtest.sh -text
-LCU/StationTest/modemlevel.sh -text
-LCU/StationTest/modules/cli.py -text
-LCU/StationTest/modules/mep.py -text
-LCU/StationTest/modules/mmd_serdes.py -text
-LCU/StationTest/modules/rsp.py -text
-LCU/StationTest/modules/smbus.py -text
-LCU/StationTest/modules/testcase.py -text
-LCU/StationTest/modules/testlog.py -text
-LCU/StationTest/power_ctrl.py -text
-LCU/StationTest/prbs_dir_test.py -text
-LCU/StationTest/prbs_test.py -text
-LCU/StationTest/rad_status.py -text
-LCU/StationTest/rcumodem.sh -text
-LCU/StationTest/rmfiles.sh -text
-LCU/StationTest/rsp_version.sh -text
-LCU/StationTest/rsp_xc_160.sh -text
-LCU/StationTest/rsp_xc_200.sh -text
-LCU/StationTest/serdes.sh -text
-LCU/StationTest/station_production.py -text
-LCU/StationTest/subrack_production.py -text
-LCU/StationTest/subrackplustest.sh -text
-LCU/StationTest/subracktest.sh -text
-LCU/StationTest/tbb_memory.sh -text
-LCU/StationTest/tbb_prbs_tester.sh -text
-LCU/StationTest/tbb_size.sh -text
-LCU/StationTest/tbb_version.sh -text
-LCU/StationTest/tc/bist.py -text
-LCU/StationTest/tc/cdo_ctrl.py -text
-LCU/StationTest/tc/cdo_settings.py -text
-LCU/StationTest/tc/cdo_transport.py -text
-LCU/StationTest/tc/empty.py -text
-LCU/StationTest/tc/hba_client.py -text
-LCU/StationTest/tc/hba_line_level.py -text
-LCU/StationTest/tc/hba_server.py -text
-LCU/StationTest/tc/prsg.py -text
-LCU/StationTest/tc/rad_lanemode.py -text
-LCU/StationTest/tc/rad_latency.py -text
-LCU/StationTest/tc/read_serdes_phy.py -text
-LCU/StationTest/tc/rsr_overwrite.py -text
-LCU/StationTest/tc/serdes.py -text
-LCU/StationTest/tc/spustat.py -text
-LCU/StationTest/tc/status.py -text
-LCU/StationTest/tc/sync_delay.py -text
-LCU/StationTest/tc/tdstat.py -text
-LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU192.sh -text
-LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU96.sh -text
-LCU/StationTest/test/beamformertest/beamformertest_LBA_RCU192.sh -text
-LCU/StationTest/test/beamformertest/beamformertest_LBHLBL_RCU96.sh -text
-LCU/StationTest/test/beamformertest/beamformertest_LBH_RCU96.sh -text
-LCU/StationTest/test/beamformertest/beamformertest_LBL_RCU96.sh -text
-LCU/StationTest/test/beamformertest/beamformertest_splitter.sh -text
-LCU/StationTest/test/beamformertest/hba0_hba1_azel.sh -text
-LCU/StationTest/test/envcontroltest/ecCtrl.py -text
-LCU/StationTest/test/envcontroltest/eccontrol.py -text
-LCU/StationTest/test/envcontroltest/power.py -text
-LCU/StationTest/test/envcontroltest/stations.py -text
-LCU/StationTest/test/hbatest/beamduur.sh -text
-LCU/StationTest/test/hbatest/determinepeak.py -text
-LCU/StationTest/test/hbatest/gold/hba_modem1.gold -text
-LCU/StationTest/test/hbatest/gold/hba_modem2.gold -text
-LCU/StationTest/test/hbatest/gold/hba_modem3.gold -text
-LCU/StationTest/test/hbatest/hba_new_address.sh -text
-LCU/StationTest/test/hbatest/hba_read_all.sh -text
-LCU/StationTest/test/hbatest/hba_save_power.sh -text
-LCU/StationTest/test/hbatest/hbaelementtest.py -text
-LCU/StationTest/test/hbatest/hbaquicktest.py -text
-LCU/StationTest/test/hbatest/modem_count.py -text
-LCU/StationTest/test/hbatest/modemtest.sh -text
-LCU/StationTest/test/subbandstatistics/subbandstatistics_hba-5.sh -text
-LCU/StationTest/test/subbandstatistics/subbandstatistics_hba-6.sh -text
-LCU/StationTest/test/subbandstatistics/subbandstatistics_hba-7.sh -text
-LCU/StationTest/test/subbandstatistics/subbandstatistics_lbh-3.sh -text
-LCU/StationTest/test/subbandstatistics/subbandstatistics_lbh-4.sh -text
-LCU/StationTest/test/subbandstatistics/subbandstatistics_lbl-1.sh -text
-LCU/StationTest/test/subbandstatistics/subbandstatistics_lbl-2.sh -text
-LCU/StationTest/test/subracktest/flash_tbb.sh -text
-LCU/StationTest/test/subracktest/flashsubrack.sh -text
-LCU/StationTest/test/subracktest/startonly.sh -text
-LCU/StationTest/test/subracktest/subrack_production.py -text
-LCU/StationTest/test/subracktest/testonly.sh -text
-LCU/StationTest/test/systemnoise/systemnoise_hba.sh -text
-LCU/StationTest/test/systemnoise/systemnoise_lbh.sh -text
-LCU/StationTest/test/timing/gps.sh -text
-LCU/StationTest/test/timing/ntpd.sh -text
-LCU/StationTest/test/timing/ntpd_restart.sh -text
-LCU/StationTest/test/timing/pps.sh -text
-LCU/StationTest/test/xcstatistics/waveform-generator-test.sh -text
-LCU/StationTest/test/xcstatistics/xcstatistics_hba.sh -text
-LCU/StationTest/test/xcstatistics/xcstatistics_hba_rcu192.sh -text
-LCU/StationTest/test/xcstatistics/xcstatistics_lba_rcu192.sh -text
-LCU/StationTest/test/xcstatistics/xcstatistics_lbh.sh -text
-LCU/StationTest/test/xcstatistics/xcstatistics_lbl.sh -text
-LCU/StationTest/verify.py -text
-LCU/StationTest/wgtest.sh -text
-LCU/StationTest/xc_160_setup.sh -text
-LCU/StationTest/xc_160_verify.sh -text
-LCU/StationTest/xc_200_setup.sh -text
-LCU/StationTest/xc_200_verify.sh -text
+LCU/StationTest/hbacontrol.txt eol=lf
+LCU/StationTest/i2c_spu.py eol=lf
+LCU/StationTest/i2c_td.py eol=lf
+LCU/StationTest/ledtest.sh eol=lf
+LCU/StationTest/modemlevel.sh eol=lf
+LCU/StationTest/modules/cli.py eol=lf
+LCU/StationTest/modules/mep.py eol=lf
+LCU/StationTest/modules/mmd_serdes.py eol=lf
+LCU/StationTest/modules/rsp.py eol=lf
+LCU/StationTest/modules/smbus.py eol=lf
+LCU/StationTest/modules/testcase.py eol=lf
+LCU/StationTest/modules/testlog.py eol=lf
+LCU/StationTest/power_ctrl.py eol=lf
+LCU/StationTest/prbs_dir_test.py eol=lf
+LCU/StationTest/prbs_test.py eol=lf
+LCU/StationTest/rad_status.py eol=lf
+LCU/StationTest/rcumodem.sh eol=lf
+LCU/StationTest/rmfiles.sh eol=lf
+LCU/StationTest/rsp_version.sh eol=lf
+LCU/StationTest/rsp_xc_160.sh eol=lf
+LCU/StationTest/rsp_xc_200.sh eol=lf
+LCU/StationTest/serdes.sh eol=lf
+LCU/StationTest/station_production.py eol=lf
+LCU/StationTest/subrack_production.py eol=lf
+LCU/StationTest/subrackplustest.sh eol=lf
+LCU/StationTest/subracktest.sh eol=lf
+LCU/StationTest/tbb_memory.sh eol=lf
+LCU/StationTest/tbb_prbs_tester.sh eol=lf
+LCU/StationTest/tbb_size.sh eol=lf
+LCU/StationTest/tbb_version.sh eol=lf
+LCU/StationTest/tc/bist.py eol=lf
+LCU/StationTest/tc/cdo_ctrl.py eol=lf
+LCU/StationTest/tc/cdo_settings.py eol=lf
+LCU/StationTest/tc/cdo_transport.py eol=lf
+LCU/StationTest/tc/empty.py eol=lf
+LCU/StationTest/tc/hba_client.py eol=lf
+LCU/StationTest/tc/hba_line_level.py eol=lf
+LCU/StationTest/tc/hba_server.py eol=lf
+LCU/StationTest/tc/prsg.py eol=lf
+LCU/StationTest/tc/rad_lanemode.py eol=lf
+LCU/StationTest/tc/rad_latency.py eol=lf
+LCU/StationTest/tc/read_serdes_phy.py eol=lf
+LCU/StationTest/tc/rsr_overwrite.py eol=lf
+LCU/StationTest/tc/serdes.py eol=lf
+LCU/StationTest/tc/spustat.py eol=lf
+LCU/StationTest/tc/status.py eol=lf
+LCU/StationTest/tc/sync_delay.py eol=lf
+LCU/StationTest/tc/tdstat.py eol=lf
+LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU192.sh eol=lf
+LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU96.sh eol=lf
+LCU/StationTest/test/beamformertest/beamformertest_LBA_RCU192.sh eol=lf
+LCU/StationTest/test/beamformertest/beamformertest_LBHLBL_RCU96.sh eol=lf
+LCU/StationTest/test/beamformertest/beamformertest_LBH_RCU96.sh eol=lf
+LCU/StationTest/test/beamformertest/beamformertest_LBL_RCU96.sh eol=lf
+LCU/StationTest/test/beamformertest/beamformertest_splitter.sh eol=lf
+LCU/StationTest/test/beamformertest/hba0_hba1_azel.sh eol=lf
+LCU/StationTest/test/envcontroltest/ecCtrl.py eol=lf
+LCU/StationTest/test/envcontroltest/eccontrol.py eol=lf
+LCU/StationTest/test/envcontroltest/power.py eol=lf
+LCU/StationTest/test/envcontroltest/stations.py eol=lf
+LCU/StationTest/test/hbatest/beamduur.sh eol=lf
+LCU/StationTest/test/hbatest/determinepeak.py eol=lf
+LCU/StationTest/test/hbatest/gold/hba_modem1.gold eol=lf
+LCU/StationTest/test/hbatest/gold/hba_modem2.gold eol=lf
+LCU/StationTest/test/hbatest/gold/hba_modem3.gold eol=lf
+LCU/StationTest/test/hbatest/hba_new_address.sh eol=lf
+LCU/StationTest/test/hbatest/hba_read_all.sh eol=lf
+LCU/StationTest/test/hbatest/hba_save_power.sh eol=lf
+LCU/StationTest/test/hbatest/hbaelementtest.py eol=lf
+LCU/StationTest/test/hbatest/hbaquicktest.py eol=lf
+LCU/StationTest/test/hbatest/modem_count.py eol=lf
+LCU/StationTest/test/hbatest/modemtest.sh eol=lf
+LCU/StationTest/test/subbandstatistics/subbandstatistics_hba-5.sh eol=lf
+LCU/StationTest/test/subbandstatistics/subbandstatistics_hba-6.sh eol=lf
+LCU/StationTest/test/subbandstatistics/subbandstatistics_hba-7.sh eol=lf
+LCU/StationTest/test/subbandstatistics/subbandstatistics_lbh-3.sh eol=lf
+LCU/StationTest/test/subbandstatistics/subbandstatistics_lbh-4.sh eol=lf
+LCU/StationTest/test/subbandstatistics/subbandstatistics_lbl-1.sh eol=lf
+LCU/StationTest/test/subbandstatistics/subbandstatistics_lbl-2.sh eol=lf
+LCU/StationTest/test/subracktest/flash_tbb.sh eol=lf
+LCU/StationTest/test/subracktest/flashsubrack.sh eol=lf
+LCU/StationTest/test/subracktest/startonly.sh eol=lf
+LCU/StationTest/test/subracktest/subrack_production.py eol=lf
+LCU/StationTest/test/subracktest/testonly.sh eol=lf
+LCU/StationTest/test/systemnoise/systemnoise_hba.sh eol=lf
+LCU/StationTest/test/systemnoise/systemnoise_lbh.sh eol=lf
+LCU/StationTest/test/timing/gps.sh eol=lf
+LCU/StationTest/test/timing/ntpd.sh eol=lf
+LCU/StationTest/test/timing/ntpd_restart.sh eol=lf
+LCU/StationTest/test/timing/pps.sh eol=lf
+LCU/StationTest/test/xcstatistics/waveform-generator-test.sh eol=lf
+LCU/StationTest/test/xcstatistics/xcstatistics_hba.sh eol=lf
+LCU/StationTest/test/xcstatistics/xcstatistics_hba_rcu192.sh eol=lf
+LCU/StationTest/test/xcstatistics/xcstatistics_lba_rcu192.sh eol=lf
+LCU/StationTest/test/xcstatistics/xcstatistics_lbh.sh eol=lf
+LCU/StationTest/test/xcstatistics/xcstatistics_lbl.sh eol=lf
+LCU/StationTest/verify.py eol=lf
+LCU/StationTest/wgtest.sh eol=lf
+LCU/StationTest/xc_160_setup.sh eol=lf
+LCU/StationTest/xc_160_verify.sh eol=lf
+LCU/StationTest/xc_200_setup.sh eol=lf
+LCU/StationTest/xc_200_verify.sh eol=lf
 MAC/APL/APLCommon/include/APL/APLCommon/AntennaField.h -text
 MAC/APL/APLCommon/src/AntennaField.cc -text
 MAC/APL/APLCommon/src/StartDaemon_Protocol.prot -text svneol=native#application/octet-stream
diff --git a/LCU/StationTest/README.txt b/LCU/StationTest/README.txt
index b8d3cb080514d95e6536589c5c64f15b99cf6f05..cb08910289894b6ca04412a02ea93848de225c88 100644
--- a/LCU/StationTest/README.txt
+++ b/LCU/StationTest/README.txt
@@ -1,404 +1,404 @@
-#
-# Test scripts for LOFAR station regression, production and operation tests.
-#
-
-################################################################################
-1) Introduction
-
-a) Purpose
-This test suite uses scripts that call rspctl and tbbctl to control a LOFAR
-station. Most scripts are written in Python. The test suite offers modules
-written in Python that allow easy access to rspctl and tbbctl, and that offer
-pass/fail handling and logging. The test scripts allow focussing on a typical
-function or interface of the station, therefore they can be used for:
-
-- regression tests (e.g. functional coverage tests)
-- production tests (e.g. chip interface, board interface tests)
-- stress tests (e.g. many HBA write, read accesses)
-- operation sanity tests
-
-b) Why Python?
-For tool interfacing TCL is the common script language, that is why the VHDL
-developent using Modelsim uses TCL scripts. The problem with the remote station
-TCL scripts is that they run under Windows using WinPCap to interface with the
-Ethernet card. TCL is platform independent, but there is no easy equivalent for
-WinPCAP under Linux. Hence it is not straigthforward to run the TCL testcases
-environment also under Linux on the LCU.
-Instead of using something like WinPCap the low level register access functions
---readblock and --writeblock were added to rspctl . This allows controlling the
-RSP board via scripts.
-Python was choosen as test script language, because it is a popular script
-language and adopted at various levels within the LOFAR software development,
-including operations. Based on my experience in translating TCL scripts into
-Python equivalents I think that Python is a more natural and nicer language than
-TCL.
-
-
-################################################################################
-2) Test setup
-
-a) Directory structure
-  ./ : README.txt, Python scripts, bash scripts. Run from this directory.
-  modules/ : Python modules
-  gold/ : Golden result files for corresponding scripts, 'diff *.log *.gold'
-          should yield no difference for the test to pass
-  tc/ : Testcase scripts to be used with verify.py
-  
-b) This test suite uses different types of test scripting:
-
-  - Testcase Python scripts in tc/ called via verify.py
-    . e.g.: tc/status.py, tc/bist.py, tc/prsg.py
-    . verify.py offers argument parsing, test result logging
-    . Resembles TCL testcase structure used for gateware development tests
-    . Most scripts in tc/ are direct (manual) translations of the TCL test
-      scripts that were used for the gateware (VHDL) development, see
-      LOFAR-ASTRON-MEM-186. The Python / rspctl test scripts run rather slow,
-      about a factor 2 slower than a comparable TCL / C test script.
-  - Stand alone Python scripts
-    . e.g.: python i2c_spu.py, i2c_td.py
-    . suitable for simple tests without argument passing
-    . test pass/fail and logging avaiable via testlog.py 
-  - BASH shell scripts
-    . e.g.: ./rsp_version.sh
-  
-  All these individual test scripts can be combined:
-  . e.g. for production test, regression test
-  . e.g. subracktest.sh
-   
-c) Environment setting
-
-  The scripts run from ./ The search path needs to be set:
-    export PYTHONPATH=./modules
-  or absolute path
-    export PYTHONPATH=/home/lofartest/ptest/modules
-  or to add the path
-    export PYTHONPATH=$PYTHONPATH:./modules
-  or on older systems
-    PYTHONPATH=$PYTHONPATH:./modules
-    export PYTHONPATH
-      
-  If rspctl is called then there must be a directory ../log/ for rspctl.log.
-  This ../log/ can be a symbolic link.
-  
-
-d) RSPDriver.conf
-
-To allow the 'rspctl --readblock' and 'rspctl --writeblock' low level access
-commands the RSP driver in /opt/lofar/etc/ must have:
-
-  RSPDriver.READ_RAW_DATA = 1
-  RSPDriver.WRITE_RAW_DATA = 1
-
-For tests that access the SPU or TDS, the RSP driver regular accesses via TDSH
-must be stopped via:
-
-  RSPDriver.READWRITE_TDSSTATUS=0
-
-
-################################################################################
-3) Test modules:
-
-cli.py      - Command line interface access
-verify.py   - Run one or more test scripts after parsing the arguments from the
-              command line
-testcase.py - Testcase pass/fail control, timing and logging for testcases that
-              run with verify.py
-testlog.py  - Similar to testcase.py, provides pass/fail control, timing and
-              logging for standalone test scripts like subrack_production.py
-mep.py      - MEP interface for RSP board access via 'rspctl --readblock/
-              rspctl --writeblock'
-rsp.py      - RSP board register access functions
-smbus.py    - SMBus (I2C) access functions
-
-
-Remarks:
-
-a) To see all script options (both general and test case specific) do:
-  
-  python verify.py --help
-
-   Remarks:
-   - via --brd a test can be ran for one RSP or multiple
-   - via --fpga a test can be ran on the BP, AP0, AP1, AP2, and/or AP3 in any
-     combination
-   - via --pol a test can be ran on RCU x and/or RCU y of the AP.
-   - There are 2 RCU per AP and 4 AP per RSP. In a station the RCUs are
-     numbered starting from 0:
-     
-       . RCU[0]  = (rsp0, blp0, x)
-       . RCU[1]  = (rsp0, blp0, y)
-       . RCU[2]  = (rsp0, blp1, x)
-       . RCU[3]  = (rsp0, blp1, y)
-       . RCU[4]  = (rsp0, blp2, x)
-       . RCU[5]  = (rsp0, blp2, y)
-       . RCU[6]  = (rsp0, blp3, x)
-       . RCU[7]  = (rsp0, blp3, y)
-       . RCU[8]  = (rsp1, blp0, x)
-       . RCU[9]  = (rsp1, blp0, y)
-       .
-       . etc
-       .
-       . RCU[64] = (rsp8, blp0, x)
-       . RCU[65] = (rsp8, blp0, y)
-       . RCU[66] = (rsp8, blp1, x)
-       . RCU[67] = (rsp8, blp1, y)
-       . RCU[68] = (rsp8, blp2, x)
-       . RCU[69] = (rsp8, blp2, y)
-       . RCU[70] = (rsp8, blp3, x)
-       . RCU[71] = (rsp8, blp3, y)
-       . RCU[72] = (rsp9, blp0, x)
-       . RCU[73] = (rsp9, blp0, y)
-       .
-       . etc
-       .
-  
-b) Classes:
-   - mep.py defines class MepMessage
-   - testcase.py defines class Testcase
-   - testlog.py defines class Testlog
-  The other modules cli.py, rsp.py and smbus.py define plain functions. Classes
-  are a nice way of grouping constants and functions to an object, for mep.py
-  the object it the message string that can be manipulated and access through
-  the class functions. Similar smbus.py could have been written as a class to
-  with the protocol_list and protocol_result as objects. I do not know what is
-  the best approach and why. With smbus.py as a plain set of functions it is 
-  also clear that the functions belong together, because they are called using
-  the module name as prefix.
-   
-c) The 'rspctl --readblock' and 'rspctl --writeblock' are quite slow, due to:
-   - the double buffering in the RSP driver
-   - maybe rspctl excepts only one access per pps interval
-   - the hex translations in mep.py to adhere to the format ot rspctl
-  For scripts that only use these low level peek and poke rspctl commands it
-  would be a great improvement to have a dedicated driver program that takes 
-  care of these low level commands. This may be a driver program or some C
-  functions that can be used directly in Python. The scripts can then remain as
-  they are, only a different mep.py module needs to be added.
-   
-d) Some scripts also use higher level rspctl commands, e.g. to set the RCU in
-   PSRG mode.
-   
-e) Typically all RSP access goes via functions in rsp.py and smbus.py. Hence in
-   a test script it should never be necessary to call the low level rspctl
-   commands directly.
-   
-f) I tried to follow the Python documentation rules. For example to read the
-   documentation in the module rsp.py do:
-
-   python
-   >>> import rsp
-   >>> dir(rsp)
-   >>> print rsp.__doc__
-   >>> print rsp.write_mem.__doc__
-
-g) When command line options are needed I use the Python option parser. For the
-   test scripts all command line options need to be defined in testcase.py.
-   There are some general test script options (e.g. --brd) but there are also
-   test script specific options (e.g. --pid). The general testcase options are
-   passed on via the Testcase class, the specific options are passed on as
-   directly and all get prefix 'arg_' in verify.py to easily recognize them.
-   
-h) For logging I followed the logging approach that was used for the RSP test
-   environment written in TCL. Python also has modules for logging thay may be
-   useful in future.
-   
-   
-################################################################################
-4) Test scripts in tc/
-
-a) The testcases in tc/ are ran using verify.py. The test results are reported
-   to the screen and also stored in tc/ in a *.log file with the same name. The
-   ammount of logging depends on the verbosity level set by option -v.
-   
-   To run a testcase with verify.py in ./ do:
-
-  python verify.py --brd rsp0 --fp blp0 --te tc/prsg.py -v 21
-  
-   To run a testcase for one subrack with 4 RSP do:
- 
-  python verify.py --brd rsp0,rsp1,rsp2,rsp3 --rep 1 -v 21 --te tc/serdes.py
-
-   To run a testcase for a station with three subracks, so 12 RSP do:
-
-  python verify.py --brd rsp0,rsp1,rsp2,rsp3,rsp4,rsp5,rsp6,rsp7,rsp8,rsp9,
-                         rsp10,rsp11 --te tc/serdes.py
-   
-  Remarks:
-  - The default option parameter values are defined in verify.py
-  - For options with multiple parameters the parameters must form one continuous
-    string seperated by commas's. 
-  
-b) The following test scripts are available in tc/, they are more or less plain,
-   manual translations from TCL test cases:
-
-  - empty.py           = empty, can be used to try verify.py
-  - cdo_ctrl.py        = Read or write the CTRL field in the CDO settings
-                         register
-  - prsg.py            = TC 5.10, capture RCU PSRG data
-  - serdes.py          = TC 3.8, serdes ring test
-  - read_serdes_phy.py = TC 8.3, read serdes PHY registers
-  - status.py          = TC 11.1, read RSP status register
-  - spustat.py         = TC 9.6, read SPU sensor status <=> 'rspctl --spustat'
-  - tdstat.py          = TC 9.1, read TD sensor status <=> 'rspctl --tdstat' 
-  - hba_client         = TC 5.42, read or write to a HBA client register at the
-                         RCU
-  - hba_server         = TC 5.43, read or write to a HBA server register at the
-                         tile
-  - rad_lanemode       = TC 5.24, write or read the lane mode for the SERDES
-                         lanes
-  - rad_latency        = TC 5.49, show latency of data frames on the SERDES
-                         lanes
-
-c) 'rspctl --readblock' and 'rspctl --writeblock'
-
-  If available high level rspctl options are used to set up things, e.g. like
-  the PRSG on an RCU. For other low level board control use the direct access
-  '--readblock' and '--writeblock' options of rspctl. The modules mep.py and
-  rsp.py provide easy interfacing with theses options.
-  
-d) For help on the testcase usage and options do:
-
-  python verify.py --help
-
-e) To delete temporary files do:
-
-  ./rmfiles.sh
-  
-f) Verbosity level (-v)
-  The testcases all adhere to the following verbosity level convention:
-   
-  -v  0 : show PASSED or FAILED
-  -v  1 : show testcase title
-  -v  2 : show testcase time
-  -v 11 : show '... went wrong' for each step or section in a testcase, plus
-          some more info like expected result and read result
-  -v 21 : show '... went OK' for each step or section in a testcase
-  -v 22 : show rspctl commands
-  -v 23 : show rspctl command return results
-	   
-g) Pass/fail
-  Default a testcase run using verify.py/testcase.py (or using testlog.py) gets
-  pass/fail status 'RUNONLY'. This is useful for test scripts that are
-  utilities. If the testcase checks for expected results then it one of the it 
-  should first initialized the tc result to 'PASSED'. Subsequently each step in
-  the testcase that fails should also set the tc result to 'FAILED'. Once the
-  tc status is 'FAILED' it can not change anymore.
-   
-h) Test scripts and the RSP driver
-  The test scripts use rspctl. Some test scripts do not affect the functional
-  behaviour of the RSP driver, however many scripts do. Due to the slow and 
-  asynchronlous behaviour of teh test scripts it is often handy to disable the
-  external sync (pps). The scripts also enable the external sync again, but 
-  if that does not recover normal rspctl behaviour then it may be necessary to
-  do a 'rspctl --rspclear' or restart the RSP driver via swlevel 1, swlevel 2.
-   
-   
-################################################################################
-5) More examples
-
-a) HBA client access
-  To read the speed register of HBA client on RCU[65] do:
-   
-  python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py
-                      --client_access r --client_reg speed --data 1
-
-  The test will only signal pass if the --data value equals the read speed
-  value, hence for read the --data option is used as expected result.
-
-b) HBA server access
-  To manage the HBA server addresses use:
-  
-  test/hbatest/hba_read_all.sh            # to read all servers in a HBA tile
-  test/hbatest/hba_new_address.sh         # to change a HBA server address
-  
-  These shell scripts use tc/hba_server.py. More examples:
-  
-  To read the delay settings for polarization X and Y of HBA server 2 on the 
-  HBA tile of RCU[64]=X (power via X) and RCU[65]=Y (control via Y) do:
-  
- python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py
-                  --server 2 --server_access uc --server_function gw
-		  --server_reg delay_x --data 50,51
-	
-  To change the default server address 127 to operational server address # in
-  1-16 range, first be sure to set a free address, otherwise two servers in the
-  tile will have the same address and can not be controlled remotely anymore.
-  Use the following command to check whether server # = 1, 2, ... 16, or 127
-  exists in the tile on RSP 8, BLP 0:
-
- python verify.py --brd rsp8 --fp blp0 -v 21 --te tc/hba_server.py
-                  --server # --server_access uc --server_function gb
-                  --server_reg address --data #
-
-  Then use the following command to change the default server address into #:
-  
- python verify.py --brd rsp8 --fp blp0 -v 21 --te tc/hba_server.py
-                  --server 127 --server_access uc --server_function sb
-		              --server_reg address --data #
-		              
-		  
-c) Read version nummers of station hardware, firmware and software:
-  - The RSP board version and BP and AP firmware versions: 'rspctl --version'.
-  - The RSP CPLD CP firmware version: 'tc/status.py --pid rsu'.
-    Should be version 3 (although 2 probably also works). Version 3 reveals
-    what caused the RSP board to reset (e.g. user, watchdog, overtemperature).
-  - The RCU firmware version: 'rspctl --rcu'.
-    The version number is given by the most significant nibble in the control
-    word "RCU[ 0].control=0x10057980". Shouls be 1 for RCUs with the I2C
-    problem of bug 1111 solved. This fix also implies that the I2C to the RCU
-    requires an active system clock (160 or 200 MHz). For I2C access to the
-    HBA client the system clock is not used.
-  - HBA client software version (old HBA software does not have a version
-    register): 'tc/hba_client.py --client_access r --client_reg version
-    --data 10' --> should be version 10.
-  - HBA server software version (old HBA software does not have a version
-    register) for all 1-16 servers: 'tc/hba_server.py --server 1
-    --server_access uc --server_reg version --server_func gb --data 10'
-    --> should be version 10.
-
-d) Useful tests for monitoring the data on the serdes ring between the RSP
-   boards (carries the crosslets for the XST and the beamlets for CDO):
-   
-   - 'rspctl --rcumode=3', 'rspctl --xcsubband=256', 'rspctl --xcstat' and/or
-     'rspctl --xcstat --xcangle' --> Should yield an smooth, noisy XST matrix
-     with autocorrelation diagonal.
-   - 'tc/rad_latency.py' --> Shows how the arrival delay in number of samples
-     for the crosslet and beamlet packets at each subsequent RSP board.
-   - 'tc/rad_lanemode.py --read' --> Reads the lane mode settings, this 
-     corresponds to the beamlet and crosslet out settings in RSP_Driver.conf.
-   - 'tc/status.py --pid rad' --> Shows whether no data packets go lost on the
-     serdes ring and whether the data streams from the local AP and the
-     preceding RSP are aligned.
-   - 'tc/read_serdes_phy.py --data 16,18,20,21,22,23' --> for multiple RSP read
-     the redundant ring registers to diagnose in case serdes.py fails.
-
-e) Clock and PPS can also affect the XST:
-   - 'tc/serdes.py --diag_sync 0' --> Uses the PPS to start and stop the
-     test, so implicitely it verifies that the PPS from the Rubidium is OK.
-   - The diff in 'rspctl --status' should be fixed (or +0, +512 at 200 MHz). 
-     Same as ext_cnt in 'tc/status.py --pid bs'. If it drifts then the XO
-     on the TDS clock board is free running, i.e. the PLL on the TDS clock
-     board is not (always) in lock.
-   - 'rspctl --tdstat' shows whether the PLL on the clock board is in lock.
-     However, this is based on a single measurement read via I2C. The PLL could
-     in fact loose and reaquire lock regular basis.
-
-
-################################################################################
-6) Standalone test scripts
-
-a) Subrack production tests
-
-The Python script subrack_production.py runs the subrack production test, it 
-requires a batch nr and a serial nr that will be used to name the log file.
-
-  python subrack_production.py --help
-  python subrack_production.py -b 3 -s 2
-
-This subrack_production.py replaces subracktest.sh.
-
-b) Various
-
-  i2c_spu.py = uses 'rspctl --spustat' to verify SPU sensor status
-  i2c_td.py  = uses 'rspctl --spustat' to verify TDS sensor status
-
+#
+# Test scripts for LOFAR station regression, production and operation tests.
+#
+
+################################################################################
+1) Introduction
+
+a) Purpose
+This test suite uses scripts that call rspctl and tbbctl to control a LOFAR
+station. Most scripts are written in Python. The test suite offers modules
+written in Python that allow easy access to rspctl and tbbctl, and that offer
+pass/fail handling and logging. The test scripts allow focussing on a typical
+function or interface of the station, therefore they can be used for:
+
+- regression tests (e.g. functional coverage tests)
+- production tests (e.g. chip interface, board interface tests)
+- stress tests (e.g. many HBA write, read accesses)
+- operation sanity tests
+
+b) Why Python?
+For tool interfacing TCL is the common script language, that is why the VHDL
+developent using Modelsim uses TCL scripts. The problem with the remote station
+TCL scripts is that they run under Windows using WinPCap to interface with the
+Ethernet card. TCL is platform independent, but there is no easy equivalent for
+WinPCAP under Linux. Hence it is not straigthforward to run the TCL testcases
+environment also under Linux on the LCU.
+Instead of using something like WinPCap the low level register access functions
+--readblock and --writeblock were added to rspctl . This allows controlling the
+RSP board via scripts.
+Python was choosen as test script language, because it is a popular script
+language and adopted at various levels within the LOFAR software development,
+including operations. Based on my experience in translating TCL scripts into
+Python equivalents I think that Python is a more natural and nicer language than
+TCL.
+
+
+################################################################################
+2) Test setup
+
+a) Directory structure
+  ./ : README.txt, Python scripts, bash scripts. Run from this directory.
+  modules/ : Python modules
+  gold/ : Golden result files for corresponding scripts, 'diff *.log *.gold'
+          should yield no difference for the test to pass
+  tc/ : Testcase scripts to be used with verify.py
+  
+b) This test suite uses different types of test scripting:
+
+  - Testcase Python scripts in tc/ called via verify.py
+    . e.g.: tc/status.py, tc/bist.py, tc/prsg.py
+    . verify.py offers argument parsing, test result logging
+    . Resembles TCL testcase structure used for gateware development tests
+    . Most scripts in tc/ are direct (manual) translations of the TCL test
+      scripts that were used for the gateware (VHDL) development, see
+      LOFAR-ASTRON-MEM-186. The Python / rspctl test scripts run rather slow,
+      about a factor 2 slower than a comparable TCL / C test script.
+  - Stand alone Python scripts
+    . e.g.: python i2c_spu.py, i2c_td.py
+    . suitable for simple tests without argument passing
+    . test pass/fail and logging avaiable via testlog.py 
+  - BASH shell scripts
+    . e.g.: ./rsp_version.sh
+  
+  All these individual test scripts can be combined:
+  . e.g. for production test, regression test
+  . e.g. subracktest.sh
+   
+c) Environment setting
+
+  The scripts run from ./ The search path needs to be set:
+    export PYTHONPATH=./modules
+  or absolute path
+    export PYTHONPATH=/home/lofartest/ptest/modules
+  or to add the path
+    export PYTHONPATH=$PYTHONPATH:./modules
+  or on older systems
+    PYTHONPATH=$PYTHONPATH:./modules
+    export PYTHONPATH
+      
+  If rspctl is called then there must be a directory ../log/ for rspctl.log.
+  This ../log/ can be a symbolic link.
+  
+
+d) RSPDriver.conf
+
+To allow the 'rspctl --readblock' and 'rspctl --writeblock' low level access
+commands the RSP driver in /opt/lofar/etc/ must have:
+
+  RSPDriver.READ_RAW_DATA = 1
+  RSPDriver.WRITE_RAW_DATA = 1
+
+For tests that access the SPU or TDS, the RSP driver regular accesses via TDSH
+must be stopped via:
+
+  RSPDriver.READWRITE_TDSSTATUS=0
+
+
+################################################################################
+3) Test modules:
+
+cli.py      - Command line interface access
+verify.py   - Run one or more test scripts after parsing the arguments from the
+              command line
+testcase.py - Testcase pass/fail control, timing and logging for testcases that
+              run with verify.py
+testlog.py  - Similar to testcase.py, provides pass/fail control, timing and
+              logging for standalone test scripts like subrack_production.py
+mep.py      - MEP interface for RSP board access via 'rspctl --readblock/
+              rspctl --writeblock'
+rsp.py      - RSP board register access functions
+smbus.py    - SMBus (I2C) access functions
+
+
+Remarks:
+
+a) To see all script options (both general and test case specific) do:
+  
+  python verify.py --help
+
+   Remarks:
+   - via --brd a test can be ran for one RSP or multiple
+   - via --fpga a test can be ran on the BP, AP0, AP1, AP2, and/or AP3 in any
+     combination
+   - via --pol a test can be ran on RCU x and/or RCU y of the AP.
+   - There are 2 RCU per AP and 4 AP per RSP. In a station the RCUs are
+     numbered starting from 0:
+     
+       . RCU[0]  = (rsp0, blp0, x)
+       . RCU[1]  = (rsp0, blp0, y)
+       . RCU[2]  = (rsp0, blp1, x)
+       . RCU[3]  = (rsp0, blp1, y)
+       . RCU[4]  = (rsp0, blp2, x)
+       . RCU[5]  = (rsp0, blp2, y)
+       . RCU[6]  = (rsp0, blp3, x)
+       . RCU[7]  = (rsp0, blp3, y)
+       . RCU[8]  = (rsp1, blp0, x)
+       . RCU[9]  = (rsp1, blp0, y)
+       .
+       . etc
+       .
+       . RCU[64] = (rsp8, blp0, x)
+       . RCU[65] = (rsp8, blp0, y)
+       . RCU[66] = (rsp8, blp1, x)
+       . RCU[67] = (rsp8, blp1, y)
+       . RCU[68] = (rsp8, blp2, x)
+       . RCU[69] = (rsp8, blp2, y)
+       . RCU[70] = (rsp8, blp3, x)
+       . RCU[71] = (rsp8, blp3, y)
+       . RCU[72] = (rsp9, blp0, x)
+       . RCU[73] = (rsp9, blp0, y)
+       .
+       . etc
+       .
+  
+b) Classes:
+   - mep.py defines class MepMessage
+   - testcase.py defines class Testcase
+   - testlog.py defines class Testlog
+  The other modules cli.py, rsp.py and smbus.py define plain functions. Classes
+  are a nice way of grouping constants and functions to an object, for mep.py
+  the object it the message string that can be manipulated and access through
+  the class functions. Similar smbus.py could have been written as a class to
+  with the protocol_list and protocol_result as objects. I do not know what is
+  the best approach and why. With smbus.py as a plain set of functions it is 
+  also clear that the functions belong together, because they are called using
+  the module name as prefix.
+   
+c) The 'rspctl --readblock' and 'rspctl --writeblock' are quite slow, due to:
+   - the double buffering in the RSP driver
+   - maybe rspctl excepts only one access per pps interval
+   - the hex translations in mep.py to adhere to the format ot rspctl
+  For scripts that only use these low level peek and poke rspctl commands it
+  would be a great improvement to have a dedicated driver program that takes 
+  care of these low level commands. This may be a driver program or some C
+  functions that can be used directly in Python. The scripts can then remain as
+  they are, only a different mep.py module needs to be added.
+   
+d) Some scripts also use higher level rspctl commands, e.g. to set the RCU in
+   PSRG mode.
+   
+e) Typically all RSP access goes via functions in rsp.py and smbus.py. Hence in
+   a test script it should never be necessary to call the low level rspctl
+   commands directly.
+   
+f) I tried to follow the Python documentation rules. For example to read the
+   documentation in the module rsp.py do:
+
+   python
+   >>> import rsp
+   >>> dir(rsp)
+   >>> print rsp.__doc__
+   >>> print rsp.write_mem.__doc__
+
+g) When command line options are needed I use the Python option parser. For the
+   test scripts all command line options need to be defined in testcase.py.
+   There are some general test script options (e.g. --brd) but there are also
+   test script specific options (e.g. --pid). The general testcase options are
+   passed on via the Testcase class, the specific options are passed on as
+   directly and all get prefix 'arg_' in verify.py to easily recognize them.
+   
+h) For logging I followed the logging approach that was used for the RSP test
+   environment written in TCL. Python also has modules for logging thay may be
+   useful in future.
+   
+   
+################################################################################
+4) Test scripts in tc/
+
+a) The testcases in tc/ are ran using verify.py. The test results are reported
+   to the screen and also stored in tc/ in a *.log file with the same name. The
+   ammount of logging depends on the verbosity level set by option -v.
+   
+   To run a testcase with verify.py in ./ do:
+
+  python verify.py --brd rsp0 --fp blp0 --te tc/prsg.py -v 21
+  
+   To run a testcase for one subrack with 4 RSP do:
+ 
+  python verify.py --brd rsp0,rsp1,rsp2,rsp3 --rep 1 -v 21 --te tc/serdes.py
+
+   To run a testcase for a station with three subracks, so 12 RSP do:
+
+  python verify.py --brd rsp0,rsp1,rsp2,rsp3,rsp4,rsp5,rsp6,rsp7,rsp8,rsp9,
+                         rsp10,rsp11 --te tc/serdes.py
+   
+  Remarks:
+  - The default option parameter values are defined in verify.py
+  - For options with multiple parameters the parameters must form one continuous
+    string seperated by commas's. 
+  
+b) The following test scripts are available in tc/, they are more or less plain,
+   manual translations from TCL test cases:
+
+  - empty.py           = empty, can be used to try verify.py
+  - cdo_ctrl.py        = Read or write the CTRL field in the CDO settings
+                         register
+  - prsg.py            = TC 5.10, capture RCU PSRG data
+  - serdes.py          = TC 3.8, serdes ring test
+  - read_serdes_phy.py = TC 8.3, read serdes PHY registers
+  - status.py          = TC 11.1, read RSP status register
+  - spustat.py         = TC 9.6, read SPU sensor status <=> 'rspctl --spustat'
+  - tdstat.py          = TC 9.1, read TD sensor status <=> 'rspctl --tdstat' 
+  - hba_client         = TC 5.42, read or write to a HBA client register at the
+                         RCU
+  - hba_server         = TC 5.43, read or write to a HBA server register at the
+                         tile
+  - rad_lanemode       = TC 5.24, write or read the lane mode for the SERDES
+                         lanes
+  - rad_latency        = TC 5.49, show latency of data frames on the SERDES
+                         lanes
+
+c) 'rspctl --readblock' and 'rspctl --writeblock'
+
+  If available high level rspctl options are used to set up things, e.g. like
+  the PRSG on an RCU. For other low level board control use the direct access
+  '--readblock' and '--writeblock' options of rspctl. The modules mep.py and
+  rsp.py provide easy interfacing with theses options.
+  
+d) For help on the testcase usage and options do:
+
+  python verify.py --help
+
+e) To delete temporary files do:
+
+  ./rmfiles.sh
+  
+f) Verbosity level (-v)
+  The testcases all adhere to the following verbosity level convention:
+   
+  -v  0 : show PASSED or FAILED
+  -v  1 : show testcase title
+  -v  2 : show testcase time
+  -v 11 : show '... went wrong' for each step or section in a testcase, plus
+          some more info like expected result and read result
+  -v 21 : show '... went OK' for each step or section in a testcase
+  -v 22 : show rspctl commands
+  -v 23 : show rspctl command return results
+	   
+g) Pass/fail
+  Default a testcase run using verify.py/testcase.py (or using testlog.py) gets
+  pass/fail status 'RUNONLY'. This is useful for test scripts that are
+  utilities. If the testcase checks for expected results then it one of the it 
+  should first initialized the tc result to 'PASSED'. Subsequently each step in
+  the testcase that fails should also set the tc result to 'FAILED'. Once the
+  tc status is 'FAILED' it can not change anymore.
+   
+h) Test scripts and the RSP driver
+  The test scripts use rspctl. Some test scripts do not affect the functional
+  behaviour of the RSP driver, however many scripts do. Due to the slow and 
+  asynchronlous behaviour of teh test scripts it is often handy to disable the
+  external sync (pps). The scripts also enable the external sync again, but 
+  if that does not recover normal rspctl behaviour then it may be necessary to
+  do a 'rspctl --rspclear' or restart the RSP driver via swlevel 1, swlevel 2.
+   
+   
+################################################################################
+5) More examples
+
+a) HBA client access
+  To read the speed register of HBA client on RCU[65] do:
+   
+  python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py
+                      --client_access r --client_reg speed --data 1
+
+  The test will only signal pass if the --data value equals the read speed
+  value, hence for read the --data option is used as expected result.
+
+b) HBA server access
+  To manage the HBA server addresses use:
+  
+  test/hbatest/hba_read_all.sh            # to read all servers in a HBA tile
+  test/hbatest/hba_new_address.sh         # to change a HBA server address
+  
+  These shell scripts use tc/hba_server.py. More examples:
+  
+  To read the delay settings for polarization X and Y of HBA server 2 on the 
+  HBA tile of RCU[64]=X (power via X) and RCU[65]=Y (control via Y) do:
+  
+ python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py
+                  --server 2 --server_access uc --server_function gw
+		  --server_reg delay_x --data 50,51
+	
+  To change the default server address 127 to operational server address # in
+  1-16 range, first be sure to set a free address, otherwise two servers in the
+  tile will have the same address and can not be controlled remotely anymore.
+  Use the following command to check whether server # = 1, 2, ... 16, or 127
+  exists in the tile on RSP 8, BLP 0:
+
+ python verify.py --brd rsp8 --fp blp0 -v 21 --te tc/hba_server.py
+                  --server # --server_access uc --server_function gb
+                  --server_reg address --data #
+
+  Then use the following command to change the default server address into #:
+  
+ python verify.py --brd rsp8 --fp blp0 -v 21 --te tc/hba_server.py
+                  --server 127 --server_access uc --server_function sb
+		              --server_reg address --data #
+		              
+		  
+c) Read version nummers of station hardware, firmware and software:
+  - The RSP board version and BP and AP firmware versions: 'rspctl --version'.
+  - The RSP CPLD CP firmware version: 'tc/status.py --pid rsu'.
+    Should be version 3 (although 2 probably also works). Version 3 reveals
+    what caused the RSP board to reset (e.g. user, watchdog, overtemperature).
+  - The RCU firmware version: 'rspctl --rcu'.
+    The version number is given by the most significant nibble in the control
+    word "RCU[ 0].control=0x10057980". Shouls be 1 for RCUs with the I2C
+    problem of bug 1111 solved. This fix also implies that the I2C to the RCU
+    requires an active system clock (160 or 200 MHz). For I2C access to the
+    HBA client the system clock is not used.
+  - HBA client software version (old HBA software does not have a version
+    register): 'tc/hba_client.py --client_access r --client_reg version
+    --data 10' --> should be version 10.
+  - HBA server software version (old HBA software does not have a version
+    register) for all 1-16 servers: 'tc/hba_server.py --server 1
+    --server_access uc --server_reg version --server_func gb --data 10'
+    --> should be version 10.
+
+d) Useful tests for monitoring the data on the serdes ring between the RSP
+   boards (carries the crosslets for the XST and the beamlets for CDO):
+   
+   - 'rspctl --rcumode=3', 'rspctl --xcsubband=256', 'rspctl --xcstat' and/or
+     'rspctl --xcstat --xcangle' --> Should yield an smooth, noisy XST matrix
+     with autocorrelation diagonal.
+   - 'tc/rad_latency.py' --> Shows how the arrival delay in number of samples
+     for the crosslet and beamlet packets at each subsequent RSP board.
+   - 'tc/rad_lanemode.py --read' --> Reads the lane mode settings, this 
+     corresponds to the beamlet and crosslet out settings in RSP_Driver.conf.
+   - 'tc/status.py --pid rad' --> Shows whether no data packets go lost on the
+     serdes ring and whether the data streams from the local AP and the
+     preceding RSP are aligned.
+   - 'tc/read_serdes_phy.py --data 16,18,20,21,22,23' --> for multiple RSP read
+     the redundant ring registers to diagnose in case serdes.py fails.
+
+e) Clock and PPS can also affect the XST:
+   - 'tc/serdes.py --diag_sync 0' --> Uses the PPS to start and stop the
+     test, so implicitely it verifies that the PPS from the Rubidium is OK.
+   - The diff in 'rspctl --status' should be fixed (or +0, +512 at 200 MHz). 
+     Same as ext_cnt in 'tc/status.py --pid bs'. If it drifts then the XO
+     on the TDS clock board is free running, i.e. the PLL on the TDS clock
+     board is not (always) in lock.
+   - 'rspctl --tdstat' shows whether the PLL on the clock board is in lock.
+     However, this is based on a single measurement read via I2C. The PLL could
+     in fact loose and reaquire lock regular basis.
+
+
+################################################################################
+6) Standalone test scripts
+
+a) Subrack production tests
+
+The Python script subrack_production.py runs the subrack production test, it 
+requires a batch nr and a serial nr that will be used to name the log file.
+
+  python subrack_production.py --help
+  python subrack_production.py -b 3 -s 2
+
+This subrack_production.py replaces subracktest.sh.
+
+b) Various
+
+  i2c_spu.py = uses 'rspctl --spustat' to verify SPU sensor status
+  i2c_td.py  = uses 'rspctl --spustat' to verify TDS sensor status
+
diff --git a/LCU/StationTest/hbacontrol.txt b/LCU/StationTest/hbacontrol.txt
index 7844ce1a59e8f646aec833e672a9699fd2455e0c..d2982ac4db23665fb8fe01dd999ba32e1d0a34ed 100644
--- a/LCU/StationTest/hbacontrol.txt
+++ b/LCU/StationTest/hbacontrol.txt
@@ -1,56 +1,56 @@
-#################################################################################################################################
-# options  testcase 5.42 Write and readback HBA client registers (RCU)
-# client_rcu  x or y
-# client_acces r or w or wr
-# client_reg request, response, led, vref, version, speed
-# data ..
-#################################################################################################################################
-
-# HBA LED RCU modem on (client) 
-python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py --client_acces w --client_reg led --data 01
-
-# HBA LED RCU modem off (client)
-python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py --client_acces w --client_reg led --data 00
-
-# HBA read LED response register (client)
-python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py --client_acces r --client_reg led 
-response [0,1,0,0] led on
-response [0,0,0,0] led off
-
-# HBA read LED response register (client)
-python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py --client_acces r --client_reg version
-response  [0,1,0,0] (5V version modem) RCU 65,67,69,71,73
-response  [0,2,0,0] (5V version modem) RCU 75,81,89
-response  [0,10,0,0] (3.3V version modem) RCU 6,7 testrack Dwingeloo
-
-#################################################################################################################################
-# options  testcase 5.43 Write and readback HBA server registers (HBA FE) 
-# client_rcu   x or y
-# server       first,last
-# server_acces bc, uc
-# server_func  gb,gw,sb,sw (get byte,word or set byte,word)
-# server_reg   delay_x,delay_y,version,address
-# data         ....
-# count        use counter data for data
-# rand         use random data for data
-#################################################################################################################################
-
-# HBA read version number HBA FE (server)
-python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py --server 2 --server_acces uc --server_reg version
-response [0,0,0,0,130,2,3,0,0]   (128 + server = 128+2=130)  version=3
-response [0,0,0,0,130,2,10,0,0]  (128 + server = 128+2=130)  version=10
-
-# HBA read delay x y from HBA FE element 2(server)
-# rspctl --hbadelays=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 --sel=64,65
-python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py --server 2 --server_acces uc --server_function gw
-response [0,0,0,0,address+2,3,X-delay,Y-delay,0,0]
-response [0,0,0,0,130,3,2,2,0,0]   (128 + server = 128+2=130)  X-delay=2 Y-delay=2
-
-# HBA write delay x y in HBA FE element 2(server)
-# the value 55 and 56 on element 2 (RCU 64,65)
-python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py --server 2 --server_acces uc --server_function sw --data 55,56
-verify rspctl --realdelays --sel=64,65 (wrong result!!!)
-or above read function server
-
-# HBA change default FE address 127 into #
-python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py --server 127 --server_acces uc --server_function sb --server_reg address --data #
+#################################################################################################################################
+# options  testcase 5.42 Write and readback HBA client registers (RCU)
+# client_rcu  x or y
+# client_acces r or w or wr
+# client_reg request, response, led, vref, version, speed
+# data ..
+#################################################################################################################################
+
+# HBA LED RCU modem on (client) 
+python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py --client_acces w --client_reg led --data 01
+
+# HBA LED RCU modem off (client)
+python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py --client_acces w --client_reg led --data 00
+
+# HBA read LED response register (client)
+python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py --client_acces r --client_reg led 
+response [0,1,0,0] led on
+response [0,0,0,0] led off
+
+# HBA read LED response register (client)
+python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_client.py --client_acces r --client_reg version
+response  [0,1,0,0] (5V version modem) RCU 65,67,69,71,73
+response  [0,2,0,0] (5V version modem) RCU 75,81,89
+response  [0,10,0,0] (3.3V version modem) RCU 6,7 testrack Dwingeloo
+
+#################################################################################################################################
+# options  testcase 5.43 Write and readback HBA server registers (HBA FE) 
+# client_rcu   x or y
+# server       first,last
+# server_acces bc, uc
+# server_func  gb,gw,sb,sw (get byte,word or set byte,word)
+# server_reg   delay_x,delay_y,version,address
+# data         ....
+# count        use counter data for data
+# rand         use random data for data
+#################################################################################################################################
+
+# HBA read version number HBA FE (server)
+python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py --server 2 --server_acces uc --server_reg version
+response [0,0,0,0,130,2,3,0,0]   (128 + server = 128+2=130)  version=3
+response [0,0,0,0,130,2,10,0,0]  (128 + server = 128+2=130)  version=10
+
+# HBA read delay x y from HBA FE element 2(server)
+# rspctl --hbadelays=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 --sel=64,65
+python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py --server 2 --server_acces uc --server_function gw
+response [0,0,0,0,address+2,3,X-delay,Y-delay,0,0]
+response [0,0,0,0,130,3,2,2,0,0]   (128 + server = 128+2=130)  X-delay=2 Y-delay=2
+
+# HBA write delay x y in HBA FE element 2(server)
+# the value 55 and 56 on element 2 (RCU 64,65)
+python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py --server 2 --server_acces uc --server_function sw --data 55,56
+verify rspctl --realdelays --sel=64,65 (wrong result!!!)
+or above read function server
+
+# HBA change default FE address 127 into #
+python verify.py --brd rsp8 --fp blp0 --rep 1 -v 21 --te tc/hba_server.py --server 127 --server_acces uc --server_function sb --server_reg address --data #
diff --git a/LCU/StationTest/rcumodem.sh b/LCU/StationTest/rcumodem.sh
index e88e112b13e1316538a917d564640d92ddced069..7970dedff14c2be35862fe9c9b2f6af1cf997093 100644
--- a/LCU/StationTest/rcumodem.sh
+++ b/LCU/StationTest/rcumodem.sh
@@ -1,9 +1,9 @@
-#!/bin/bash
-#
-# check the modem software version of the receiver unit.
-# 4-3-10, M.J.Norden
-
-
-echo "The modemtest"  
-sleep 2
-python verify.py --brd rsp0,rsp1,rsp2,rsp3,rsp4,rsp5,rsp6,rsp7,rsp8,rsp9,rsp10,rsp11 --fpga blp0,blp1,blp2,blp3 --te tc/hba_client.py --client_acces r --client_reg version --data 10
+#!/bin/bash
+#
+# check the modem software version of the receiver unit.
+# 4-3-10, M.J.Norden
+
+
+echo "The modemtest"  
+sleep 2
+python verify.py --brd rsp0,rsp1,rsp2,rsp3,rsp4,rsp5,rsp6,rsp7,rsp8,rsp9,rsp10,rsp11 --fpga blp0,blp1,blp2,blp3 --te tc/hba_client.py --client_acces r --client_reg version --data 10
diff --git a/LCU/StationTest/rsp_version.sh b/LCU/StationTest/rsp_version.sh
index f48d536cb60effd82815d44b78c2c43bb2109e09..2af41375db4ff2dc995b93c2eb7d882863d93a5f 100755
--- a/LCU/StationTest/rsp_version.sh
+++ b/LCU/StationTest/rsp_version.sh
@@ -1,31 +1,31 @@
-#!/bin/bash
-#
-# Get version info from the RSP boards and compare this with the expected golden result.
-#
-# Modified voor INT stations, M.J.Norden 14-10-2010
-
-let rspboards=`sed -n  's/^\s*RS\.N_RSPBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
-
-rm -f rsp_version*.log
-rm -f rsp_version*.diff
-rspctl --version > rsp_version.log
-
-if [ $rspboards == 12 ]; then
-     # This is a NL station
-     diff rsp_version.log gold/rsp_version.gold > rsp_version.diff
-     if [ -e rsp_version.log ] && [ -e gold/rsp_version.gold ] && [ -e rsp_version.diff ] && ! [ -s rsp_version.diff ]; then
-     # The files exists AND the diff has size 0
-         echo "RSP version test went OK"
-     else
-         echo "RSP version test went wrong"
-     fi
-else
-     # This is a INT station
-     diff rsp_version.log gold/rsp_version_int.gold > rsp_version_int.diff
-     if [ -e rsp_version.log ] && [ -e gold/rsp_version_int.gold ] && [ -e rsp_version_int.diff ] && ! [ -s rsp_version_int.diff ]; then
-     # The files exists AND the diff has size 0
-         echo "RSP version test went OK"
-     else
-         echo "RSP version test went wrong"
-     fi
+#!/bin/bash
+#
+# Get version info from the RSP boards and compare this with the expected golden result.
+#
+# Modified voor INT stations, M.J.Norden 14-10-2010
+
+let rspboards=`sed -n  's/^\s*RS\.N_RSPBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
+
+rm -f rsp_version*.log
+rm -f rsp_version*.diff
+rspctl --version > rsp_version.log
+
+if [ $rspboards == 12 ]; then
+     # This is a NL station
+     diff rsp_version.log gold/rsp_version.gold > rsp_version.diff
+     if [ -e rsp_version.log ] && [ -e gold/rsp_version.gold ] && [ -e rsp_version.diff ] && ! [ -s rsp_version.diff ]; then
+     # The files exists AND the diff has size 0
+         echo "RSP version test went OK"
+     else
+         echo "RSP version test went wrong"
+     fi
+else
+     # This is a INT station
+     diff rsp_version.log gold/rsp_version_int.gold > rsp_version_int.diff
+     if [ -e rsp_version.log ] && [ -e gold/rsp_version_int.gold ] && [ -e rsp_version_int.diff ] && ! [ -s rsp_version_int.diff ]; then
+     # The files exists AND the diff has size 0
+         echo "RSP version test went OK"
+     else
+         echo "RSP version test went wrong"
+     fi
 fi
\ No newline at end of file
diff --git a/LCU/StationTest/tbb_prbs_tester.sh b/LCU/StationTest/tbb_prbs_tester.sh
index ca1d254275390456b483e54c8d0ad4cf1c01f3c8..0c87880d0f4d19c6d25ff36e7431d2f87c976b39 100755
--- a/LCU/StationTest/tbb_prbs_tester.sh
+++ b/LCU/StationTest/tbb_prbs_tester.sh
@@ -1,67 +1,67 @@
-#!/bin/bash
-
-#
-# Test the LVDS interfaces between RCU -> RSP -> TBB using the Pseudo Random generator in the RCUs.
-#
-# Modified for INT station 14-10-2010 M.J.Norden
-
-
-let rspboards=`sed -n  's/^\s*RS\.N_RSPBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
-let tbboards=`sed -n  's/^\s*RS\.N_TBBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
-let nof_rcu=8*$rspboards
-
-rm -f prbs_dir*.log
-rm -f prbs_dir*.diff
-rm -f ./prbs/*.*
-rm -r ./prbs/.svn
-
-
-# Set up RCU and RSP, make sure waveform generator is off
-rspctl --rcuprsg=1
-sleep 2
-rspctl --tbbmode=transient
-sleep 1
-rspctl --rcuenable=1
-
-sleep 5
-# set up TBB
-nof_slices=10   # one slice contains 1024 transient (raw data) samples
-
-tbbctl --free
-tbbctl --alloc
-tbbctl --rec
-
-sleep 1
-
-# Freeze and get the captured data from TBB
-cd ./prbs
-tbbctl --stop
-for ((i = 0; i < $nof_rcu; i++)) do
-  tbbctl --readpage=$i,0,$nof_slices
-done
-cd ..
-# Verify the PRBS
-python prbs_dir_test.py
-rspctl --rcuprsg=0
-
-if [ $tbboards == 6 ]; then
-     # This is a NL station
-     diff prbs_dir_test.log ./gold/prbs_dir_test.gold > prbs_dir_test.diff
-     if [ -e prbs_dir_test.log ] && [ -e ./gold/prbs_dir_test.gold ] && [ -e prbs_dir_test.diff ] && ! [ -s prbs_dir_test.diff ]; then
-     # The files exists AND has the diff size 0
-         echo "RCU -> RSP -> TBB interfaces test went OK"
-     else
-         echo "RCU -> RSP -> TBB interfaces test went wrong"
-     fi
-else
-     # This is a INT station
-     diff prbs_dir_test.log ./gold/prbs_dir_test_int.gold > prbs_dir_test_int.diff
-     if [ -e prbs_dir_test.log ] && [ -e ./gold/prbs_dir_test_int.gold ] && [ -e prbs_dir_test_int.diff ] && ! [ -s prbs_dir_test_int.diff ]; then
-     # The files exists AND has the diff size 0
-         echo "RCU -> RSP -> TBB interfaces test went OK"
-     else
-         echo "RCU -> RSP -> TBB interfaces test went wrong"
-     fi
-fi
-
-
+#!/bin/bash
+
+#
+# Test the LVDS interfaces between RCU -> RSP -> TBB using the Pseudo Random generator in the RCUs.
+#
+# Modified for INT station 14-10-2010 M.J.Norden
+
+
+let rspboards=`sed -n  's/^\s*RS\.N_RSPBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
+let tbboards=`sed -n  's/^\s*RS\.N_TBBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
+let nof_rcu=8*$rspboards
+
+rm -f prbs_dir*.log
+rm -f prbs_dir*.diff
+rm -f ./prbs/*.*
+rm -r ./prbs/.svn
+
+
+# Set up RCU and RSP, make sure waveform generator is off
+rspctl --rcuprsg=1
+sleep 2
+rspctl --tbbmode=transient
+sleep 1
+rspctl --rcuenable=1
+
+sleep 5
+# set up TBB
+nof_slices=10   # one slice contains 1024 transient (raw data) samples
+
+tbbctl --free
+tbbctl --alloc
+tbbctl --rec
+
+sleep 1
+
+# Freeze and get the captured data from TBB
+cd ./prbs
+tbbctl --stop
+for ((i = 0; i < $nof_rcu; i++)) do
+  tbbctl --readpage=$i,0,$nof_slices
+done
+cd ..
+# Verify the PRBS
+python prbs_dir_test.py
+rspctl --rcuprsg=0
+
+if [ $tbboards == 6 ]; then
+     # This is a NL station
+     diff prbs_dir_test.log ./gold/prbs_dir_test.gold > prbs_dir_test.diff
+     if [ -e prbs_dir_test.log ] && [ -e ./gold/prbs_dir_test.gold ] && [ -e prbs_dir_test.diff ] && ! [ -s prbs_dir_test.diff ]; then
+     # The files exists AND has the diff size 0
+         echo "RCU -> RSP -> TBB interfaces test went OK"
+     else
+         echo "RCU -> RSP -> TBB interfaces test went wrong"
+     fi
+else
+     # This is a INT station
+     diff prbs_dir_test.log ./gold/prbs_dir_test_int.gold > prbs_dir_test_int.diff
+     if [ -e prbs_dir_test.log ] && [ -e ./gold/prbs_dir_test_int.gold ] && [ -e prbs_dir_test_int.diff ] && ! [ -s prbs_dir_test_int.diff ]; then
+     # The files exists AND has the diff size 0
+         echo "RCU -> RSP -> TBB interfaces test went OK"
+     else
+         echo "RCU -> RSP -> TBB interfaces test went wrong"
+     fi
+fi
+
+
diff --git a/LCU/StationTest/tbb_size.sh b/LCU/StationTest/tbb_size.sh
index 943ec4fac47c5dc2895a62b5013a556b4c8ad41f..f57cf47256847a9fea3b83f437248991829fb5fb 100755
--- a/LCU/StationTest/tbb_size.sh
+++ b/LCU/StationTest/tbb_size.sh
@@ -1,32 +1,32 @@
-#!/bin/bash
-
-#
-# Get version info from the TBB boards and compare this with the expected golden result.
-#
-# Modified for INT stations, 14-10-2010, M.J.Norden
-
-rm -f tbb_size*.log
-rm -f tbb_size*.diff
-tbbctl --size > tbb_size.log
-
-let tbboards=`sed -n  's/^\s*RS\.N_TBBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
-
-if [ $tbboards == 6 ]; then
-     # This is a NL station
-     diff tbb_size.log gold/tbb_size.gold > tbb_size.diff
-     if [ -e tbb_size.log ] && [ -e gold/tbb_size.gold ] && [ -e tbb_size.diff ] && ! [ -s tbb_size.diff ]; then
-     # The files exists AND has the diff size 0
-         echo "TBB memory size test went OK"
-     else
-         echo "TBB memory size test went wrong"
-     fi
-else
-     # This is a INT station
-     diff tbb_size.log gold/tbb_size_int.gold > tbb_size_int.diff
-     if [ -e tbb_size.log ] && [ -e gold/tbb_size_int.gold ] && [ -e tbb_size_int.diff ] && ! [ -s tbb_size_int.diff ]; then
-     # The files exists AND has the diff size 0
-         echo "TBB memory size test went OK"
-     else
-         echo "TBB memory size test went wrong"
-     fi
-fi
+#!/bin/bash
+
+#
+# Get version info from the TBB boards and compare this with the expected golden result.
+#
+# Modified for INT stations, 14-10-2010, M.J.Norden
+
+rm -f tbb_size*.log
+rm -f tbb_size*.diff
+tbbctl --size > tbb_size.log
+
+let tbboards=`sed -n  's/^\s*RS\.N_TBBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
+
+if [ $tbboards == 6 ]; then
+     # This is a NL station
+     diff tbb_size.log gold/tbb_size.gold > tbb_size.diff
+     if [ -e tbb_size.log ] && [ -e gold/tbb_size.gold ] && [ -e tbb_size.diff ] && ! [ -s tbb_size.diff ]; then
+     # The files exists AND has the diff size 0
+         echo "TBB memory size test went OK"
+     else
+         echo "TBB memory size test went wrong"
+     fi
+else
+     # This is a INT station
+     diff tbb_size.log gold/tbb_size_int.gold > tbb_size_int.diff
+     if [ -e tbb_size.log ] && [ -e gold/tbb_size_int.gold ] && [ -e tbb_size_int.diff ] && ! [ -s tbb_size_int.diff ]; then
+     # The files exists AND has the diff size 0
+         echo "TBB memory size test went OK"
+     else
+         echo "TBB memory size test went wrong"
+     fi
+fi
diff --git a/LCU/StationTest/tbb_version.sh b/LCU/StationTest/tbb_version.sh
index a3d3f10c01a4882dc64a79f402cbdcb8eba29568..c8d0035da65cdfbbff4a16512c2cbe534dde7cbf 100755
--- a/LCU/StationTest/tbb_version.sh
+++ b/LCU/StationTest/tbb_version.sh
@@ -1,31 +1,31 @@
-#!/bin/bash
-#
-# Get version info from the TBB boards and compare this with the expected golden result.
-#
-# Modified voor INT stations, M.J.Norden 14-10-2010
-
-let tbboards=`sed -n  's/^\s*RS\.N_TBBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
-
-rm -f tbb_version*.log
-rm -f tbb_version*.diff
-tbbctl --version > tbb_version.log
-
-if [ $tbboards == 6 ]; then
-     # This is a NL station
-     diff tbb_version.log gold/tbb_version.gold > tbb_version.diff
-     if [ -e tbb_version.log ] && [ -e gold/tbb_version.gold ] && [ -e tbb_version.diff ] && ! [ -s tbb_version.diff ]; then
-     # The files exists AND has the diff size 0
-         echo "TBB version test went OK"
-     else
-         echo "TBB version test went wrong"
-     fi
-else
-     # This is a INT station
-     diff tbb_version.log gold/tbb_version_int.gold > tbb_version_int.diff
-     if [ -e tbb_version.log ] && [ -e gold/tbb_version_int.gold ] && [ -e tbb_version_int.diff ] && ! [ -s tbb_version_int.diff ]; then
-     # The files exists AND has the diff size 0
-         echo "TBB version test went OK"
-     else
-         echo "TBB version test went wrong"
-     fi
-fi
+#!/bin/bash
+#
+# Get version info from the TBB boards and compare this with the expected golden result.
+#
+# Modified voor INT stations, M.J.Norden 14-10-2010
+
+let tbboards=`sed -n  's/^\s*RS\.N_TBBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
+
+rm -f tbb_version*.log
+rm -f tbb_version*.diff
+tbbctl --version > tbb_version.log
+
+if [ $tbboards == 6 ]; then
+     # This is a NL station
+     diff tbb_version.log gold/tbb_version.gold > tbb_version.diff
+     if [ -e tbb_version.log ] && [ -e gold/tbb_version.gold ] && [ -e tbb_version.diff ] && ! [ -s tbb_version.diff ]; then
+     # The files exists AND has the diff size 0
+         echo "TBB version test went OK"
+     else
+         echo "TBB version test went wrong"
+     fi
+else
+     # This is a INT station
+     diff tbb_version.log gold/tbb_version_int.gold > tbb_version_int.diff
+     if [ -e tbb_version.log ] && [ -e gold/tbb_version_int.gold ] && [ -e tbb_version_int.diff ] && ! [ -s tbb_version_int.diff ]; then
+     # The files exists AND has the diff size 0
+         echo "TBB version test went OK"
+     else
+         echo "TBB version test went wrong"
+     fi
+fi
diff --git a/LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU192.sh b/LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU192.sh
index a2fa8f601971c18adc28495a1d9322ddfb96862e..9df889c5d71adba01fb6b78c9c0fc63dc4378d7c 100755
--- a/LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU192.sh
+++ b/LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU192.sh
@@ -1,25 +1,25 @@
-# beamformer test for 192 rcu's in HBA mode (with splitter OFF)
-# object zenith
-# version 1.1,  3 dec 2010, M.J.Norden
-
-
-rspctl --wg=0
-sleep 1
-rspctl --rcuprsg=0
-sleep 1
-
-killall beamctl
-sleep 3
-eval swlevel 3
-sleep 2
-rspctl --splitter=0
-sleep 3
-
-beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:1 --subbands=320:381 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:95 --subbands=320:381 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=96:97 --subbands=320:381 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:191 --subbands=320:381 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-
+# beamformer test for 192 rcu's in HBA mode (with splitter OFF)
+# object zenith
+# version 1.1,  3 dec 2010, M.J.Norden
+
+
+rspctl --wg=0
+sleep 1
+rspctl --rcuprsg=0
+sleep 1
+
+killall beamctl
+sleep 3
+eval swlevel 3
+sleep 2
+rspctl --splitter=0
+sleep 3
+
+beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:1 --subbands=320:381 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:95 --subbands=320:381 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=96:97 --subbands=320:381 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:191 --subbands=320:381 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+
diff --git a/LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU96.sh b/LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU96.sh
index 80cdbd75fb67ed4a15bc2c98857d127d63c06a83..f0e79ea832f702bb8e7e81a86b83899aff385e61 100755
--- a/LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU96.sh
+++ b/LCU/StationTest/test/beamformertest/beamformertest_HBA_RCU96.sh
@@ -1,25 +1,25 @@
-# beamformer test for 96 rcu's in HBA mode (with splitter OFF)
-# object zenith
-# version 1.1,  3 dec 2010, M.J.Norden
-
-
-rspctl --wg=0
-sleep 1
-rspctl --rcuprsg=0
-sleep 1
-
-killall beamctl
-sleep 3
-eval swlevel 3
-sleep 2
-rspctl --splitter=0
-sleep 3
-
-beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:1 --subbands=320:381 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:46 --subbands=320:381 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=47:48 --subbands=320:381 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:95 --subbands=320:381 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-
+# beamformer test for 96 rcu's in HBA mode (with splitter OFF)
+# object zenith
+# version 1.1,  3 dec 2010, M.J.Norden
+
+
+rspctl --wg=0
+sleep 1
+rspctl --rcuprsg=0
+sleep 1
+
+killall beamctl
+sleep 3
+eval swlevel 3
+sleep 2
+rspctl --splitter=0
+sleep 3
+
+beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:1 --subbands=320:381 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:46 --subbands=320:381 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=47:48 --subbands=320:381 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=HBA_JOINED --rcumode=5 --rcus=0:95 --subbands=320:381 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+
diff --git a/LCU/StationTest/test/beamformertest/beamformertest_LBA_RCU192.sh b/LCU/StationTest/test/beamformertest/beamformertest_LBA_RCU192.sh
index ac2c323f1b1fac017ae1c0caf17a831cce93f0f3..fa8b8b363e73c34689fdcca35599f16fe6e9b4c7 100755
--- a/LCU/StationTest/test/beamformertest/beamformertest_LBA_RCU192.sh
+++ b/LCU/StationTest/test/beamformertest/beamformertest_LBA_RCU192.sh
@@ -1,25 +1,25 @@
-# beamformer test for 192 rcu's in LBA mode (with splitter OFF)
-# object zenith
-# version 1.1,  3 dec 2010, M.J.Norden
-
-
-rspctl --wg=0
-sleep 1
-rspctl --rcuprsg=0
-sleep 1
-
-killall beamctl
-sleep 3
-eval swlevel 3
-sleep 2
-rspctl --splitter=0
-sleep 3
-
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:1 --subbands=270:331 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:95 --subbands=270:331 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=96:97 --subbands=270:331 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:191 --subbands=270:331 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-
+# beamformer test for 192 rcu's in LBA mode (with splitter OFF)
+# object zenith
+# version 1.1,  3 dec 2010, M.J.Norden
+
+
+rspctl --wg=0
+sleep 1
+rspctl --rcuprsg=0
+sleep 1
+
+killall beamctl
+sleep 3
+eval swlevel 3
+sleep 2
+rspctl --splitter=0
+sleep 3
+
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:1 --subbands=270:331 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:95 --subbands=270:331 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=96:97 --subbands=270:331 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:191 --subbands=270:331 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+
diff --git a/LCU/StationTest/test/beamformertest/beamformertest_LBHLBL_RCU96.sh b/LCU/StationTest/test/beamformertest/beamformertest_LBHLBL_RCU96.sh
index 0085dd8564efae6920bf7410e9e15f02119faf7c..e2634a28af884edfb2f36cf8990bb3dee69349a3 100755
--- a/LCU/StationTest/test/beamformertest/beamformertest_LBHLBL_RCU96.sh
+++ b/LCU/StationTest/test/beamformertest/beamformertest_LBHLBL_RCU96.sh
@@ -1,21 +1,21 @@
-# beamformermformer test for 96 rcu's in LBA mode (LBL & LBH input)
-# two antennas per beam, four beams
-# object zenith
-# version 1.9  3 dec 2010 M.J.Norden
-
-
-rspctl --wg=0
-rspctl --rcuprsg=0
-
-killall beamctl
-swlevel 3
-sleep 5
-
-beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=48:49 --subbands=270:331 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:1 --subbands=270:331 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=48:95 --subbands=270:331 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:47 --subbands=270:331 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-
+# beamformermformer test for 96 rcu's in LBA mode (LBL & LBH input)
+# two antennas per beam, four beams
+# object zenith
+# version 1.9  3 dec 2010 M.J.Norden
+
+
+rspctl --wg=0
+rspctl --rcuprsg=0
+
+killall beamctl
+swlevel 3
+sleep 5
+
+beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=48:49 --subbands=270:331 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:1 --subbands=270:331 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=48:95 --subbands=270:331 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:47 --subbands=270:331 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+
diff --git a/LCU/StationTest/test/beamformertest/beamformertest_LBH_RCU96.sh b/LCU/StationTest/test/beamformertest/beamformertest_LBH_RCU96.sh
index 6a649606eba1b0b929766e05fb118f63ddf3b0a9..23af0f2a78ff5e49d95dcc1ce4668eb59c6d7c56 100755
--- a/LCU/StationTest/test/beamformertest/beamformertest_LBH_RCU96.sh
+++ b/LCU/StationTest/test/beamformertest/beamformertest_LBH_RCU96.sh
@@ -1,25 +1,25 @@
-# beamformer test for 96 rcu's in LBH mode (with splitter OFF)
-# object zenith
-# version 1.2,  3 dec 2010, M.J.Norden
-
-
-rspctl --wg=0
-sleep 1
-rspctl --rcuprsg=0
-sleep 1
-
-killall beamctl
-sleep 3
-swlevel 3
-sleep 2
-rspctl --splitter=0
-sleep 3
-
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:1 --subbands=270:331 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:47 --subbands=270:331 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=48:49 --subbands=270:331 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:95 --subbands=270:331 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-
+# beamformer test for 96 rcu's in LBH mode (with splitter OFF)
+# object zenith
+# version 1.2,  3 dec 2010, M.J.Norden
+
+
+rspctl --wg=0
+sleep 1
+rspctl --rcuprsg=0
+sleep 1
+
+killall beamctl
+sleep 3
+swlevel 3
+sleep 2
+rspctl --splitter=0
+sleep 3
+
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:1 --subbands=270:331 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:47 --subbands=270:331 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=48:49 --subbands=270:331 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_INNER --rcumode=3 --rcus=0:95 --subbands=270:331 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+
diff --git a/LCU/StationTest/test/beamformertest/beamformertest_LBL_RCU96.sh b/LCU/StationTest/test/beamformertest/beamformertest_LBL_RCU96.sh
index af08d1569bd285a615e0305a70697ca2647dad18..3a0541d715b13f30f083a86572a899f3cd94a1a4 100755
--- a/LCU/StationTest/test/beamformertest/beamformertest_LBL_RCU96.sh
+++ b/LCU/StationTest/test/beamformertest/beamformertest_LBL_RCU96.sh
@@ -1,25 +1,25 @@
-# beamformer test for 96 rcu's in LBL mode (with splitter OFF)
-# object zenith
-# version 1.2,  3 dec 2010, M.J.Norden
-
-
-rspctl --wg=0
-sleep 1
-rspctl --rcuprsg=0
-sleep 1
-
-killall beamctl
-sleep 3
-swlevel 3
-sleep 2
-rspctl --splitter=0
-sleep 3
-
-beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=0:1 --subbands=270:331 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=0:47 --subbands=270:331 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=48:49 --subbands=270:331 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=0:95 --subbands=270:331 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-
+# beamformer test for 96 rcu's in LBL mode (with splitter OFF)
+# object zenith
+# version 1.2,  3 dec 2010, M.J.Norden
+
+
+rspctl --wg=0
+sleep 1
+rspctl --rcuprsg=0
+sleep 1
+
+killall beamctl
+sleep 3
+swlevel 3
+sleep 2
+rspctl --splitter=0
+sleep 3
+
+beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=0:1 --subbands=270:331 --beamlets=0:61 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=0:47 --subbands=270:331 --beamlets=62:123 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=48:49 --subbands=270:331 --beamlets=124:185 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=LBA_OUTER --rcumode=1 --rcus=0:95 --subbands=270:331 --beamlets=186:247 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+
diff --git a/LCU/StationTest/test/beamformertest/hba0_hba1_azel.sh b/LCU/StationTest/test/beamformertest/hba0_hba1_azel.sh
index 3dc3d0fdfeedae708ab93be429403bffa3e6af63..3e71f71e63ef1d3d87cfd1129ebb477d936f21e6 100644
--- a/LCU/StationTest/test/beamformertest/hba0_hba1_azel.sh
+++ b/LCU/StationTest/test/beamformertest/hba0_hba1_azel.sh
@@ -1,84 +1,84 @@
-#!/bin/sh
-# 1.1 test script to verify HBA0 and HBA1 settings
-# North, East, South, West positions with AZEL
-# 15-10-10, M.J Norden
-# HBA input with antenna
-
-killall beamctl
-rspctl --rcuprsg=0
-rspctl --wg=0
-rspctl --splitter=1
-
-swlevel 3
-sleep 10
-
-# rotation CS002
-let rotation_hba0=52
-let rotation_hba1=0
-
-echo "rotation_hba0" $rotation_hba0
-echo "rotation_hba1" $rotation_hba1
-
-HBAnorth0=`(echo - | awk -v K=$rotation_hba0 '{print 0 + (K/360)*2*3.14159}')`;
-HBAnorth1=`(echo - | awk -v K=$rotation_hba1 '{print 0 + (K/360)*2*3.14159}')`;
-
-HBAeast0=`(echo - | awk -v K=$rotation_hba0 '{print 1.5708 + (K/360)*2*3.14159}')`;
-HBAeast1=`(echo - | awk -v K=$rotation_hba1 '{print 1.5708 + (K/360)*2*3.14159}')`;
-
-HBAsouth0=`(echo - | awk -v K=$rotation_hba0 '{print 3.1459 + (K/360)*2*3.14159}')`;
-HBAsouth1=`(echo - | awk -v K=$rotation_hba1 '{print 3.1459 + (K/360)*2*3.14159}')`;
-
-HBAwest0=`(echo - | awk -v K=$rotation_hba0 '{print 4.7124 + (K/360)*2*3.14159}')`;
-HBAwest1=`(echo - | awk -v K=$rotation_hba1 '{print 4.7124 + (K/360)*2*3.14159}')`;
-
-
-sleep 3
-
-# pointing to horizon north
-beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAnorth0,0,AZEL --digdir=$HBAnorth0,0,AZEL&
-sleep 3
-beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAnorth1,0,AZEL --digdir=$HBAnorth1,0,AZEL&
-sleep 20
-rspctl --realdelays > realdelays_north_`date +%F_%T`.log
-killall beamctl
-sleep 10
-
-# pointing to horizon east
-beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAeast0,0,AZEL --digdir=$HBAeast0,0,AZEL&
-sleep 3
-beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAeast1,0,AZEL --digdir=$HBAeast1,0,AZEL&
-sleep 20
-rspctl --realdelays > realdelays_east_`date +%F_%T`.log
-killall beamctl
-sleep 10
-
-# pointing to horizon south
-beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAsouth0,0,AZEL --digdir=$HBAsouth0,0,AZEL&
-sleep 3
-beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAsouth1,0,AZEL --digdir=$HBAsouth1,0,AZEL&
-sleep 20
-rspctl --realdelays > realdelays_south_`date +%F_%T`.log
-killall beamctl
-sleep 10
-
-# pointing to horizon west
-beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAwest0,0,AZEL --digdir=$HBAwest0,0,AZEL&
-sleep 3
-beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAwest1,0,AZEL --digdir=$HBAwest1,0,AZEL&
-sleep 20
-rspctl --realdelays > realdelays_west_`date +%F_%T`.log
-killall beamctl
-sleep 10
-
-# pointing to zenith and north
-beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAnorth,1.5708,AZEL --digdir=$HBAnorth,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAnorth,1.5708,AZEL --digdir=$HBAnorth,1.5708,AZEL&
-sleep 20
-rspctl --realdelays > realdelays_zenith_`date +%F_%T`.log
-killall beamctl
-sleep 10
-
-
-
-
+#!/bin/sh
+# 1.1 test script to verify HBA0 and HBA1 settings
+# North, East, South, West positions with AZEL
+# 15-10-10, M.J Norden
+# HBA input with antenna
+
+killall beamctl
+rspctl --rcuprsg=0
+rspctl --wg=0
+rspctl --splitter=1
+
+swlevel 3
+sleep 10
+
+# rotation CS002
+let rotation_hba0=52
+let rotation_hba1=0
+
+echo "rotation_hba0" $rotation_hba0
+echo "rotation_hba1" $rotation_hba1
+
+HBAnorth0=`(echo - | awk -v K=$rotation_hba0 '{print 0 + (K/360)*2*3.14159}')`;
+HBAnorth1=`(echo - | awk -v K=$rotation_hba1 '{print 0 + (K/360)*2*3.14159}')`;
+
+HBAeast0=`(echo - | awk -v K=$rotation_hba0 '{print 1.5708 + (K/360)*2*3.14159}')`;
+HBAeast1=`(echo - | awk -v K=$rotation_hba1 '{print 1.5708 + (K/360)*2*3.14159}')`;
+
+HBAsouth0=`(echo - | awk -v K=$rotation_hba0 '{print 3.1459 + (K/360)*2*3.14159}')`;
+HBAsouth1=`(echo - | awk -v K=$rotation_hba1 '{print 3.1459 + (K/360)*2*3.14159}')`;
+
+HBAwest0=`(echo - | awk -v K=$rotation_hba0 '{print 4.7124 + (K/360)*2*3.14159}')`;
+HBAwest1=`(echo - | awk -v K=$rotation_hba1 '{print 4.7124 + (K/360)*2*3.14159}')`;
+
+
+sleep 3
+
+# pointing to horizon north
+beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAnorth0,0,AZEL --digdir=$HBAnorth0,0,AZEL&
+sleep 3
+beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAnorth1,0,AZEL --digdir=$HBAnorth1,0,AZEL&
+sleep 20
+rspctl --realdelays > realdelays_north_`date +%F_%T`.log
+killall beamctl
+sleep 10
+
+# pointing to horizon east
+beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAeast0,0,AZEL --digdir=$HBAeast0,0,AZEL&
+sleep 3
+beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAeast1,0,AZEL --digdir=$HBAeast1,0,AZEL&
+sleep 20
+rspctl --realdelays > realdelays_east_`date +%F_%T`.log
+killall beamctl
+sleep 10
+
+# pointing to horizon south
+beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAsouth0,0,AZEL --digdir=$HBAsouth0,0,AZEL&
+sleep 3
+beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAsouth1,0,AZEL --digdir=$HBAsouth1,0,AZEL&
+sleep 20
+rspctl --realdelays > realdelays_south_`date +%F_%T`.log
+killall beamctl
+sleep 10
+
+# pointing to horizon west
+beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAwest0,0,AZEL --digdir=$HBAwest0,0,AZEL&
+sleep 3
+beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAwest1,0,AZEL --digdir=$HBAwest1,0,AZEL&
+sleep 20
+rspctl --realdelays > realdelays_west_`date +%F_%T`.log
+killall beamctl
+sleep 10
+
+# pointing to zenith and north
+beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=300:360 --beamlets=0:60 --anadir=$HBAnorth,1.5708,AZEL --digdir=$HBAnorth,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=300:360 --beamlets=1000:1060 --anadir=$HBAnorth,1.5708,AZEL --digdir=$HBAnorth,1.5708,AZEL&
+sleep 20
+rspctl --realdelays > realdelays_zenith_`date +%F_%T`.log
+killall beamctl
+sleep 10
+
+
+
+
diff --git a/LCU/StationTest/test/envcontroltest/eccontrol.py b/LCU/StationTest/test/envcontroltest/eccontrol.py
index 869cde7c4fa9992f896945fcf97ffd12435bedea..1ba4c0d152fddc9ce7e6cd258e0a098ae601d99f 100644
--- a/LCU/StationTest/test/envcontroltest/eccontrol.py
+++ b/LCU/StationTest/test/envcontroltest/eccontrol.py
@@ -1,587 +1,587 @@
-## P.Donker ASTRON februari 2010
-## EC control module
-
-import socket
-import struct
-import time
-
-class EC:
-    # cmdIDs from TCP PROTOCOL ec-controller
-    EC_NONE             = 0
-    EC_STATUS           = 1
-    EC_SETTINGS         = 2
-    EC_CTRL_TEMP        = 3
-    EC_VERSION          = 5
-    EC_SET_CTRL_MODE    = 10
-    EC_SET_FANS         = 11
-    EC_SET_TEMP         = 15
-    EC_SET_HEATER       = 17
-    EC_SET_48           = 20
-    EC_RESET_48         = 22
-    EC_SET_230          = 25
-    EC_RESET_230        = 27
-    EC_RESET_TRIP       = 28
-    EC_SET_DOOR_CTRL    = 50
-    EC_SET_HUM_CTRL     = 52
-    EC_SET_SECOND       = 115
-    
-    SET_MAX_CTRL_TEMP   = 150
-    SET_MIN_CTRL_TEMP   = 151
-    SET_WARN1_TEMP      = 152
-    SET_WARN2_TEMP      = 153
-    SET_TRIP_TEMP       = 154
-    SET_HEATER_TEMP     = 155
-    SET_MAX_HUM         = 160
-    SET_TRIP_HUM        = 161
-    SET_START_SIDE      = 170
-    SET_BALANCE_POINT   = 171
-    SET_MAX_CHANGE      = 172
-    SET_SEEK_TIME       = 173
-    SET_SEEK_CHANGE     = 174
-                        
-    SET_TEMP_OFFSET     = 180
-    SET_TEMP_MULT       = 181
-    SET_HUM_OFFSET      = 182
-    SET_HUM_MULT        = 183
-    SENSOR_SETTINGS     = 184
-    SET_LOG             = 1111
-    FLASH_ERASE         = 2330
-    FLASH_WRITE         = 2331
-    RESTART             = 2440
-
-    MODE_OFF     = 0
-    MODE_ON      = 1
-    MODE_AUTO    = 2
-    MODE_MANUAL  = 3
-    MODE_STARTUP = 4
-    MODE_SEEK    = 5
-    PWR_OFF      = 0
-    PWR_ON       = 1
-    LCU          = 230
-
-    printToScreen = False
-    printToFile = False
-    cabs = None
-    nCabs = None
-    host = None
-    station = None
-    port = 10000
-    sck = None
-    logger = False
-    info = ''
-    version = 0
-    versionstr = 'V-.-.-'
-    
-    def __init__(self, addr='0.0.0.0', nCabs=3):
-        self.nCabs = nCabs
-        if nCabs == 1: self.cabs = [0]
-        if nCabs == 3: self.cabs = [0,1,3]
-        if nCabs == 4: self.cabs = [0,1,2,3]
-        self.host = addr
-        try:
-            (hostname,a,b) = socket.gethostbyaddr(addr)
-            self.station = hostname.split('.')[0]
-        except:
-            self.station = 'Unknown'
-                
-    def setInfo(self, info):
-        self.info = info
-        if self.printToScreen:
-            print self.info
-            self.info = ''
-        else: self.info += '\n'
-        return
-
-    def addInfo(self, info):
-        self.info += info
-        if self.printToScreen:
-            print self.info
-            self.info = ''
-        else: self.info += '\n'
-        return
-    
-    def printInfo(self, state=True):
-        self.printToScreen = state
-        return
- 
-    def printFile(self, state=True):
-        self.printToFile = state
-        return
-    
-    def hex2bit(self, val=0, bits=16):
-        bit = ''
-        for i in range(bits-1,-1,-1):
-            if val & (1 << i):
-                bit += '1'
-            else:
-                bit += '0'
-        return(bit) 
-
-    #---------------------------------------
-    def connectToHost(self):
-        self.setInfo("connecting to %s on port %d" %(self.host, self.port))
-        connected = False
-
-        try:
-            self.sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        except socket.error:
-            self.sck.close()
-            return(connected)
-
-        try:
-            self.sck.settimeout(3.0)
-            self.sck.connect((self.host, self.port))
-            connected = True
-            #time.sleep(0.1)
-        except socket.error:
-            self.sck.close()
-        return(connected)
-            
-    #---------------------------------------
-    def disconnectHost(self):
-        self.sck.close()
-        #time.sleep(0.1)
-        return
-        
-    #---------------------------------------
-    def sendCmd(self, cmdId=0, cab=-1, value=0):
-        if (cmdId == self.EC_NONE):
-            return (false)
-        try:
-            cmd = struct.pack('hhh', cmdId, cab, int(value))
-            self.sck.send(cmd)
-        except socket.error:
-            self.setInfo("socket error, try to reconnect")
-            self.disconnectHost()
-            time.sleep(10.0)
-            self.connectToHost()
-        return
-    #---------------------------------------
-    def recvAck(self):
-        socketError = False    
-        try:
-            self.sck.settimeout(1.0)
-            data = self.sck.recv(6)
-        except socket.error:
-            socketError = True
-            self.setInfo("socket error, try to reconnect")
-            #self.disconnectHost()
-            #self.connectToHost()
-        if socketError:
-            return(0,0,[])
-            
-        header = struct.unpack('hhh', data)
-        cmdId = header[0]
-        status = header[1]
-        PLSize = header[2]
-        if (PLSize > 0):
-            data = self.sck.recv(PLSize)
-            fmt = 'h' * int(PLSize / 2)
-            PL = struct.unpack(fmt, data)
-        else:
-            PL = []
-        return (cmdId, status, PL) 
-    #---------------------------------------
-    def recvLog(self):
-        socketError = False    
-        try:
-            self.sck.settimeout(10.0)
-            data = self.sck.recv(200)
-        except socket.error:
-            socketError = True
-        if socketError:
-            return
-        print str(data).replace('\r',''),
-        return 
-    
-    #---------------------------------------
-    def setSecond(self, sec=0):
-        self.sendCmd(self.EC_SET_SECOND, 0, sec)
-        (cmdId, status, PL) = self.recvAck()
-        return
-    #---------------------------------------
-    def waitForSync(self):
-        while ((time.gmtime()[5] % 10) != 7):
-            time.sleep(0.5)
-        time.sleep(1.0)
-        return
-    #---------------------------------------
-    def waitForUpdate(self):
-        while ((time.gmtime()[5] % 10) != 3):
-            time.sleep(0.5)
-        time.sleep(1.0)
-        return
-    #---------------------------------------
-    def setLogger(self, level=0):
-        if (self.version >= 150):
-            self.setInfo('EC set logger to level %d' %(level))
-            self.sendCmd(self.SET_LOG, 0, level)
-            #(cmdId, status, PL) = self.recvAck()
-            return 
-        else:
-            self.setInfo('setting log level not possible in this EC version')
-        return 
-    #---------------------------------------
-    
-    def restart(self):
-        if (self.version >= 107) or (self.version == 1):
-            self.setInfo('EC restart')
-            if self.version < 110:
-                self.sendCmd(211)
-            elif self.version < 141:
-                self.sendCmd(210)
-            else:
-                self.sendCmd(self.RESTART)
-                time.sleep(2.0)
-            #(cmdId, status, PL) = self.recvAck()
-            return 1
-        else:
-            self.setInfo('restart not possible in this EC version')
-        return 0
-    #---------------------------------------
-    def setControlMode(self, cab=-1, mode=MODE_AUTO):
-        self.sendCmd(self.EC_SET_CTRL_MODE, cab, mode)
-        (cmdId, status, PL) = self.recvAck()
-        self.setInfo('SetControlMode cab %d to %d' %(cab, mode))
-        return
-    #---------------------------------------
-    def setPower(self, pwr=-1, state=PWR_ON):
-        if ((pwr == 48) or (pwr == -1)):
-            self.sendCmd(self.EC_SET_48, 0, state)
-            (cmdId, status, PL) = self.recvAck()
-            self.setInfo('Power Set 48V to %d' %(state))
-        if ((pwr == self.LCU) or (pwr == -1)):
-            self.sendCmd(self.EC_SET_230, 0, state)
-            (cmdId, status, PL) = self.recvAck()
-            self.setInfo('Power Set LCU to %d' %(state))
-        return
-    #---------------------------------------
-    def resetPower(self, pwr=-1):
-        if ((pwr == 48) or (pwr == -1)):
-            self.sendCmd(self.EC_RESET_48, 0, 0)
-            (cmdId, status, PL) = self.recvAck()
-            self.setInfo('PowerReset 48V')
-        if ((pwr == self.LCU) or (pwr == -1)):
-            self.sendCmd(self.EC_RESET_230, 0, 0)
-            (cmdId, status, PL) = self.recvAck()
-            self.setInfo('PowerReset LCU')
-
-    #---------------------------------------
-    def resetTrip(self):
-        self.sendCmd(self.EC_RESET_TRIP, -1, 0)
-        (cmdId, status, PL) = self.recvAck()
-        self.setInfo('Reset Trip System')
-
-   #---------------------------------------
-    ## search for new setpoint, works only in control mmode 1
-    def seekNewSetpoint(self, cab=-1):
-        self.sendCmd(self.EC_SET_MODE, cab, MODE_SEEK)
-        (cmdId, status, PL) = self.recvAck()
-        self.setInfo('Find newSetpoint cab %d' %(cab))
-    #---------------------------------------
-    ## set new setpoint, works only in manual mode
-    def setTemperature(self, cab=-1, temp=20.0):
-        temperature = int(temp * 100.)
-        self.sendCmd(self.EC_SET_TEMP, cab, temperature)
-        (cmdId, status, PL) = self.recvAck()
-        self.setInfo('SetTemperature cab %d to %4.2f' %(cab,temp))
-    #---------------------------------------
-    ## set new setpoint, works only in manual mode
-    def setFans(self, cab=-1, fans=0x0f):
-        self.sendCmd(self.EC_SET_FANS, cab, fans)
-        (cmdId, status, PL) = self.recvAck()
-        self.setInfo('SetFans cab %d to %X' %(cab,fans))
-    #---------------------------------------
-    ## set door control to on(1) or off(0)
-    def setDoorControl(self, cab=-1, state=1):
-        self.sendCmd(self.EC_SET_DOOR_CTRL, cab, state)
-        (cmdId, status, PL) = self.recvAck()
-        self.setinfo('SetDoorControl cab %d to %d' %(cab, state))
-    #---------------------------------------
-    ## set hum control to on(1) or off(0)
-    def setHumControl(self, cab=-1, state=1):
-        self.sendCmd(self.EC_SET_HUM_CTRL, cab, state)
-        (cmdId, status, PL) = self.recvAck()
-        self.setInfo('SetHumidityControl cab %d to %d' %(cab, state))
-    #---------------------------------------
-    def setHeater(self, mode=0):
-        self.sendCmd(self.EC_SET_HEATER, -1, mode)
-        (cmdId, status, payload) = self.recvAck()
-        
-        if (mode == self.MODE_ON): self.setInfo('heater is turned ON')
-        if (mode == self.MODE_OFF): self.setInfo('heater is turned OFF')
-        if (mode == self.MODE_AUTO): self.setInfo('heater set to AUTO')
-    #---------------------------------------
-    def getVersion(self):
-        self.sendCmd(self.EC_VERSION)
-        (cmdId, status, PL) = self.recvAck()
-        
-        version = int((PL[0]*100)+(PL[1]*10)+PL[2])
-        versionstr = 'V%d.%d.%d' %(PL)
-        self.version = version
-        self.versionstr = versionstr
-        self.setInfo('EC software version %d.%d.%d' %(PL))
-        return version, versionstr
-    #---------------------------------------
-    def getStatus(self):
-        ec_mode = ('OFF','ON','AUTO','MANUAL','STARTUP','AUTO-SEEK','ABSENT')
-        fan = ('.  .  .  .','.  .  .  .','.  2  .  .','1  2  .  .',\
-               '.  .  3  .','.  .  .  .','.  2  3  .','1  2  3  .',\
-               '.  .  .  .','.  .  .  .','.  .  .  .','.  .  .  .',\
-               '.  .  3  4','.  .  .  .','.  2  3  4','1  2  3  4')
-        
-        door = ('CLOSED','FRONT_OPEN','BACK_OPEN','ALL_OPEN')
-        fanstate = ('BAD | BAD ','GOOD| BAD ','BAD | GOOD','GOOD| GOOD')
-        fanestate= ('OFF | OFF ','ON  | OFF ','OFF | ON  ','ON  | ON  ')
-        onoff = ('OFF','ON')
-        badok = ('BAD','OK')
-       
-        # get information from EC
-        self.sendCmd(self.EC_CTRL_TEMP)
-        (cmdId, status, PL1) = self.recvAck()
-        self.sendCmd(self.EC_STATUS)
-        (cmdId, status, PL2) = self.recvAck()
-        if len(PL1) == 0 or len(PL2) == 0: return     
-        # fill lines with data    
-        lines = []
-
-        if self.nCabs == 4:
-            lines.append('temperature cab3 = %5.2f' %(PL2[2]/100.))
-            lines.append('humidity cab3    = %5.2f' %(PL2[3]/100.))
-            lines.append('cabinet fans     = all on')
-            lines.append('heater state     = %s' %(onoff[PL2[(3*7)+6]]))
-            lines.append('power 48V state  = %s' %(onoff[(PL2[28] & 1)]))
-            lines.append('power LCU state  = %s' %(onoff[(PL2[28] >> 1)]))
-            lines.append('lightning state  = %s' %(badok[(PL2[29] & 1)]))
-
-        else:
-            lines.append('            |')
-            lines.append('mode        |')
-            lines.append('status      |')
-            lines.append('set point   |')
-            lines.append('temperature |')
-            lines.append('humidity    |')
-            lines.append('fans        |')
-            lines.append('fane        |')
-            lines.append('fans state  |')
-            lines.append('doors       |')
-            lines.append('heater      |')
-
-            for nCab in range(self.nCabs):
-                cab = self.cabs[nCab]
-                lines[0] += '  cabinet %1d |' %(cab)
-                lines[1] += '%11s |' %(ec_mode[PL2[(cab*7)]])
-                lines[2] += '     %#06x |' %(PL2[(cab*7)+1])
-                lines[3] += '%11.2f |' %(PL1[cab]/100.)
-                lines[4] += '%11.2f |' %(PL2[(cab*7)+2]/100.)
-                lines[5] += '%11.2f |' %(PL2[(cab*7)+3]/100.)
-                lines[6] += '%11s |' %(fan[(PL2[(cab*7)+4]&0x0f)])
-                lines[7] += '%11s |' %(fanestate[(PL2[(cab*7)+4]>>4)&0x3])  
-                lines[8] += '%11s |' %(fanstate[(PL2[(cab*7)+4]>>6)&0x3])  
-                lines[9] += '%11s |' %(door[(PL2[(cab*7)+5]&0x03)])
-                if (cab != 3):
-                   lines[10] += '%11s |' %('none')
-                else:
-                   lines[10] += '%11s |' %(onoff[PL2[(cab*7)+6]])
-
-            if self.nCabs == 1: i = 7
-            else: i = 28
-            lines.append('power 48V state  = %s' %(onoff[(PL2[i] & 1)]))
-            lines.append('power LCU state  = %s' %(onoff[(PL2[i] >> 1)]))
-            lines.append('lightning state  = %s' %(badok[(PL2[i+1] & 1)]))
-        
-        # print lines to screen or file, see printInfo
-        info = 'status %s (%s)     %s ' %(self.station, self.versionstr, time.asctime())
-        self.setInfo('-' * len(info))
-        self.addInfo(info)
-        self.addInfo('-' * len(info))
-        for line in lines:
-            self.addInfo(line)
-        # print data to file if selected
-        if (self.printToFile == 1):
-            tm = time.gmtime()
-            filename = '%s_%d%02d%02d.dat' %(self.station,tm.tm_year, tm.tm_mon, tm.tm_mday)
-            df = open(filename, mode='a')
-            df.write('%f ' %(time.time()))
-            for cab in self.cabs:
-                # print cabnr, setpoint, temperature, humidity, fansstate, heaterstate
-                df.write('[%d] %3.2f %3.2f %3.2f %d %d ' %\
-                        ( cab, PL1[cab]/100., PL2[(cab*7)+2]/100., PL2[(cab*7)+3]/100.,
-                          PL2[(cab*7)+4], PL2[(cab*7)+6]))
-            df.write('\n')
-            df.close()
-    #---------------------------------------
-    def getTripStatus(self):
-        # get information from EC
-        self.sendCmd(self.EC_STATUS)
-        (cmdId, status, PL) = self.recvAck()
-        state = False
-        if (PL[1] & 0x1000):
-            self.addInfo('trip in cabinet 0')
-            state = True
-        if (PL[8] & 0x1000):
-            self.addInfo('trip in cabinet 1')
-            state = True
-        if (PL[22] & 0x1000):
-            self.addInfo('trip in cabinet 3')
-            state = True
-        
-        if (PL[1] & 0x6000):
-            self.addInfo('warning in cabinet 0')
-            state = True
-        if (PL[8] & 0x6000):
-            self.addInfo('warning in cabinet 1')
-            state = True
-        if (PL[22] & 0x6000):
-            self.addInfo('warning in cabinet 3')
-            state = True
-
-        if (state == False):
-            self.addInfo('NO trips available')
-        return(state)
-    
-    #---------------------------------------
-    def getPowerStatus(self):
-        state = ('OFF','ON')
-        # get information from EC
-        self.sendCmd(self.EC_STATUS)
-        (cmdId, status, PL) = self.recvAck()
-        
-        self.addInfo('Power: 48V = %s, LCU = %s' %(state[(PL[28] & 1)], state[(PL[28] >> 1)]))
-        
-    #---------------------------------------
-    def getControlTemp(self):
-        self.sendCmd(self.EC_CTRL_TEMP)
-        (cmdId, status, PL) = self.recvAck()
-        lines = []
-        lines.append('                 |')
-        lines.append('min control temp |')
-        
-        for cab in self.cabs:
-            lines[0] += '  cab-%1d |' %(cab)
-            lines[1] += '%9.2f |' %(PL[cab]/100.)
-    #---------------------------------------    
-    def getSettings(self):
-        self.sendCmd(self.EC_SETTINGS)
-        (cmdId, status, PL) = self.recvAck()
-            #self.info =  len(PL))
-        # fill lines with data    
-        lines = []
-        lines.append('                 |')
-        lines.append('start side       |')
-        lines.append('balance point    |') 
-        lines.append('max hour change  |')
-        lines.append('seek time        |')
-        lines.append('max seek change  |')
-        lines.append('min control temp |')
-        lines.append('max control temp |')
-        lines.append('heater temp      |')
-        lines.append('warn1 temp       |')
-        lines.append('warn2 temp       |')
-        lines.append('trip temp        |')
-        lines.append('max humidity     |')
-        lines.append('trip humidity    |')
-
-
-        for nCab in range(self.nCabs):
-            cab = self.cabs[nCab]
-            lines[0] += '    cab-%1d |' %(cab)
-            lines[1] += '%9d |'    %(PL[(cab*13)+10])
-            lines[2] += '%9d |'    %(PL[(cab*13)+9])
-            lines[3] += '%9.2f |'  %(PL[(cab*13)+8]/100.)
-            lines[4] += '%9d |'    %(PL[(cab*13)+11])
-            lines[5] += '%9.2f |'  %(PL[(cab*13)+12]/100.)
-            lines[6] += '%9.2f |'  %(PL[(cab*13)+0]/100.)
-            lines[7] += '%9.2f |'  %(PL[(cab*13)+1]/100.)
-            lines[8] += '%9.2f |'  %(PL[(cab*13)+2]/100.)
-            lines[9] += '%9.2f |'  %(PL[(cab*13)+3]/100.)
-            lines[10] += '%9.2f |'  %(PL[(cab*13)+4]/100.)
-            lines[11] += '%9.2f |'  %(PL[(cab*13)+5]/100.)
-            lines[12] += '%9.2f |' %(PL[(cab*13)+6]/100.)
-            lines[13] += '%9.2f |' %(PL[(cab*13)+7]/100.)
-        
-        # print lines to screen or file, see printInfo
-        self.addInfo('=== Station settings ===')
-        for line in lines:
-            self.addInfo(line)
-
-    #---------------------------------------
-    def setSetting(self, cmd=0, cab=-1, val=0):
-        self.sendCmd(cmd, cab, val)
-        (cmdId, status, PL) = self.recvAck()
-    
-    #---------------------------------------    
-    def getSensorSettings(self):
-        self.sendCmd(self.SENSOR_SETTINGS)
-        (cmdId, status, PL) = self.recvAck()
-        #self.info =  len(PL))
-        # fill lines with data    
-        lines = []
-        lines.append('                     |')
-        lines.append('temperature offset   |')
-        lines.append('temperature multiply |')    
-        lines.append('humidity offset      |')
-        lines.append('humidity multiply    |')
-        
-        for nCab in range(self.nCabs):
-            cab = self.cabs[nCab]
-            lines[0] += '    cab-%1d |' %(cab)
-            lines[1] += '%9.2f |' %(PL[(cab*4)+0]/100.)
-            lines[2] += '%9.2f |' %(PL[(cab*4)+1]/100.)
-            lines[3] += '%9.2f |' %(PL[(cab*4)+2]/100.)
-            lines[4] += '%9.2f |' %(PL[(cab*4)+3]/100.)
-        
-        # print lines to screen or file, see printInfo
-        self.addInfo('=== Station sensor settings ===')
-        for line in lines:
-            self.addInfo(line)
-    
-    #---------------------------------------
-    def sendFlashEraseCmd(self):
-        try:
-            if (self.version < 141):
-                cmd = struct.pack('hHH', 200, 0, 0)
-            else:
-                cmd = struct.pack('hHH', self.FLASH_ERASE, 0, 0)
-            self.sck.send(cmd)
-        except socket.error:
-            self.setInfo("socket error, try to reconnect")
-            self.disconnectHost()
-            self.connectToHost()
-        return
-    #---------------------------------------
-    def sendFlashWriteCmd(self, sector=0, offset=0, data=''):
-        try:
-            if (self.version < 141):
-                cmd = struct.pack('hHH', 201, sector, offset)
-            else:
-                cmd = struct.pack('hHH', self.FLASH_WRITE, sector, offset)
-            if (len(data) > 0):
-                if (len(data) < 1024):
-                    data = data + ('\xFF' * (1024 - len(data)))
-                cmd = cmd + data
-            self.sck.send(cmd)
-        except socket.error:
-            self.setInfo("socket error, try to reconnect")
-            self.disconnectHost()
-            self.connectToHost()
-        return
-    #---------------------------------------
-    def recvFlashAck(self):
-        socketError = False    
-        try:
-            self.sck.settimeout(5.0)
-            data = self.sck.recv(4)
-        except socket.error:
-            socketError = True
-            self.setInfo("socket error, try to reconnect")
-            self.disconnectHost()
-            self.connectToHost()
-        if socketError:
-            return(0,-1)
-            
-        header = struct.unpack('hh', data)
-        cmdId = header[0]
-        status = header[1]
-        return (cmdId, status) 
-
+## P.Donker ASTRON februari 2010
+## EC control module
+
+import socket
+import struct
+import time
+
+class EC:
+    # cmdIDs from TCP PROTOCOL ec-controller
+    EC_NONE             = 0
+    EC_STATUS           = 1
+    EC_SETTINGS         = 2
+    EC_CTRL_TEMP        = 3
+    EC_VERSION          = 5
+    EC_SET_CTRL_MODE    = 10
+    EC_SET_FANS         = 11
+    EC_SET_TEMP         = 15
+    EC_SET_HEATER       = 17
+    EC_SET_48           = 20
+    EC_RESET_48         = 22
+    EC_SET_230          = 25
+    EC_RESET_230        = 27
+    EC_RESET_TRIP       = 28
+    EC_SET_DOOR_CTRL    = 50
+    EC_SET_HUM_CTRL     = 52
+    EC_SET_SECOND       = 115
+    
+    SET_MAX_CTRL_TEMP   = 150
+    SET_MIN_CTRL_TEMP   = 151
+    SET_WARN1_TEMP      = 152
+    SET_WARN2_TEMP      = 153
+    SET_TRIP_TEMP       = 154
+    SET_HEATER_TEMP     = 155
+    SET_MAX_HUM         = 160
+    SET_TRIP_HUM        = 161
+    SET_START_SIDE      = 170
+    SET_BALANCE_POINT   = 171
+    SET_MAX_CHANGE      = 172
+    SET_SEEK_TIME       = 173
+    SET_SEEK_CHANGE     = 174
+                        
+    SET_TEMP_OFFSET     = 180
+    SET_TEMP_MULT       = 181
+    SET_HUM_OFFSET      = 182
+    SET_HUM_MULT        = 183
+    SENSOR_SETTINGS     = 184
+    SET_LOG             = 1111
+    FLASH_ERASE         = 2330
+    FLASH_WRITE         = 2331
+    RESTART             = 2440
+
+    MODE_OFF     = 0
+    MODE_ON      = 1
+    MODE_AUTO    = 2
+    MODE_MANUAL  = 3
+    MODE_STARTUP = 4
+    MODE_SEEK    = 5
+    PWR_OFF      = 0
+    PWR_ON       = 1
+    LCU          = 230
+
+    printToScreen = False
+    printToFile = False
+    cabs = None
+    nCabs = None
+    host = None
+    station = None
+    port = 10000
+    sck = None
+    logger = False
+    info = ''
+    version = 0
+    versionstr = 'V-.-.-'
+    
+    def __init__(self, addr='0.0.0.0', nCabs=3):
+        self.nCabs = nCabs
+        if nCabs == 1: self.cabs = [0]
+        if nCabs == 3: self.cabs = [0,1,3]
+        if nCabs == 4: self.cabs = [0,1,2,3]
+        self.host = addr
+        try:
+            (hostname,a,b) = socket.gethostbyaddr(addr)
+            self.station = hostname.split('.')[0]
+        except:
+            self.station = 'Unknown'
+                
+    def setInfo(self, info):
+        self.info = info
+        if self.printToScreen:
+            print self.info
+            self.info = ''
+        else: self.info += '\n'
+        return
+
+    def addInfo(self, info):
+        self.info += info
+        if self.printToScreen:
+            print self.info
+            self.info = ''
+        else: self.info += '\n'
+        return
+    
+    def printInfo(self, state=True):
+        self.printToScreen = state
+        return
+ 
+    def printFile(self, state=True):
+        self.printToFile = state
+        return
+    
+    def hex2bit(self, val=0, bits=16):
+        bit = ''
+        for i in range(bits-1,-1,-1):
+            if val & (1 << i):
+                bit += '1'
+            else:
+                bit += '0'
+        return(bit) 
+
+    #---------------------------------------
+    def connectToHost(self):
+        self.setInfo("connecting to %s on port %d" %(self.host, self.port))
+        connected = False
+
+        try:
+            self.sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        except socket.error:
+            self.sck.close()
+            return(connected)
+
+        try:
+            self.sck.settimeout(3.0)
+            self.sck.connect((self.host, self.port))
+            connected = True
+            #time.sleep(0.1)
+        except socket.error:
+            self.sck.close()
+        return(connected)
+            
+    #---------------------------------------
+    def disconnectHost(self):
+        self.sck.close()
+        #time.sleep(0.1)
+        return
+        
+    #---------------------------------------
+    def sendCmd(self, cmdId=0, cab=-1, value=0):
+        if (cmdId == self.EC_NONE):
+            return (false)
+        try:
+            cmd = struct.pack('hhh', cmdId, cab, int(value))
+            self.sck.send(cmd)
+        except socket.error:
+            self.setInfo("socket error, try to reconnect")
+            self.disconnectHost()
+            time.sleep(10.0)
+            self.connectToHost()
+        return
+    #---------------------------------------
+    def recvAck(self):
+        socketError = False    
+        try:
+            self.sck.settimeout(1.0)
+            data = self.sck.recv(6)
+        except socket.error:
+            socketError = True
+            self.setInfo("socket error, try to reconnect")
+            #self.disconnectHost()
+            #self.connectToHost()
+        if socketError:
+            return(0,0,[])
+            
+        header = struct.unpack('hhh', data)
+        cmdId = header[0]
+        status = header[1]
+        PLSize = header[2]
+        if (PLSize > 0):
+            data = self.sck.recv(PLSize)
+            fmt = 'h' * int(PLSize / 2)
+            PL = struct.unpack(fmt, data)
+        else:
+            PL = []
+        return (cmdId, status, PL) 
+    #---------------------------------------
+    def recvLog(self):
+        socketError = False    
+        try:
+            self.sck.settimeout(10.0)
+            data = self.sck.recv(200)
+        except socket.error:
+            socketError = True
+        if socketError:
+            return
+        print str(data).replace('\r',''),
+        return 
+    
+    #---------------------------------------
+    def setSecond(self, sec=0):
+        self.sendCmd(self.EC_SET_SECOND, 0, sec)
+        (cmdId, status, PL) = self.recvAck()
+        return
+    #---------------------------------------
+    def waitForSync(self):
+        while ((time.gmtime()[5] % 10) != 7):
+            time.sleep(0.5)
+        time.sleep(1.0)
+        return
+    #---------------------------------------
+    def waitForUpdate(self):
+        while ((time.gmtime()[5] % 10) != 3):
+            time.sleep(0.5)
+        time.sleep(1.0)
+        return
+    #---------------------------------------
+    def setLogger(self, level=0):
+        if (self.version >= 150):
+            self.setInfo('EC set logger to level %d' %(level))
+            self.sendCmd(self.SET_LOG, 0, level)
+            #(cmdId, status, PL) = self.recvAck()
+            return 
+        else:
+            self.setInfo('setting log level not possible in this EC version')
+        return 
+    #---------------------------------------
+    
+    def restart(self):
+        if (self.version >= 107) or (self.version == 1):
+            self.setInfo('EC restart')
+            if self.version < 110:
+                self.sendCmd(211)
+            elif self.version < 141:
+                self.sendCmd(210)
+            else:
+                self.sendCmd(self.RESTART)
+                time.sleep(2.0)
+            #(cmdId, status, PL) = self.recvAck()
+            return 1
+        else:
+            self.setInfo('restart not possible in this EC version')
+        return 0
+    #---------------------------------------
+    def setControlMode(self, cab=-1, mode=MODE_AUTO):
+        self.sendCmd(self.EC_SET_CTRL_MODE, cab, mode)
+        (cmdId, status, PL) = self.recvAck()
+        self.setInfo('SetControlMode cab %d to %d' %(cab, mode))
+        return
+    #---------------------------------------
+    def setPower(self, pwr=-1, state=PWR_ON):
+        if ((pwr == 48) or (pwr == -1)):
+            self.sendCmd(self.EC_SET_48, 0, state)
+            (cmdId, status, PL) = self.recvAck()
+            self.setInfo('Power Set 48V to %d' %(state))
+        if ((pwr == self.LCU) or (pwr == -1)):
+            self.sendCmd(self.EC_SET_230, 0, state)
+            (cmdId, status, PL) = self.recvAck()
+            self.setInfo('Power Set LCU to %d' %(state))
+        return
+    #---------------------------------------
+    def resetPower(self, pwr=-1):
+        if ((pwr == 48) or (pwr == -1)):
+            self.sendCmd(self.EC_RESET_48, 0, 0)
+            (cmdId, status, PL) = self.recvAck()
+            self.setInfo('PowerReset 48V')
+        if ((pwr == self.LCU) or (pwr == -1)):
+            self.sendCmd(self.EC_RESET_230, 0, 0)
+            (cmdId, status, PL) = self.recvAck()
+            self.setInfo('PowerReset LCU')
+
+    #---------------------------------------
+    def resetTrip(self):
+        self.sendCmd(self.EC_RESET_TRIP, -1, 0)
+        (cmdId, status, PL) = self.recvAck()
+        self.setInfo('Reset Trip System')
+
+   #---------------------------------------
+    ## search for new setpoint, works only in control mmode 1
+    def seekNewSetpoint(self, cab=-1):
+        self.sendCmd(self.EC_SET_MODE, cab, MODE_SEEK)
+        (cmdId, status, PL) = self.recvAck()
+        self.setInfo('Find newSetpoint cab %d' %(cab))
+    #---------------------------------------
+    ## set new setpoint, works only in manual mode
+    def setTemperature(self, cab=-1, temp=20.0):
+        temperature = int(temp * 100.)
+        self.sendCmd(self.EC_SET_TEMP, cab, temperature)
+        (cmdId, status, PL) = self.recvAck()
+        self.setInfo('SetTemperature cab %d to %4.2f' %(cab,temp))
+    #---------------------------------------
+    ## set new setpoint, works only in manual mode
+    def setFans(self, cab=-1, fans=0x0f):
+        self.sendCmd(self.EC_SET_FANS, cab, fans)
+        (cmdId, status, PL) = self.recvAck()
+        self.setInfo('SetFans cab %d to %X' %(cab,fans))
+    #---------------------------------------
+    ## set door control to on(1) or off(0)
+    def setDoorControl(self, cab=-1, state=1):
+        self.sendCmd(self.EC_SET_DOOR_CTRL, cab, state)
+        (cmdId, status, PL) = self.recvAck()
+        self.setinfo('SetDoorControl cab %d to %d' %(cab, state))
+    #---------------------------------------
+    ## set hum control to on(1) or off(0)
+    def setHumControl(self, cab=-1, state=1):
+        self.sendCmd(self.EC_SET_HUM_CTRL, cab, state)
+        (cmdId, status, PL) = self.recvAck()
+        self.setInfo('SetHumidityControl cab %d to %d' %(cab, state))
+    #---------------------------------------
+    def setHeater(self, mode=0):
+        self.sendCmd(self.EC_SET_HEATER, -1, mode)
+        (cmdId, status, payload) = self.recvAck()
+        
+        if (mode == self.MODE_ON): self.setInfo('heater is turned ON')
+        if (mode == self.MODE_OFF): self.setInfo('heater is turned OFF')
+        if (mode == self.MODE_AUTO): self.setInfo('heater set to AUTO')
+    #---------------------------------------
+    def getVersion(self):
+        self.sendCmd(self.EC_VERSION)
+        (cmdId, status, PL) = self.recvAck()
+        
+        version = int((PL[0]*100)+(PL[1]*10)+PL[2])
+        versionstr = 'V%d.%d.%d' %(PL)
+        self.version = version
+        self.versionstr = versionstr
+        self.setInfo('EC software version %d.%d.%d' %(PL))
+        return version, versionstr
+    #---------------------------------------
+    def getStatus(self):
+        ec_mode = ('OFF','ON','AUTO','MANUAL','STARTUP','AUTO-SEEK','ABSENT')
+        fan = ('.  .  .  .','.  .  .  .','.  2  .  .','1  2  .  .',\
+               '.  .  3  .','.  .  .  .','.  2  3  .','1  2  3  .',\
+               '.  .  .  .','.  .  .  .','.  .  .  .','.  .  .  .',\
+               '.  .  3  4','.  .  .  .','.  2  3  4','1  2  3  4')
+        
+        door = ('CLOSED','FRONT_OPEN','BACK_OPEN','ALL_OPEN')
+        fanstate = ('BAD | BAD ','GOOD| BAD ','BAD | GOOD','GOOD| GOOD')
+        fanestate= ('OFF | OFF ','ON  | OFF ','OFF | ON  ','ON  | ON  ')
+        onoff = ('OFF','ON')
+        badok = ('BAD','OK')
+       
+        # get information from EC
+        self.sendCmd(self.EC_CTRL_TEMP)
+        (cmdId, status, PL1) = self.recvAck()
+        self.sendCmd(self.EC_STATUS)
+        (cmdId, status, PL2) = self.recvAck()
+        if len(PL1) == 0 or len(PL2) == 0: return     
+        # fill lines with data    
+        lines = []
+
+        if self.nCabs == 4:
+            lines.append('temperature cab3 = %5.2f' %(PL2[2]/100.))
+            lines.append('humidity cab3    = %5.2f' %(PL2[3]/100.))
+            lines.append('cabinet fans     = all on')
+            lines.append('heater state     = %s' %(onoff[PL2[(3*7)+6]]))
+            lines.append('power 48V state  = %s' %(onoff[(PL2[28] & 1)]))
+            lines.append('power LCU state  = %s' %(onoff[(PL2[28] >> 1)]))
+            lines.append('lightning state  = %s' %(badok[(PL2[29] & 1)]))
+
+        else:
+            lines.append('            |')
+            lines.append('mode        |')
+            lines.append('status      |')
+            lines.append('set point   |')
+            lines.append('temperature |')
+            lines.append('humidity    |')
+            lines.append('fans        |')
+            lines.append('fane        |')
+            lines.append('fans state  |')
+            lines.append('doors       |')
+            lines.append('heater      |')
+
+            for nCab in range(self.nCabs):
+                cab = self.cabs[nCab]
+                lines[0] += '  cabinet %1d |' %(cab)
+                lines[1] += '%11s |' %(ec_mode[PL2[(cab*7)]])
+                lines[2] += '     %#06x |' %(PL2[(cab*7)+1])
+                lines[3] += '%11.2f |' %(PL1[cab]/100.)
+                lines[4] += '%11.2f |' %(PL2[(cab*7)+2]/100.)
+                lines[5] += '%11.2f |' %(PL2[(cab*7)+3]/100.)
+                lines[6] += '%11s |' %(fan[(PL2[(cab*7)+4]&0x0f)])
+                lines[7] += '%11s |' %(fanestate[(PL2[(cab*7)+4]>>4)&0x3])  
+                lines[8] += '%11s |' %(fanstate[(PL2[(cab*7)+4]>>6)&0x3])  
+                lines[9] += '%11s |' %(door[(PL2[(cab*7)+5]&0x03)])
+                if (cab != 3):
+                   lines[10] += '%11s |' %('none')
+                else:
+                   lines[10] += '%11s |' %(onoff[PL2[(cab*7)+6]])
+
+            if self.nCabs == 1: i = 7
+            else: i = 28
+            lines.append('power 48V state  = %s' %(onoff[(PL2[i] & 1)]))
+            lines.append('power LCU state  = %s' %(onoff[(PL2[i] >> 1)]))
+            lines.append('lightning state  = %s' %(badok[(PL2[i+1] & 1)]))
+        
+        # print lines to screen or file, see printInfo
+        info = 'status %s (%s)     %s ' %(self.station, self.versionstr, time.asctime())
+        self.setInfo('-' * len(info))
+        self.addInfo(info)
+        self.addInfo('-' * len(info))
+        for line in lines:
+            self.addInfo(line)
+        # print data to file if selected
+        if (self.printToFile == 1):
+            tm = time.gmtime()
+            filename = '%s_%d%02d%02d.dat' %(self.station,tm.tm_year, tm.tm_mon, tm.tm_mday)
+            df = open(filename, mode='a')
+            df.write('%f ' %(time.time()))
+            for cab in self.cabs:
+                # print cabnr, setpoint, temperature, humidity, fansstate, heaterstate
+                df.write('[%d] %3.2f %3.2f %3.2f %d %d ' %\
+                        ( cab, PL1[cab]/100., PL2[(cab*7)+2]/100., PL2[(cab*7)+3]/100.,
+                          PL2[(cab*7)+4], PL2[(cab*7)+6]))
+            df.write('\n')
+            df.close()
+    #---------------------------------------
+    def getTripStatus(self):
+        # get information from EC
+        self.sendCmd(self.EC_STATUS)
+        (cmdId, status, PL) = self.recvAck()
+        state = False
+        if (PL[1] & 0x1000):
+            self.addInfo('trip in cabinet 0')
+            state = True
+        if (PL[8] & 0x1000):
+            self.addInfo('trip in cabinet 1')
+            state = True
+        if (PL[22] & 0x1000):
+            self.addInfo('trip in cabinet 3')
+            state = True
+        
+        if (PL[1] & 0x6000):
+            self.addInfo('warning in cabinet 0')
+            state = True
+        if (PL[8] & 0x6000):
+            self.addInfo('warning in cabinet 1')
+            state = True
+        if (PL[22] & 0x6000):
+            self.addInfo('warning in cabinet 3')
+            state = True
+
+        if (state == False):
+            self.addInfo('NO trips available')
+        return(state)
+    
+    #---------------------------------------
+    def getPowerStatus(self):
+        state = ('OFF','ON')
+        # get information from EC
+        self.sendCmd(self.EC_STATUS)
+        (cmdId, status, PL) = self.recvAck()
+        
+        self.addInfo('Power: 48V = %s, LCU = %s' %(state[(PL[28] & 1)], state[(PL[28] >> 1)]))
+        
+    #---------------------------------------
+    def getControlTemp(self):
+        self.sendCmd(self.EC_CTRL_TEMP)
+        (cmdId, status, PL) = self.recvAck()
+        lines = []
+        lines.append('                 |')
+        lines.append('min control temp |')
+        
+        for cab in self.cabs:
+            lines[0] += '  cab-%1d |' %(cab)
+            lines[1] += '%9.2f |' %(PL[cab]/100.)
+    #---------------------------------------    
+    def getSettings(self):
+        self.sendCmd(self.EC_SETTINGS)
+        (cmdId, status, PL) = self.recvAck()
+            #self.info =  len(PL))
+        # fill lines with data    
+        lines = []
+        lines.append('                 |')
+        lines.append('start side       |')
+        lines.append('balance point    |') 
+        lines.append('max hour change  |')
+        lines.append('seek time        |')
+        lines.append('max seek change  |')
+        lines.append('min control temp |')
+        lines.append('max control temp |')
+        lines.append('heater temp      |')
+        lines.append('warn1 temp       |')
+        lines.append('warn2 temp       |')
+        lines.append('trip temp        |')
+        lines.append('max humidity     |')
+        lines.append('trip humidity    |')
+
+
+        for nCab in range(self.nCabs):
+            cab = self.cabs[nCab]
+            lines[0] += '    cab-%1d |' %(cab)
+            lines[1] += '%9d |'    %(PL[(cab*13)+10])
+            lines[2] += '%9d |'    %(PL[(cab*13)+9])
+            lines[3] += '%9.2f |'  %(PL[(cab*13)+8]/100.)
+            lines[4] += '%9d |'    %(PL[(cab*13)+11])
+            lines[5] += '%9.2f |'  %(PL[(cab*13)+12]/100.)
+            lines[6] += '%9.2f |'  %(PL[(cab*13)+0]/100.)
+            lines[7] += '%9.2f |'  %(PL[(cab*13)+1]/100.)
+            lines[8] += '%9.2f |'  %(PL[(cab*13)+2]/100.)
+            lines[9] += '%9.2f |'  %(PL[(cab*13)+3]/100.)
+            lines[10] += '%9.2f |'  %(PL[(cab*13)+4]/100.)
+            lines[11] += '%9.2f |'  %(PL[(cab*13)+5]/100.)
+            lines[12] += '%9.2f |' %(PL[(cab*13)+6]/100.)
+            lines[13] += '%9.2f |' %(PL[(cab*13)+7]/100.)
+        
+        # print lines to screen or file, see printInfo
+        self.addInfo('=== Station settings ===')
+        for line in lines:
+            self.addInfo(line)
+
+    #---------------------------------------
+    def setSetting(self, cmd=0, cab=-1, val=0):
+        self.sendCmd(cmd, cab, val)
+        (cmdId, status, PL) = self.recvAck()
+    
+    #---------------------------------------    
+    def getSensorSettings(self):
+        self.sendCmd(self.SENSOR_SETTINGS)
+        (cmdId, status, PL) = self.recvAck()
+        #self.info =  len(PL))
+        # fill lines with data    
+        lines = []
+        lines.append('                     |')
+        lines.append('temperature offset   |')
+        lines.append('temperature multiply |')    
+        lines.append('humidity offset      |')
+        lines.append('humidity multiply    |')
+        
+        for nCab in range(self.nCabs):
+            cab = self.cabs[nCab]
+            lines[0] += '    cab-%1d |' %(cab)
+            lines[1] += '%9.2f |' %(PL[(cab*4)+0]/100.)
+            lines[2] += '%9.2f |' %(PL[(cab*4)+1]/100.)
+            lines[3] += '%9.2f |' %(PL[(cab*4)+2]/100.)
+            lines[4] += '%9.2f |' %(PL[(cab*4)+3]/100.)
+        
+        # print lines to screen or file, see printInfo
+        self.addInfo('=== Station sensor settings ===')
+        for line in lines:
+            self.addInfo(line)
+    
+    #---------------------------------------
+    def sendFlashEraseCmd(self):
+        try:
+            if (self.version < 141):
+                cmd = struct.pack('hHH', 200, 0, 0)
+            else:
+                cmd = struct.pack('hHH', self.FLASH_ERASE, 0, 0)
+            self.sck.send(cmd)
+        except socket.error:
+            self.setInfo("socket error, try to reconnect")
+            self.disconnectHost()
+            self.connectToHost()
+        return
+    #---------------------------------------
+    def sendFlashWriteCmd(self, sector=0, offset=0, data=''):
+        try:
+            if (self.version < 141):
+                cmd = struct.pack('hHH', 201, sector, offset)
+            else:
+                cmd = struct.pack('hHH', self.FLASH_WRITE, sector, offset)
+            if (len(data) > 0):
+                if (len(data) < 1024):
+                    data = data + ('\xFF' * (1024 - len(data)))
+                cmd = cmd + data
+            self.sck.send(cmd)
+        except socket.error:
+            self.setInfo("socket error, try to reconnect")
+            self.disconnectHost()
+            self.connectToHost()
+        return
+    #---------------------------------------
+    def recvFlashAck(self):
+        socketError = False    
+        try:
+            self.sck.settimeout(5.0)
+            data = self.sck.recv(4)
+        except socket.error:
+            socketError = True
+            self.setInfo("socket error, try to reconnect")
+            self.disconnectHost()
+            self.connectToHost()
+        if socketError:
+            return(0,-1)
+            
+        header = struct.unpack('hh', data)
+        cmdId = header[0]
+        status = header[1]
+        return (cmdId, status) 
+
diff --git a/LCU/StationTest/test/hbatest/beamduur.sh b/LCU/StationTest/test/hbatest/beamduur.sh
index 5bdb9c02c4b6af587445ba642004265737d7c3a9..43d5b8086fe196916fa7c2d9641ae2be1efe1d8c 100644
--- a/LCU/StationTest/test/hbatest/beamduur.sh
+++ b/LCU/StationTest/test/hbatest/beamduur.sh
@@ -1,59 +1,59 @@
-#!/bin/bash
-#
-# This test is a duration test to test the modem communication between RCU and HBA.
-# The beamserver is used in this test.
-#
-# Version 1.3  29-04-10   M.J.Norden
-
-rm -f /Beamdata/output_*.dat
-let hbamode=5
-let points=10
-
-killall beamctl
-rspctl --splitter=0
-
-station=`hostname -s`
-
-# determine the number of rcu's 
-if [ -e /opt/lofar/etc/RemoteStation.conf ]; then
-  let rspboards=`sed -n  's/^\s*RS\.N_RSPBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
-  let rcus=$rspboards*8
-else
-  echo "Could not find /opt/lofar/etc/RemoteStation.conf"
-  let rspboards=12
-  let rcus=$rspboards*8
-fi
-
-# determine the time between each skyscan position
-if [ -e /opt/lofar/etc/BeamServer.conf ]; then
-  let waittime=`sed -n  's/^\s*BeamServer\.HBA_INTERVAL\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/BeamServer.conf`
-else
-  echo "Could not find /opt/lofar/etc/BeamServer.conf"
-  let waittime=10
-fi
-
-swlevel 3
-
-echo "This is station "$station
-echo "The number of RCU's is "$rcus
-echo "The rcumode is "$hbamode
-echo "The wait time is "$waittime
-echo "The number of scanpoints "$points*$points
-let duration=$waittime*$points*$points
-echo "The duration of this measurement is "$duration" seconds"
-let nrcus=$rcus-1
-sleep 10
-
-beamctl --array=HBA --rcus=0:$nrcus --rcumode=$hbamode --subbands=300:310 --beamlets=0:10 --direction=$points,$points,SKYSCAN &
-sleep 25
-
-for (( passes=1; passes<($points*$points)+1; passes++)) 
-do
-	echo "this is loop nr "$passes
-	rspctl --realdelays > ./Beamdata/output_$passes.dat
-	sleep $waittime 
-done
-
-
-
-
+#!/bin/bash
+#
+# This test is a duration test to test the modem communication between RCU and HBA.
+# The beamserver is used in this test.
+#
+# Version 1.3  29-04-10   M.J.Norden
+
+rm -f /Beamdata/output_*.dat
+let hbamode=5
+let points=10
+
+killall beamctl
+rspctl --splitter=0
+
+station=`hostname -s`
+
+# determine the number of rcu's 
+if [ -e /opt/lofar/etc/RemoteStation.conf ]; then
+  let rspboards=`sed -n  's/^\s*RS\.N_RSPBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
+  let rcus=$rspboards*8
+else
+  echo "Could not find /opt/lofar/etc/RemoteStation.conf"
+  let rspboards=12
+  let rcus=$rspboards*8
+fi
+
+# determine the time between each skyscan position
+if [ -e /opt/lofar/etc/BeamServer.conf ]; then
+  let waittime=`sed -n  's/^\s*BeamServer\.HBA_INTERVAL\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/BeamServer.conf`
+else
+  echo "Could not find /opt/lofar/etc/BeamServer.conf"
+  let waittime=10
+fi
+
+swlevel 3
+
+echo "This is station "$station
+echo "The number of RCU's is "$rcus
+echo "The rcumode is "$hbamode
+echo "The wait time is "$waittime
+echo "The number of scanpoints "$points*$points
+let duration=$waittime*$points*$points
+echo "The duration of this measurement is "$duration" seconds"
+let nrcus=$rcus-1
+sleep 10
+
+beamctl --array=HBA --rcus=0:$nrcus --rcumode=$hbamode --subbands=300:310 --beamlets=0:10 --direction=$points,$points,SKYSCAN &
+sleep 25
+
+for (( passes=1; passes<($points*$points)+1; passes++)) 
+do
+	echo "this is loop nr "$passes
+	rspctl --realdelays > ./Beamdata/output_$passes.dat
+	sleep $waittime 
+done
+
+
+
+
diff --git a/LCU/StationTest/test/xcstatistics/xcstatistics_hba.sh b/LCU/StationTest/test/xcstatistics/xcstatistics_hba.sh
index e05e390b55d72a7f80b75428b08f755fdeb76ef2..e1baa985f8898acf345ffbeb6007df3ac5901958 100755
--- a/LCU/StationTest/test/xcstatistics/xcstatistics_hba.sh
+++ b/LCU/StationTest/test/xcstatistics/xcstatistics_hba.sh
@@ -1,32 +1,32 @@
-#!/bin/sh
-# 1.3 xcstatistics test to check SerDes Ring with LBH antennas
-# 03-12-10, M.J Norden
-# HBA input with antenna
-
-killall beamctl
-rspctl --rcuprsg=0
-rspctl --wg=0
-rspctl --splitter=1
-
-swlevel 3
-sleep 5
-beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=100:110 --beamlets=0:10 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=100:110 --beamlets=1000:1010 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
-sleep 3
-echo "check xcstat and xcangle"
-
-rspctl --xcsubband=256
-echo ==========================
-echo "Amplitudes" `hostname -s`
-echo ==========================
-rspctl --xcstatistics& 
-sleep 20 && kill $!
-
-echo ======================
-echo "Phases" `hostname -s`
-echo ======================
-rspctl --xcangle --xcstatistics &
-sleep 20 && kill $!
-killall beamctl
-
+#!/bin/sh
+# 1.3 xcstatistics test to check SerDes Ring with LBH antennas
+# 03-12-10, M.J Norden
+# HBA input with antenna
+
+killall beamctl
+rspctl --rcuprsg=0
+rspctl --wg=0
+rspctl --splitter=1
+
+swlevel 3
+sleep 5
+beamctl --antennaset=HBA_ZERO --rcus=0:47 --rcumode=5 --subbands=100:110 --beamlets=0:10 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+beamctl --antennaset=HBA_ONE --rcus=48:95 --rcumode=5 --subbands=100:110 --beamlets=1000:1010 --anadir=0,1.5708,AZEL --digdir=0,1.5708,AZEL&
+sleep 3
+echo "check xcstat and xcangle"
+
+rspctl --xcsubband=256
+echo ==========================
+echo "Amplitudes" `hostname -s`
+echo ==========================
+rspctl --xcstatistics& 
+sleep 20 && kill $!
+
+echo ======================
+echo "Phases" `hostname -s`
+echo ======================
+rspctl --xcangle --xcstatistics &
+sleep 20 && kill $!
+killall beamctl
+