hti/HtiCommPlugins/HtiSerialCommPlugin/inc/HtiSerialCommEcomPlugin.h
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     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 to communicate over serial port
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CHTISERIALCOMMECOMPLUGIN_H
       
    20 #define CHTISERIALCOMMECOMPLUGIN_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <c32comm.h>
       
    25 
       
    26 #include <HtiCommPluginInterface.h> // defined in HtiFramework project
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CHtiCfg;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 /**
       
    34 * ECOM plugin module for communicating with PC using serial port.
       
    35 *
       
    36 */
       
    37 class CHtiSerialCommEcomPlugin :
       
    38     public CHTICommPluginInterface
       
    39     {
       
    40 public:
       
    41 
       
    42     /**
       
    43     * Create instance of plugin.
       
    44     * Reads configuration, opens and initializes serial port.
       
    45     * @return Plugin instance.
       
    46     */
       
    47     static CHtiSerialCommEcomPlugin* NewL();
       
    48 
       
    49     /**
       
    50     * Destructor.
       
    51     */
       
    52     ~CHtiSerialCommEcomPlugin();
       
    53 
       
    54 public: // Interface implementation
       
    55 
       
    56     /**
       
    57     * Receive data from serial port.
       
    58     * The size of supplied buffer must equal to size given
       
    59     * by GetReceiveBufferSize.
       
    60     * The number of received bytes may be anything between 1
       
    61     * and GetReceiveBufferSize.
       
    62     *
       
    63     * @param aRawdataBuf Buffer where the result is written
       
    64     * @param aStatus Request status
       
    65     */
       
    66     void Receive( TDes8& aRawdataBuf, TRequestStatus& aStatus );
       
    67 
       
    68     /**
       
    69     * Send data to serial port. The size of data must not
       
    70     * exceed GetSendBufferSize.
       
    71     * @param aRawdataBuf Buffer where the data is read from.
       
    72     * @param aStatus Request status
       
    73     */
       
    74     void Send( const TDesC8& aRawdataBuf, TRequestStatus& aStatus );
       
    75 
       
    76     /**
       
    77     * Cancel read operation
       
    78     */
       
    79     void CancelReceive();
       
    80 
       
    81     /**
       
    82     * Cancel send operation
       
    83     */
       
    84     void CancelSend();
       
    85 
       
    86     /**
       
    87      *  Return required buffer size for Send operation.
       
    88      */
       
    89     TInt GetSendBufferSize();
       
    90 
       
    91     /**
       
    92      *  Return required buffer size for Receive operation.
       
    93      */
       
    94     TInt GetReceiveBufferSize();
       
    95 
       
    96 private:
       
    97 
       
    98     /**
       
    99     * Constructor of this plugin.
       
   100     */
       
   101     CHtiSerialCommEcomPlugin();
       
   102 
       
   103     /**
       
   104     * Second phase construction.
       
   105     */
       
   106     void ConstructL();
       
   107 
       
   108     /**
       
   109     * Load needed drivers and start comm server.
       
   110     */
       
   111     void InitCommServerL();
       
   112 
       
   113     /**
       
   114     * Setup serial port.
       
   115     */
       
   116     void InitCommPortL();
       
   117 
       
   118     /**
       
   119     * Load configuration file.
       
   120     */
       
   121     void LoadConfigL();
       
   122 
       
   123     /**
       
   124     * Read and parse the configuration values.
       
   125     */
       
   126     void ReadConfig();
       
   127 
       
   128     /**
       
   129     * Show error notifier dialog with text and error code.
       
   130     */
       
   131     void ShowErrorNotifierL( const TDesC& aText, TInt aErr );
       
   132 
       
   133 private: // Data
       
   134 
       
   135     CHtiCfg* iCfg;
       
   136 
       
   137     // port settings
       
   138     TInt      iPortNumber;
       
   139     TBps      iDataRate;
       
   140     TParity   iParity;
       
   141     TDataBits iDataBits;
       
   142     TStopBits iStopBits;
       
   143 
       
   144     // optional delay after each write to RComm
       
   145     TInt iSendDelay;
       
   146 
       
   147     // bitmask for handshake
       
   148     TInt iHandshake;
       
   149 
       
   150     RCommServ iCommServ;
       
   151     RComm iCommPort;
       
   152     };
       
   153 
       
   154 #endif // CHTISERIALCOMMECOMPLUGIN_H