hti/HtiCommPlugins/HtiUsbSerialCommPlugin/src/HtiUsbSerialCommEcomPlugin.cpp
changeset 0 a03f92240627
child 4 73ff0d268e1d
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ECOM plugin for serial communication over USB port
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <badesca.h>
       
    21 #include <f32file.h>
       
    22 
       
    23 #include "HtiUsbSerialCommEcomPlugin.h"
       
    24 #include <hticfg.h>
       
    25 #include <htilogging.h>
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES
       
    30 
       
    31 // CONSTANTS
       
    32 _LIT( KHtiUsbSerialError, "HtiUsbSerialError" );
       
    33 _LIT( KHtiOkButton, "OK" );
       
    34 
       
    35 _LIT( KHtiCfgPath,          "\\" ); // root of drive
       
    36 _LIT( KHtiUsbSerialCommCfg, "HTIUsbSerialComm.cfg" );
       
    37 _LIT8( KUsbPortNumber,      "PortNumber" );
       
    38 _LIT8( KUsbDataRate,        "DataRate" );
       
    39 
       
    40 // _LIT( KUsbPddName, "" );
       
    41 _LIT( KUsbLddName, "EUSBC" );
       
    42 _LIT( KUsbCsyName, "ECACM");
       
    43 
       
    44 const TInt KDefaultUsbPort = 1;
       
    45 
       
    46 const static TUint KReceiveBufferLength = 4 * 1024;
       
    47 const static TUint KSendBufferLength =    4 * 1024;
       
    48 
       
    49 const static TInt KMaxHtiNotifierLength = 128;
       
    50 
       
    51 // MACROS
       
    52 
       
    53 // MODULE DATA STRUCTURES
       
    54 
       
    55 // LOCAL FUNCTION PROTOTYPES
       
    56 
       
    57 // FORWARD DECLARATIONS
       
    58 
       
    59 // ============================ MEMBER FUNCTIONS ===============================
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CHtiUsbSerialCommEcomPlugin::NewL
       
    63 // Two-phased constructor.
       
    64 // -----------------------------------------------------------------------------
       
    65 CHtiUsbSerialCommEcomPlugin* CHtiUsbSerialCommEcomPlugin::NewL()
       
    66     {
       
    67     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::NewL" );
       
    68     CHtiUsbSerialCommEcomPlugin* plugin =
       
    69         new ( ELeave ) CHtiUsbSerialCommEcomPlugin();
       
    70     CleanupStack::PushL( plugin );
       
    71     plugin->ConstructL();
       
    72     CleanupStack::Pop( plugin );
       
    73     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::NewL" );
       
    74     return plugin;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CHtiUsbSerialCommEcomPlugin::~CHtiUsbSerialCommEcomPlugin
       
    79 // Destructor.
       
    80 // -----------------------------------------------------------------------------
       
    81 CHtiUsbSerialCommEcomPlugin::~CHtiUsbSerialCommEcomPlugin()
       
    82     {
       
    83     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::~CHtiUsbSerialCommEcomPlugin" );
       
    84     iCommPort.Close();
       
    85     iCommServ.Close();
       
    86     delete iCfg;
       
    87     User::FreeLogicalDevice( KUsbLddName() );
       
    88     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::~CHtiUsbSerialCommEcomPlugin" );
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CHtiUsbSerialCommEcomPlugin::CHtiUsbSerialCommEcomPlugin
       
    93 // C++ default constructor can NOT contain any code, that might leave.
       
    94 // -----------------------------------------------------------------------------
       
    95 CHtiUsbSerialCommEcomPlugin::CHtiUsbSerialCommEcomPlugin()
       
    96     {
       
    97     // default port settings
       
    98     iPortNumber = KDefaultUsbPort;
       
    99     iDataRate   = EBps115200;
       
   100     iParity     = EParityNone;
       
   101     iDataBits   = EData8;
       
   102     iStopBits   = EStop1;
       
   103     iHandshake  = 0;
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CHtiUsbSerialCommEcomPlugin::ConstructL
       
   108 // Symbian 2nd phase constructor - can leave.
       
   109 // -----------------------------------------------------------------------------
       
   110 void CHtiUsbSerialCommEcomPlugin::ConstructL()
       
   111     {
       
   112     TRAPD( err, LoadConfigL() );
       
   113     if ( err == KErrNone )
       
   114         {
       
   115         ReadConfig();
       
   116         }
       
   117     InitCommServerL();
       
   118     InitCommPortL();
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CHtiUsbSerialCommEcomPlugin::LoadConfigL
       
   123 // Loads the plugin configuration file from disk to iCfg.
       
   124 // -----------------------------------------------------------------------------
       
   125 void CHtiUsbSerialCommEcomPlugin::LoadConfigL()
       
   126     {
       
   127     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::LoadConfigL" );
       
   128     iCfg = CHtiCfg::NewL();
       
   129     HTI_LOG_TEXT( "CHtiCfg constructed - loading cfg file" );
       
   130     iCfg->LoadCfgL( KHtiCfgPath, KHtiUsbSerialCommCfg );
       
   131     HTI_LOG_TEXT( "Cfg file loaded" );
       
   132     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::LoadConfigL" );
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CHtiUsbSerialCommEcomPlugin::ReadConfig
       
   137 // Reads the parameters from loaded configuration file.
       
   138 // -----------------------------------------------------------------------------
       
   139 void CHtiUsbSerialCommEcomPlugin::ReadConfig()
       
   140     {
       
   141     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::ReadConfig" );
       
   142 
       
   143     TInt portNumberCfg = 0;
       
   144     TRAPD( paramErr,
       
   145             portNumberCfg = iCfg->GetParameterIntL( KUsbPortNumber ) );
       
   146     if ( paramErr != KErrNone )
       
   147         {
       
   148         HTI_LOG_FORMAT(
       
   149             "PortNumber not defined in cfg, using default value %d",
       
   150             iPortNumber );
       
   151         portNumberCfg = iPortNumber;
       
   152         }
       
   153     iPortNumber = portNumberCfg;
       
   154 
       
   155     TInt dataRateCfg = 0;
       
   156     TRAP( paramErr, dataRateCfg = iCfg->GetParameterIntL( KUsbDataRate ) );
       
   157     if ( paramErr != KErrNone )
       
   158         {
       
   159         HTI_LOG_TEXT( "DataRate not defined in cfg, using default" );
       
   160         }
       
   161     else
       
   162         {
       
   163         switch ( dataRateCfg )
       
   164             {
       
   165             case 2400:    iDataRate = EBps2400;    break;
       
   166             case 4800:    iDataRate = EBps4800;    break;
       
   167             case 9600:    iDataRate = EBps9600;    break;
       
   168             case 19200:   iDataRate = EBps19200;   break;
       
   169             case 38400:   iDataRate = EBps38400;   break;
       
   170             case 57600:   iDataRate = EBps57600;   break;
       
   171             case 115200:  iDataRate = EBps115200;  break;
       
   172             case 576000:  iDataRate = EBps576000;  break;
       
   173             case 1152000: iDataRate = EBps1152000; break;
       
   174             case 4000000: iDataRate = EBps4000000; break;
       
   175             default:
       
   176                 HTI_LOG_FORMAT(
       
   177                     "Unsupported DataRate %d defined - using default",
       
   178                     dataRateCfg );
       
   179                 break;
       
   180             }
       
   181         }
       
   182 
       
   183     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::ReadConfig" );
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CHtiUsbSerialCommEcomPlugin::InitCommServerL
       
   188 // Starts the comm server, loads comms module and device drivers.
       
   189 // -----------------------------------------------------------------------------
       
   190 void CHtiUsbSerialCommEcomPlugin::InitCommServerL()
       
   191     {
       
   192     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::InitCommServerL" );
       
   193 
       
   194     TInt err = KErrNone;
       
   195 
       
   196     // start the comm server
       
   197     err = StartC32();
       
   198     if ( err != KErrNone && err != KErrAlreadyExists )
       
   199         {
       
   200         ShowErrorNotifierL( _L( "Failed to start comm server" ), err );
       
   201         User::Leave( err );
       
   202         }
       
   203 
       
   204     // connect to RCommServ
       
   205     err = iCommServ.Connect();
       
   206     if ( err != KErrNone )
       
   207         {
       
   208         ShowErrorNotifierL( _L( "Failed to connect to comm server" ), err );
       
   209         User::Leave( err );
       
   210         }
       
   211 
       
   212     // load comms module (CSY file)
       
   213     err = iCommServ.LoadCommModule( KUsbCsyName() );
       
   214     if ( err != KErrNone )
       
   215         {
       
   216         ShowErrorNotifierL( _L( "Failed to load comms module" ), err );
       
   217         User::Leave( err );
       
   218         }
       
   219 
       
   220     /* USB PDD is usually a kernel extension so no need to load separately.
       
   221     // load physical device driver
       
   222     TInt err = User::LoadPhysicalDevice( KUsbPddName );
       
   223     if ( err != KErrNone && err != KErrAlreadyExists )
       
   224         {
       
   225         ShowErrorNotifierL( _L( "Failed to load USB PDD" ), err );
       
   226         User::Leave( err );
       
   227         }
       
   228     */
       
   229 
       
   230     // load logical device driver
       
   231     err = User::LoadLogicalDevice( KUsbLddName() );
       
   232     if ( err != KErrNone && err != KErrAlreadyExists )
       
   233         {
       
   234         ShowErrorNotifierL( _L( "Failed to load USB LDD" ), err );
       
   235         User::Leave( err );
       
   236         }
       
   237 
       
   238     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::InitCommServerL" );
       
   239     }
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // CHtiUsbSerialCommEcomPlugin::InitCommPortL
       
   243 // Checks that the comms module is valid and opens the port.
       
   244 // -----------------------------------------------------------------------------
       
   245 void CHtiUsbSerialCommEcomPlugin::InitCommPortL()
       
   246     {
       
   247     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::InitCommPortL" );
       
   248 
       
   249     TInt err = KErrNone;
       
   250     // check the number of loaded comms modules
       
   251     TInt commsCount = 0;
       
   252     err = iCommServ.NumPorts( commsCount );
       
   253     if ( err != KErrNone || commsCount < 1 )
       
   254         {
       
   255         if ( err != KErrNone )
       
   256             {
       
   257             ShowErrorNotifierL( _L( "Failed to get comms module count" ), err );
       
   258             User::Leave( err );
       
   259             }
       
   260         else
       
   261             {
       
   262             ShowErrorNotifierL( _L( "No comms module loaded" ), KErrNotFound );
       
   263             User::Leave( KErrNotFound );
       
   264             }
       
   265         }
       
   266 
       
   267     HTI_LOG_FORMAT( "Found %d loaded comms modules", commsCount );
       
   268 
       
   269     // get info about our loaded comms module
       
   270     TSerialInfo serialInfo;
       
   271     TBool found = EFalse;
       
   272     for ( TInt i = 0; i < commsCount && !found; i++ )
       
   273         {
       
   274         TBuf<32> moduleName;
       
   275         err = iCommServ.GetPortInfo( i, moduleName, serialInfo );
       
   276         if ( err != KErrNone )
       
   277             {
       
   278             ShowErrorNotifierL( _L( "Failed to get port info" ), err );
       
   279             User::Leave( err );
       
   280             }
       
   281         HTI_LOG_FORMAT( "Found comms module %S", &moduleName );
       
   282         HTI_LOG_FORMAT( "Comms module description: %S",
       
   283             &( serialInfo.iDescription ) );
       
   284         if ( moduleName.CompareF( KUsbCsyName ) == 0 )
       
   285             {
       
   286             found = ETrue;
       
   287             HTI_LOG_FORMAT( "Lowest port num  = %d", serialInfo.iLowUnit );
       
   288             HTI_LOG_FORMAT( "Highest port num = %d", serialInfo.iHighUnit );
       
   289             }
       
   290         }
       
   291 
       
   292     if ( !found )
       
   293         {
       
   294         ShowErrorNotifierL( _L( "Failed to get port info" ), KErrNotFound );
       
   295         User::Leave( KErrNotFound );
       
   296         }
       
   297 
       
   298     // create port name
       
   299     TBuf<KMaxPortName + 4> commPort;
       
   300     commPort.Append( serialInfo.iName );
       
   301     commPort.AppendFill( ':', 2 );
       
   302     commPort.AppendNum( iPortNumber );
       
   303     HTI_LOG_FORMAT( "Opening port %S", &commPort );
       
   304 
       
   305     // try to open the port
       
   306     err = iCommPort.Open( iCommServ, commPort, ECommExclusive, ECommRoleDTE );
       
   307     if ( err )
       
   308         {
       
   309         HTI_LOG_FORMAT( "Failed to open port %d", err );
       
   310         ShowErrorNotifierL( _L( "Failed to open port" ), err );
       
   311         }
       
   312     User::LeaveIfError( err );
       
   313     HTI_LOG_TEXT( "Port open - checking port capabilities" );
       
   314 
       
   315     // check port data rate capability
       
   316     TCommCaps portCaps;
       
   317     iCommPort.Caps( portCaps );
       
   318     HTI_LOG_TEXT( "Port capabilities:" );
       
   319     HTI_LOG_FORMAT( " DataRate  = %d", portCaps().iRate );
       
   320     HTI_LOG_FORMAT( " Parity    = %d", portCaps().iParity );
       
   321     HTI_LOG_FORMAT( " DataBits  = %d", portCaps().iDataBits );
       
   322     HTI_LOG_FORMAT( " StopBits  = %d", portCaps().iStopBits );
       
   323     HTI_LOG_FORMAT( " Handshake = %d", portCaps().iHandshake );
       
   324     HTI_LOG_FORMAT( " Signals   = %d", portCaps().iSignals );
       
   325     HTI_LOG_FORMAT( " Fifo      = %d", portCaps().iFifo );
       
   326     HTI_LOG_FORMAT( " SIR       = %d", portCaps().iSIR );
       
   327 
       
   328     TUint reqRateCapsBitmask = RateCapsBitmaskFromRate( iDataRate );
       
   329     HTI_LOG_FORMAT( "Required data rate capability bitmask %d",
       
   330         reqRateCapsBitmask );
       
   331 
       
   332     if ( reqRateCapsBitmask == 0 ||
       
   333          ( reqRateCapsBitmask & portCaps().iRate ) == 0 )
       
   334         {
       
   335         ShowErrorNotifierL( _L( "Unsupported data rate configured" ),
       
   336             KErrNotSupported );
       
   337         User::Leave( KErrNotSupported );
       
   338         }
       
   339     HTI_LOG_TEXT( "Data rate supported - setting port configuration" );
       
   340 
       
   341     // set port configuration
       
   342     TCommConfig portSettings;
       
   343     iCommPort.Config( portSettings );
       
   344     portSettings().iRate      = iDataRate;
       
   345     portSettings().iParity    = iParity;
       
   346     portSettings().iDataBits  = iDataBits;
       
   347     portSettings().iStopBits  = iStopBits;
       
   348     portSettings().iFifo      = EFifoEnable;
       
   349     portSettings().iHandshake = iHandshake;
       
   350 
       
   351     err = iCommPort.SetConfig( portSettings );
       
   352     if ( err )
       
   353         {
       
   354         HTI_LOG_FORMAT( "Failed to set port settings %d", err );
       
   355         ShowErrorNotifierL( _L( "Failed to set port settings" ), err );
       
   356         User::Leave( err );
       
   357         }
       
   358 
       
   359     iCommPort.SetReceiveBufferLength( KReceiveBufferLength );
       
   360 
       
   361     HTI_LOG_TEXT( "Port open and configured" );
       
   362     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::InitCommPortL" );
       
   363     }
       
   364 
       
   365 // -----------------------------------------------------------------------------
       
   366 // CHtiUsbSerialCommEcomPlugin::Receive
       
   367 // Receive data from comm port.
       
   368 // -----------------------------------------------------------------------------
       
   369 void CHtiUsbSerialCommEcomPlugin::Receive( TDes8& aRawdataBuf,
       
   370                                         TRequestStatus& aStatus )
       
   371     {
       
   372     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::Receive" );
       
   373     HTI_LOG_FORMAT( "Buf max len: %d", aRawdataBuf.MaxLength() );
       
   374     iCommPort.ReadOneOrMore( aStatus, aRawdataBuf );
       
   375     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::Receive" );
       
   376     }
       
   377 
       
   378 // -----------------------------------------------------------------------------
       
   379 // CHtiUsbSerialCommEcomPlugin::Send
       
   380 // Write data to comm port.
       
   381 // -----------------------------------------------------------------------------
       
   382 void CHtiUsbSerialCommEcomPlugin::Send( const TDesC8& aRawdataBuf,
       
   383                                            TRequestStatus& aStatus )
       
   384     {
       
   385     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::Send" );
       
   386     iCommPort.Write( aStatus, aRawdataBuf );
       
   387     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::Send" );
       
   388     }
       
   389 
       
   390 // -----------------------------------------------------------------------------
       
   391 // CHtiUsbSerialCommEcomPlugin::CancelReceive
       
   392 // Cancel a pending read.
       
   393 // -----------------------------------------------------------------------------
       
   394 void CHtiUsbSerialCommEcomPlugin::CancelReceive()
       
   395     {
       
   396     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::CancelReceive" );
       
   397     iCommPort.ReadCancel();
       
   398     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::CancelReceive" );
       
   399     }
       
   400 
       
   401 // -----------------------------------------------------------------------------
       
   402 // CHtiUsbSerialCommEcomPlugin::CancelSend
       
   403 // Cancel a pending write.
       
   404 // -----------------------------------------------------------------------------
       
   405 void CHtiUsbSerialCommEcomPlugin::CancelSend()
       
   406     {
       
   407     HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::CancelSend" );
       
   408     iCommPort.WriteCancel();
       
   409     HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::CancelSend" );
       
   410     }
       
   411 
       
   412 // -----------------------------------------------------------------------------
       
   413 // CHtiUsbSerialCommEcomPlugin::GetSendBufferSize
       
   414 // -----------------------------------------------------------------------------
       
   415 TInt CHtiUsbSerialCommEcomPlugin::GetSendBufferSize()
       
   416     {
       
   417     return KSendBufferLength;
       
   418     }
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // CHtiUsbSerialCommEcomPlugin::GetReceiveBufferSize
       
   422 // -----------------------------------------------------------------------------
       
   423 TInt CHtiUsbSerialCommEcomPlugin::GetReceiveBufferSize()
       
   424     {
       
   425     return KReceiveBufferLength;
       
   426     }
       
   427 
       
   428 // -----------------------------------------------------------------------------
       
   429 // CHtiUsbSerialCommEcomPlugin::RateCapsBitmaskFromRate
       
   430 // Converts a TBps enumeration value to a corresponding bitmask.
       
   431 // -----------------------------------------------------------------------------
       
   432 TUint CHtiUsbSerialCommEcomPlugin::RateCapsBitmaskFromRate( TBps aDataRate )
       
   433     {
       
   434     switch ( aDataRate )
       
   435         {
       
   436         case EBps50:      return KCapsBps50;
       
   437         case EBps75:      return KCapsBps75;
       
   438         case EBps110:     return KCapsBps110;
       
   439         case EBps134:     return KCapsBps134;
       
   440         case EBps150:     return KCapsBps150;
       
   441         case EBps300:     return KCapsBps300;
       
   442         case EBps600:     return KCapsBps600;
       
   443         case EBps1200:    return KCapsBps1200;
       
   444         case EBps1800:    return KCapsBps1800;
       
   445         case EBps2000:    return KCapsBps2000;
       
   446         case EBps2400:    return KCapsBps2400;
       
   447         case EBps3600:    return KCapsBps3600;
       
   448         case EBps4800:    return KCapsBps4800;
       
   449         case EBps7200:    return KCapsBps7200;
       
   450         case EBps9600:    return KCapsBps9600;
       
   451         case EBps19200:   return KCapsBps19200;
       
   452         case EBps38400:   return KCapsBps38400;
       
   453         case EBps57600:   return KCapsBps57600;
       
   454         case EBps115200:  return KCapsBps115200;
       
   455         case EBps230400:  return KCapsBps230400;
       
   456         case EBps460800:  return KCapsBps460800;
       
   457         case EBps576000:  return KCapsBps576000;
       
   458         case EBps1152000: return KCapsBps1152000;
       
   459         case EBps4000000: return KCapsBps4000000;
       
   460         default:          return 0;
       
   461         }
       
   462     }
       
   463 
       
   464 // -----------------------------------------------------------------------------
       
   465 // CHtiUsbSerialCommEcomPlugin::ShowErrorNotifierL
       
   466 // Shows an error notifier dialog with text and error code.
       
   467 // -----------------------------------------------------------------------------
       
   468 void CHtiUsbSerialCommEcomPlugin::ShowErrorNotifierL( const TDesC& aText,
       
   469                                                       TInt aErr )
       
   470     {
       
   471     RNotifier notifier;
       
   472     User::LeaveIfError( notifier.Connect() );
       
   473 
       
   474     TBuf<KMaxHtiNotifierLength> errorMsg;
       
   475     // aText is cut if it's too long - leaving some space also for error code
       
   476     errorMsg.Append( aText.Left( errorMsg.MaxLength() - 10 ) );
       
   477     errorMsg.Append( _L("\n") );
       
   478     errorMsg.AppendNum( aErr );
       
   479 
       
   480     TRequestStatus status;
       
   481     TInt button;
       
   482     notifier.Notify( KHtiUsbSerialError, errorMsg,
       
   483                      KHtiOkButton, KNullDesC, button, status );
       
   484     User::WaitForRequest( status );
       
   485     notifier.Close();
       
   486     }
       
   487 
       
   488 
       
   489 // End of file