author | fturovic <frank.turovich@nokia.com> |
Wed, 29 Sep 2010 11:00:40 -0500 | |
changeset 2115 | 0f22172f2f8f |
parent 1481 | c7f22cc57d44 |
permissions | -rw-r--r-- |
60 | 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 the License "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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
#ifndef __BASECOM_H__ |
|
18 |
#define __BASECOM_H__ |
|
19 |
#include "Registry.h" |
|
20 |
#include "ServerClient.h" |
|
21 |
#include "TCConstants.h" |
|
22 |
#include "TCErrorConstants.h" |
|
23 |
#include "BaseProtocol.h" |
|
24 |
#include "TCDebugLog.h" |
|
25 |
#include <time.h> |
|
26 |
||
27 |
#ifdef _DEBUG |
|
28 |
extern BOOL gDoLogging; |
|
29 |
#endif |
|
30 |
||
31 |
#define LOG_COMM |
|
32 |
#if defined(LOG_COMM) && defined(_DEBUG) |
|
33 |
||
34 |
#define COMMLOGOPEN() if (gDoLogging) { if (m_CommDebugLog) m_CommDebugLog->WaitForAccess(); } |
|
35 |
#define COMMLOGS(s) if (gDoLogging) { sprintf(m_CommDebugLogMsg,"%s", s); if (m_CommDebugLog) m_CommDebugLog->log(m_CommDebugLogMsg); } |
|
36 |
#define COMMLOGA1(s, a1) if (gDoLogging) { sprintf(m_CommDebugLogMsg, s, a1); if (m_CommDebugLog) m_CommDebugLog->log(m_CommDebugLogMsg); } |
|
37 |
#define COMMLOGA2(s, a1, a2) if (gDoLogging) { sprintf(m_CommDebugLogMsg, s, a1, a2); if (m_CommDebugLog) m_CommDebugLog->log(m_CommDebugLogMsg); } |
|
38 |
#define COMMLOGA3(s, a1, a2, a3) if (gDoLogging) { sprintf(m_CommDebugLogMsg, s, a1, a2, a3); if (m_CommDebugLog) m_CommDebugLog->log(m_CommDebugLogMsg); } |
|
39 |
#define COMMLOGA4(s, a1, a2, a3, a4) if (gDoLogging) { sprintf(m_CommDebugLogMsg, s, a1, a2, a3, a4); if (m_CommDebugLog) m_CommDebugLog->log(m_CommDebugLogMsg); } |
|
40 |
#define COMMLOGCLOSE() if (gDoLogging) { if (m_CommDebugLog) m_CommDebugLog->ReleaseAccess(); } |
|
41 |
#else |
|
42 |
#define COMMLOGOPEN() |
|
43 |
#define COMMLOGS(s) |
|
44 |
#define COMMLOGA1(s, a1) |
|
45 |
#define COMMLOGA2(s, a1, a2) |
|
46 |
#define COMMLOGA3(s, a1, a2, a3) |
|
47 |
#define COMMLOGA4(s, a1, a2, a3, a4) |
|
48 |
#define COMMLOGCLOSE() |
|
49 |
#endif |
|
50 |
||
458 | 51 |
#define LOG_PROCCOMM |
60 | 52 |
#if defined(LOG_PROCCOMM) && defined(_DEBUG) |
53 |
#define PROCLOGOPEN() if (gDoLogging) { m_ProcDebugLog->WaitForAccess(); } |
|
54 |
#define PROCLOGS(s) if (gDoLogging) { sprintf(m_ProcDebugLogMsg,"%s", s); m_ProcDebugLog->log(m_ProcDebugLogMsg); } |
|
55 |
#define PROCLOGA1(s, a1) if (gDoLogging) { sprintf(m_ProcDebugLogMsg, s, a1); m_ProcDebugLog->log(m_ProcDebugLogMsg); } |
|
56 |
#define PROCLOGA2(s, a1, a2) if (gDoLogging) { sprintf(m_ProcDebugLogMsg, s, a1, a2); m_ProcDebugLog->log(m_ProcDebugLogMsg); } |
|
57 |
#define PROCLOGA3(s, a1, a2, a3) if (gDoLogging) { sprintf(m_ProcDebugLogMsg, s, a1, a2, a3); m_ProcDebugLog->log(m_ProcDebugLogMsg); } |
|
58 |
#define PROCLOGA4(s, a1, a2, a3, a4) if (gDoLogging) { sprintf(m_ProcDebugLogMsg, s, a1, a2, a3, a4); m_ProcDebugLog->log(m_ProcDebugLogMsg); } |
|
59 |
#define PROCLOGA5(s, a1, a2, a3, a4, a5) if (gDoLogging) { sprintf(m_ProcDebugLogMsg, s, a1, a2, a3, a4, a5); m_ProcDebugLog->log(m_ProcDebugLogMsg); } |
|
60 |
#define PROCLOGCLOSE() if (gDoLogging) { m_ProcDebugLog->ReleaseAccess(); } |
|
61 |
#else |
|
62 |
#define PROCLOGOPEN() |
|
63 |
#define PROCLOGS(s) |
|
64 |
#define PROCLOGA1(s, a1) |
|
65 |
#define PROCLOGA2(s, a1, a2) |
|
66 |
#define PROCLOGA3(s, a1, a2, a3) |
|
67 |
#define PROCLOGA4(s, a1, a2, a3, a4) |
|
68 |
#define PROCLOGA5(s, a1, a2, a3, a4, a5) |
|
69 |
#define PROCLOGCLOSE() |
|
70 |
#endif |
|
71 |
||
72 |
class CConnection; |
|
73 |
class CBaseProtocol; |
|
74 |
||
75 |
class CBaseCom |
|
76 |
{ |
|
77 |
public: |
|
78 |
CBaseCom(); |
|
79 |
CBaseCom(ConnectData* connectSettings, DWORD connectionId, CBaseProtocol* protocol); |
|
80 |
virtual ~CBaseCom(); |
|
81 |
||
82 |
// void SetConnectSettings(ConnectData* connectSettings); |
|
83 |
// void SetProtocol(CBaseProtocol* protocol) { m_Protocol = protocol; } |
|
84 |
// void SetConnectionId(DWORD id); |
|
85 |
||
86 |
virtual long OpenPort()=0; |
|
87 |
virtual long ClosePort()=0; |
|
88 |
virtual long SendDataToPort(DWORD inSize, const void* inData)=0; |
|
89 |
virtual long PollPort(DWORD& outSize)=0; |
|
90 |
virtual long ReadPort(DWORD inSize, void* outData, DWORD& outSize)=0; |
|
91 |
virtual long ProcessBuffer(CConnection* pConn, CRegistry* pRegistry, long& numberProcessed)=0; |
|
92 |
virtual void DeleteMsg(DWORD inMsgLength)=0; |
|
93 |
virtual bool IsConnected() { return m_isConnected; } |
|
94 |
virtual bool GetVersion(char* outVersion)=0; // get version of whatever we're connected to |
|
95 |
virtual bool HasVersion()=0; // does this connection have a version? |
|
96 |
virtual long PreProcessMessage(int inMsgType, DWORD inMsgLength, BYTE* inMessage)=0; |
|
97 |
virtual long PreProcessMessage(BYTE msgId, DWORD inMsgLength, BYTE* inMessage)=0; |
|
98 |
virtual bool IsConnectionEqual(ConnectData* pConn)=0; |
|
99 |
||
100 |
BYTE* m_pBuffer; |
|
101 |
DWORD m_numberBytes; |
|
102 |
bool m_isConnected; |
|
103 |
DWORD m_connId; |
|
104 |
||
105 |
ConnectData* m_ConnectSettings; // from connection |
|
106 |
CBaseProtocol* m_Protocol; // used for this connection |
|
107 |
||
108 |
// for Open/Close/Send thread |
|
109 |
char m_CommDebugLogMsg[2000]; |
|
110 |
TCDebugLog* m_CommDebugLog; |
|
111 |
||
112 |
// for Poll/Read/Process/PreProcess thread |
|
113 |
char m_ProcDebugLogMsg[2000]; |
|
114 |
TCDebugLog* m_ProcDebugLog; |
|
115 |
||
116 |
DWORD m_lastCommError; |
|
117 |
}; |
|
118 |
||
119 |
typedef const char* (*COMMREGISTER)(void); |
|
120 |
typedef CBaseCom* (*COMMCREATE)(ConnectData* connectSettings, DWORD connectionId, CBaseProtocol* protocol); |
|
121 |
||
122 |
#define COMMREGISTER_FNNAME "RegisterComm" |
|
123 |
#define COMMCREATE_FNNAME "CreateComm" |
|
124 |
||
125 |
#define COMMDLL_BASENAME "TCFComm" |
|
126 |
||
1481
c7f22cc57d44
Commit some changes from Ed, also for USB, return different error for h/w comm error as opposed to where there is no error reported by windows, but the bytes did not get sent to the device (not responding)
Chad Peckham <chad.peckham@nokia.com>
parents:
458
diff
changeset
|
127 |
#endif //__BASECOM_H__ |