00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00023 #ifndef __DRIVER1_DEV_H__
00024 #define __DRIVER1_DEV_H__
00025
00029 class DDriver1Factory : public DLogicalDevice
00030 {
00031 public:
00032 DDriver1Factory();
00033 ~DDriver1Factory();
00034
00035
00036 virtual TInt Install();
00037 virtual void GetCaps(TDes8& aDes) const;
00038 virtual TInt Create(DLogicalChannelBase*& aChannel);
00039 };
00040
00041 class DDriver1;
00042
00046 class DDriver1Channel : public DLogicalChannel
00047 {
00048 public:
00049 DDriver1Channel();
00050 virtual ~DDriver1Channel();
00051
00052
00053 virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
00054
00055
00056 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
00057
00058
00059 virtual void HandleMsg(TMessageBase* aMsg);
00060 private:
00061
00062 enum TPanic
00063 {
00064
00065 ERequestAlreadyPending = 1
00066 };
00067
00068
00069 TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
00070 TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
00071 void DoCancel(TUint aMask);
00072
00073 inline DDriver1* Pdd();
00074
00075 TInt GetConfig(TDes8* aConfigBuf);
00076 TInt SetConfig(const TDesC8* aConfigBuf);
00077 void CurrentConfig(RDriver1::TConfig& aConfig);
00078
00079 TInt SendData(TRequestStatus* aStatus,const TDesC8* aData);
00080 void SendDataCancel();
00081 void DoSendDataComplete();
00082 static void SendDataDfc(TAny* aPtr);
00083
00084 TInt ReceiveData(TRequestStatus* aStatus,TDes8* aBuffer);
00085 void ReceiveDataCancel();
00086 void DoReceiveDataComplete();
00087 static void ReceiveDataDfc(TAny* aPtr);
00088 public:
00089
00090 virtual void SendDataComplete(TInt aResult);
00091 virtual void ReceiveDataComplete(TInt aResult);
00092 private:
00093 DThread* iClient;
00094
00095 TRequestStatus* iSendDataStatus;
00096 TDfc iSendDataDfc;
00097 TInt iSendDataResult;
00098 TBuf8<256> iSendDataBuffer;
00099
00100 TDes8* iReceiveDataDescriptor;
00101 TRequestStatus* iReceiveDataStatus;
00102 TDfc iReceiveDataDfc;
00103 TInt iReceiveDataResult;
00104 TBuf8<256> iReceiveDataBuffer;
00105 };
00106
00107 inline DDriver1* DDriver1Channel::Pdd()
00108 { return (DDriver1*)iPdd; }
00109
00113 class DDriver1 : public DBase
00114 {
00115 public:
00119 class TCaps
00120 {
00121 public:
00122 TVersion iVersion;
00123 };
00124 public:
00125 virtual TInt BufferSize() const =0;
00126 virtual TInt Speed() const =0;
00127 virtual TInt SetSpeed(TInt aSpeed) =0;
00128 virtual TInt SendData(const TDesC8& aData) =0;
00129 virtual void SendDataCancel() =0;
00130 virtual TInt ReceiveData(TDes8& aBuffer) =0;
00131 virtual void ReceiveDataCancel() =0;
00132 public:
00133 DDriver1Channel* iLdd;
00134 };
00135
00136 #endif
00137