|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : tcomportserver.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <c32comm.h> |
|
19 |
|
20 #if defined (__WINS__) |
|
21 #define PDD_NAME _L("ECDRV") |
|
22 #else |
|
23 #define PDD_NAME _L("EUART1") |
|
24 #define PDD2_NAME _L("EUART2") |
|
25 #define PDD3_NAME _L("EUART3") |
|
26 #define PDD4_NAME _L("EUART4") |
|
27 #endif |
|
28 |
|
29 #define LDD_NAME _L("ECOMM") |
|
30 |
|
31 |
|
32 /** |
|
33 * @file |
|
34 * |
|
35 * random test server implementation |
|
36 */ |
|
37 #include "tcomportserver.h" |
|
38 #include "tcomport.h" |
|
39 |
|
40 |
|
41 _LIT(KSerName, "tcomport"); |
|
42 |
|
43 CComportTestServer* CComportTestServer::NewL() |
|
44 { |
|
45 CComportTestServer *server = new(ELeave) CComportTestServer(); |
|
46 CleanupStack::PushL(server); |
|
47 server->ConstructL(KSerName); |
|
48 CleanupStack::Pop(server); |
|
49 return server; |
|
50 } |
|
51 |
|
52 static void InitCommsL() |
|
53 { |
|
54 |
|
55 TInt err=0; |
|
56 err = User::LoadPhysicalDevice (PDD_NAME); |
|
57 if ( err != KErrAlreadyExists && err) |
|
58 User::Leave(err); |
|
59 err = User::LoadLogicalDevice (LDD_NAME); |
|
60 if ( err != KErrAlreadyExists && err) |
|
61 User::Leave(err); |
|
62 StartC32(); |
|
63 |
|
64 RCommServ ComSer; |
|
65 ComSer.Connect(); |
|
66 |
|
67 err=ComSer.LoadCommModule(_L("ECUART")); |
|
68 if ( err != KErrAlreadyExists && err) |
|
69 User::Leave(err); |
|
70 } |
|
71 |
|
72 LOCAL_C void MainL() |
|
73 { |
|
74 // Leave the hooks in for platform security |
|
75 #if (defined __DATA_CAGING__) |
|
76 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
77 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
78 #endif |
|
79 InitCommsL(); |
|
80 |
|
81 CActiveScheduler* sched=NULL; |
|
82 sched=new(ELeave) CActiveScheduler; |
|
83 CActiveScheduler::Install(sched); |
|
84 CComportTestServer* server = NULL; |
|
85 // Create the CTestServer derived server |
|
86 TRAPD(err, server = CComportTestServer::NewL()); |
|
87 if(!err) |
|
88 { |
|
89 // Sync with the client and enter the active scheduler |
|
90 RProcess::Rendezvous(KErrNone); |
|
91 sched->Start(); |
|
92 } |
|
93 delete server; |
|
94 delete sched; |
|
95 } |
|
96 |
|
97 /** |
|
98 * Server entry point |
|
99 * @return Standard Epoc error code on exit |
|
100 */ |
|
101 TInt main() |
|
102 { |
|
103 __UHEAP_MARK; |
|
104 |
|
105 TRAP_IGNORE(MainL()); |
|
106 |
|
107 __UHEAP_MARKEND; |
|
108 return KErrNone; |
|
109 } |
|
110 |
|
111 CTestStep* CComportTestServer::CreateTestStep(const TDesC& aStepName) |
|
112 { |
|
113 CTestStep* testStep = NULL; |
|
114 |
|
115 // This server creates just one step but create as many as you want |
|
116 // They are created "just in time" when the worker thread is created |
|
117 // install steps |
|
118 if(aStepName == Ktest_printf_COM) |
|
119 { |
|
120 testStep = new CTestcomport(aStepName); |
|
121 } |
|
122 else if(aStepName == Ktest_scanf_COM) |
|
123 { |
|
124 testStep = new CTestcomport(aStepName); |
|
125 } |
|
126 return testStep; |
|
127 } |
|
128 |