SimpleEPUtest.py

Go to the documentation of this file.
00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2005
00004 #                                     by
00005 #                        The Board of Trustees of the
00006 #                     Leland Stanford Junior University.
00007 #                            All rights reserved.
00008 #
00009 
00010 __facility__ = "Online"
00011 __abstract__ = "Simple test of converted EPU"
00012 __author__   = "J. Panetta <panetta@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online"
00013 __date__     = "2006/01/10 00:08:27"
00014 __updated__  = "$Date: 2006/03/08 00:40:22 $"
00015 __version__  = "$Revision: 1.6 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 import logging as log
00022 import            os
00023 import            time
00024 from   binascii import hexlify
00025 import struct
00026 
00027 
00028 from LICOS_Scripts.lib.testAppBase               import TestAppBase
00029 from LICOS.lib.cmdTlmDb.TelemetryEvent         import TelemetryEvent
00030 from LICOS.lib.LATconstants                    import *
00031 from LICOS.lib.cmdTlmDb.PBC                    import *
00032 from LICOS.lib.cmdTlmDb.FILE                    import *
00033 import VSC
00034 
00035 
00036 #  Example application implementation.
00037 class SimpleEPUtest(TestAppBase):
00038   """\brief LAT startup sequence testing.
00039 
00040   """
00041   def __init__(self, common):
00042     TestAppBase.__init__(self, common)
00043     log.debug("%s.__init__()" % self.getName())
00044 
00045     self.__prefDir = os.path.join(ONLINE_ROOT, 'LICOS/tests/data')
00046     self.__prefPrompt = "Select EPU test configuration"
00047     preReqSeq = []
00048 
00049   def getName(self):
00050     return self.__class__.__name__
00051 
00052   def testSetup(self):
00053     #self.testScriptPrefs = self.readTestscriptPreferences(self.__prefDir, self.__prefPrompt)
00054     #if self.testScriptPrefs is None:
00055     #  log.debug("Operator cancelled configuration file selection")
00056     #  return -1
00057 
00058 
00059     self.__siuId  = 0
00060     self.__epuId  = 0
00061     self.__pduId  = None
00062 
00063     self.vsc.siuSelect(getattr(self.vsc, 'AB'))
00064     self.vsc.daqSelect(getattr(self.vsc, 'AA'))
00065 
00066 
00067   def testStartRun(self):
00068     pass
00069 
00070   def testRun(self):
00071     log.debug("%s.startRun()" % self.getName())
00072     self.setCompletionStatus(self.COMPL_STATUS_UNDEFINED)
00073 
00074     result = True
00075     try:
00076       log.info("sending SSR off and load-shed")
00077       # self.lcat.PBC.LPBCRESET(LPBCLATUNIT=self.__epuId+1,
00078       #                         LPBCPAD1=0,
00079       #                         LPBCPAD2=0,
00080       #                         LPBCPRIFLAGSHI=0,
00081       #                         LPBCPRIFLAGSLO=0)
00082 
00083       self.vsc.ssr(VSC.VscProxy.Disable)
00084       time.sleep(2)  # just making sure.
00085 
00086       self.lcat.LIM.LIMLOADSHED()
00087       time.sleep(15)  # 15 seconds or so for load shed to go through
00088 
00089       log.info("Waiting for SIU boot telemetry")
00090       result &= self.waitForSiuBootTelem()
00091       if not result:
00092         raise "Timeout waiting for primary boot"
00093 
00094       log.info("Secondary booting SIU")
00095       result &= self.bootSIU()
00096       if not result:
00097         raise "bad result in secondary boot"
00098 
00099       log.info("Waiting for LHK...")
00100       result &= self.waitForLatHSK()
00101       if not result:
00102         raise "timeout waiting for LAT telem"
00103 
00104       time.sleep(5)
00105 
00106       log.info("Sending MainFeed, and enabling SSR")
00107       result &= self.sendMainFeed()
00108       if not result:
00109         raise "Bad result in mainfeed"
00110 
00111       time.sleep(5)
00112 
00113       log.info("Sending Power-on to EPU")
00114       result &= self.powerEPU()
00115       if not result:
00116         raise "Bad result in powerEPU"
00117 
00118       log.info("Waiting for EPU boot telemetry")
00119       result &= self.waitForEpuBootTelem()
00120       if not result:
00121         raise "Timeout waiting for EPU boot telem"
00122 
00123       log.info("Attempting to upload to EPU during primary boot")
00124       result &= self.uplFileEPUpri()
00125 
00126 
00127       log.info("Sending Secondary EPU boot")
00128       result &= self.bootEPU()
00129       if not result:
00130         raise "Bad result in bootEPU"
00131 
00132       time.sleep(15)
00133 #      log.info("Attempting to download serial number from EPU %d" % self.__epuId)
00134 #      result &= self.checkEpuMem()
00135 
00136       log.info("attempting to upload file during secondary boot")
00137       result &= self.uplFileEPUsec()
00138 
00139 
00140 
00141     except self.StopRequestedException, e:
00142       msg = ("%s was aborted by the operator while executing step: %s - %s, test: %s"
00143                   % (self.getName(), e.args[1], e.args[2], e.args[3]))
00144       log.error(msg)
00145       result = False
00146       self.setCompletionStatus(self.COMPL_STATUS_ABORTED)
00147     else:
00148       if not result:
00149         log.error("One or more of the previous tests failed.")
00150         log.error("Setting status to *****FAILED******")
00151         self.setCompletionStatus(self.COMPL_STATUS_FAILED)
00152       else:
00153         self.setCompletionStatus(self.COMPL_STATUS_PASSED)
00154     # End of run
00155     return
00156 
00157 
00158 
00159   def testStopRun(self):
00160     pass
00161 
00162   def bootSIU(self):
00163     result = True
00164     log.debug("Sending secondary boot command to SIU %d..." % self.__siuId)
00165     # boot the following:
00166     #  RTOS_source    = UPPER (1)
00167     #  SBC executable = UPPER (1)
00168     #  RTOS database  = RAM   (0)
00169     # flags_hi = 0x5400 # regular SBC upper bank default boot
00170     # flags_hi = 0x5000 # VXW, SBC_NOM, DDT
00171     flags_hi = 0x5400
00172     flags_hi = 0xA800
00173     # flags_lo = 0xC000 # Mount EE0, EE1 as file systems
00174     flags_lo = 0xC000
00175     self.vsc.bootSIU(0, flags_hi, flags_lo )
00176     return result
00177 
00178   def powerEPU(self):
00179     result = True
00180     self.vsc.powerOnEpuOnly(epuId = self.__epuId, pduId = 0)
00181 
00182     return result
00183 
00184 
00185   def bootEPU(self):
00186     result = True
00187 
00188     # boot the following:
00189     #  RTOS_source    = UPPER (1)
00190     #  SBC executable = UPPER (1)
00191     #  RTOS database  = RAM   (0)
00192     # flags_hi = 0x5400 # regular SBC upper bank default boot
00193     # flags_hi = 0x5000 # VXW, SBC_NOM, DDT
00194     PBC = self.lcat.PBC
00195     flags_hi = 0x5400
00196     flags_hi = 0xA800
00197     flags_hi = 0x8800
00198     # flags_lo = 0xC000 # Mount EE0, EE1 as file systems
00199     flags_lo = 0xC000
00200     PBC.LPBCRTOSEXEC(LPBCLATUNIT = self.__epuId+1,
00201                      LPBCPAD1    = 0,
00202                      LPBCPAD2    = 0,
00203                      LPBCSBCFLAGSHI = flags_hi,
00204                      LPBCSBCFLAGSLO = flags_lo)
00205 
00206 
00207     return result
00208 
00209   def sendMainFeed(self):
00210     result = True
00211     # MainFeedOn command with siuId=0, pduId=0, mfPri=1, dabPri=1, dabRed=0
00212     self.vsc.mainFeedOn( siuId = self.__siuId,
00213                          pduId = 0,#self.__pduId,
00214                          mfPri = 1,
00215                          dabPri = 1,
00216                          dabRed = 0)
00217     self.vsc.ssr(VSC.VscProxy.Enable)
00218     time.sleep(3)
00219     return result
00220 
00221 
00222   def waitForLatHSK(self):
00223     result = True
00224     latHskTlm  = TelemetryEvent(self.getTelemHandler(),
00225                                 range(0x210, 0x231))
00226     latHskTlm.enable()
00227     log.info("Waiting for LAT housekeeping telemetry...")
00228     payloads = latHskTlm.waitForPayload([], LONG_TIMEOUT)
00229     latHskTlm.disable()
00230     if payloads is not None:
00231       msg = "LAT housekeeping telemetry received."
00232       log.info(msg)
00233     else:
00234       msg = "LAT housekeeping telemetry is not present."
00235       log.warning(msg)
00236       result = False
00237     return result
00238 
00239   def waitForSiuBootTelem(self):
00240     siuId = self.__siuId
00241     log.info("Waiting for SIU %d boot telemetry..." % siuId)
00242     result = True
00243     siuBootTlm  = TelemetryEvent(self.getTelemHandler(),
00244                                  [self.lcatTlm.getApidFromName('LBTHKP')])
00245     bootMode = None
00246     siuBootTlm.enable()
00247     payloads = siuBootTlm.waitForPayload(["LPBCBOOTSTAT"], STANDARD_TIMEOUT)
00248     siuBootTlm.disable()
00249     if payloads is not None:
00250       bootMode = payloads[0]
00251       if bootMode == PBC.BOOT_MODE_COMMAND:
00252         msg = "SIU boot telemetry received."
00253         log.info(msg)
00254     else:
00255       msg = "SIU boot telemetry is not present."
00256       log.warning(msg)
00257       result = False
00258       return result
00259     if bootMode != PBC.BOOT_MODE_COMMAND:
00260       msg = "SIU boot telemetry received but the boot code mode has unexpected value %s" % PBC.BOOT_CODE_MODES[bootMode]
00261       log.warning(msg)
00262       result = False
00263     return result
00264 
00265   def waitForEpuBootTelem(self):
00266     epuId = self.__epuId
00267     result = True
00268     siuBootTlm  = TelemetryEvent(self.getDiagHandler(),
00269                                  [self.lcatTlm.getApidFromName('LBTEPU%dHKP'%(epuId))])
00270     bootMode = None
00271     siuBootTlm.enable()
00272     payloads = siuBootTlm.waitForPayload(["LPBC%dBOOTSTAT"%(epuId)], STANDARD_TIMEOUT)
00273     siuBootTlm.disable()
00274     if payloads is not None:
00275       bootMode = payloads[0]
00276       if bootMode == PBC.BOOT_MODE_COMMAND:
00277         msg = "EPU boot telemetry received."
00278         log.info(msg)
00279     else:
00280       msg = "EPU boot telemetry is not present."
00281       log.warning(msg)
00282       result = False
00283       return result
00284     if bootMode != PBC.BOOT_MODE_COMMAND:
00285       msg = "EPU boot telemetry received but the boot code mode has unexpected value %s" % PBC.BOOT_CODE_MODES[bootMode]
00286       log.warning(msg)
00287       result = False
00288     return result
00289 
00290   def checkEpuMem(self):
00291     result = True
00292     return result
00293     MEM = self.lcat.MEM
00294 
00295     dumpSize = 4
00296     serialOffsets = (0x10bf0+12, 0x203f0+12, 0x2fbf0+12, 0x3f3f0+12)
00297     unit = FSW_UNIT_NAMES.index('EPU%d'%self.__epuId)
00298     epuDump = {}
00299 
00300     for offset in serialOffsets:
00301       dump = MEM.dumpMemory(unit    = unit,
00302                                        address = MEM_SUROM_START+offset,
00303                                        size    = dumpSize/4,
00304                                        tranID  = 0xBEEF,
00305                                        dest    = FSW_DEST_1553)
00306       epuDump[offset] = struct.unpack('!L', dump)
00307 
00308 
00309     baseSer = None
00310     base    = None
00311     for offset, serial in epuDump.items():
00312       if baseSer is None:
00313         baseSer = serial
00314         base    = offset
00315         continue
00316       if serial != baseSer:
00317         log.error("Serial numbers at memory locations 0x%08x and 0x%08x do not match" % (base, offset))
00318         log.error("Downloaded serials are 0x%08x and 0x%08x respectively" % (baseSer, serial))
00319         result = False
00320         return
00321 
00322     caption = "Input requested"
00323     msg     = "Downloaded serial number 0x%08x.  \nIf this is correct, press OK" % baseSer
00324     result = ( self.getInput(caption, msg, None) is not None )
00325 
00326 
00327     return result
00328 
00329 
00330 
00331 
00332   def uplFileEPUpri(self):
00333     self.lcat.FILE.setPrimaryBoot(True)
00334 
00335     #fn = os.path.expandvars("$ONLINE_ROOT/LICOS/tests/data/12346_hdr")
00336     fn = os.path.join("/nfs/home/panetta/burning/B0-6-1.2",
00337 #                      "fdb/VXW/V6-11-2/vxw_flight/vxw_flight.o.s.z.f")
00338                       "fdb/SBC/V1-3-1/sbc_nominal/libsbc_nominal.o.s.z.f")
00339 #                      "FDB_sbs_epu.o.z.f")
00340 
00341     fid = FswFileID(device=FSW_DEVICE_BOOT,
00342                     directory = 0,
00343                     fileNumber = 1)
00344 
00345     uplF = FswFileFromDisk(fid, fn)
00346 
00347     result = self.lcat.FILE.uploadFile(fswFile = uplF,unit=self.__epuId+1)
00348 
00349     return result
00350 
00351 
00352   def uplFileEPUsec(self):
00353     self.lcat.FILE.setPrimaryBoot(False)
00354 
00355     fn = os.path.join(ONLINE_ROOT, "LICOS/tests/data/12346_hdr")
00356 
00357     fid = FswFileID(device=FSW_DEVICE_RAM,
00358                     directory = 14,
00359                     fileNumber = 7)
00360 
00361     uplF = FswFileFromDisk(fid, fn)
00362 
00363     result = self.lcat.FILE.uploadFile(fswFile = uplF,unit=self.__epuId+1)
00364 
00365     dump = self.lcat.FILE.dumpDirectory(self.__epuId+1,fid)
00366     import sys
00367     dump.dump(sys.stdout)
00368 
00369     f2 = FswFileID(device=FSW_DEVICE_BOOT,
00370                     directory = 0,
00371                     fileNumber = 7)
00372 
00373     dump = self.lcat.FILE.dumpDirectory(self.__epuId+1,f2)
00374     import sys
00375     dump.dump(sys.stdout)
00376 
00377     return result

Generated on Thu Apr 27 20:52:43 2006 for LICOS L02-01-00 by doxygen 1.4.6-NO