// Return false on error load. static bool loadDevices() { TInt r = KErrNone; #ifdef __WINS__ RFs fileServer; r = User::LeaveIfError(fileServer.Connect()); if (r != KErrNone) return false; fileServer.Close (); #endif r = User::LoadPhysicalDevice(KPddName); if (r != KErrNone && r != KErrAlreadyExists) return false; //User::Leave(r); r = User::LoadLogicalDevice(KLddName); if (r != KErrNone && r != KErrAlreadyExists) return false; //User::Leave(r); #ifndef __WINS__ r = StartC32(); if (r != KErrNone && r != KErrAlreadyExists) return false; //User::Leave(r); #endif return true; }
//this is not needed with a UI, only text shell void LoadLDD_PDD() { TInt r; #ifdef __EPOC32__ r=StartC32(); if (r!=KErrNone && r!=KErrAlreadyExists) { test.Printf(_L("Failed %d!\n\r"),r); test(r==KErrNone); } else test.Printf(_L("Started C32\n")); #endif test.Printf(_L("Loading PDD\n")); r=User::LoadPhysicalDevice(PDD_NAME); if (r!=KErrNone && r!=KErrAlreadyExists) { test.Printf(_L("Failed %d!\n\r"),r); test(r==KErrNone); } else test.Printf(_L("Loaded LDD\n")); test.Printf(_L("Loading LDD\n")); r=User::LoadLogicalDevice(LDD_NAME); if (r!=KErrNone && r!=KErrAlreadyExists) { test.Printf(_L("Failed %d!\n\r"),r); test(r==KErrNone); } else test.Printf(_L("Loaded PDD\n")); }
LOCAL_C void MainL() /** * Secure variant * Much simpler, uses the new Rendezvous() call to sync with the client */ { TInt result = StartC32(); if (result != KErrNone && result != KErrAlreadyExists) { User::Leave(result); } CActiveScheduler* sched=NULL; sched=new(ELeave) CActiveScheduler; CActiveScheduler::Install(sched); // Create the CTestServer derived server CSimVoiceTestServer* testServer = NULL; TRAPD(err,testServer = CSimVoiceTestServer::NewL()); if(!err) { // Sync with the client and enter the active scheduler RProcess::Rendezvous(KErrNone); sched->Start(); } delete testServer; delete sched; }
TInt CCapabilityTestStep::StartServer() { #define C32_SERVER_START_SEQUENCE 5 TInt ret = StartC32(); if (ret==KErrNone || ret==KErrAlreadyExists) { RProperty property; ret=property.Attach(KUidSystemCategory, KUidC32StartPropertyKey.iUid); if(ret!=KErrNone) return ret; // C32 Server is loaded at sequence C32_SERVER_START_SEQUENCE, loop until it has finished. TInt propertyValue=0; ret = property.Get(propertyValue); if(ret!=KErrNone) return ret; TRequestStatus status; while(propertyValue<C32_SERVER_START_SEQUENCE) { property.Subscribe(status); User::WaitForRequest(status); property.Get(propertyValue); } property.Close(); return KErrNone; } User::After(2000000); return ret; }
LOCAL_C void Init() // // Initialisation code - loads the serial LDD and PDD // starts the comm subsystem (for EPOC32 builds) // On a full Symbian OS implementation, this code would not // be required because higher level GUI components // automatically start the services. // { // Load the physical device driver // The OS will automatically append .PDD and // search /System/Libs on all drives. TInt r=User::LoadPhysicalDevice(PDD_NAME); if (r != KErrNone && r!= KErrAlreadyExists) User::Leave(r); //test(r==KErrNone || r==KErrAlreadyExists); // Similarly for the Logical device driver r=User::LoadLogicalDevice(LDD_NAME); if (r != KErrNone && r != KErrAlreadyExists) User::Leave(r); //test(r==KErrNone|| r==KErrAlreadyExists); #if defined (__EPOC32__) // For EPOC builds we need to start the comms subsystem // This call actually starts the comms server process r=StartC32(); if (r != KErrAlreadyExists) User::LeaveIfError(r); #endif }
TInt RReplaySession::Connect() { TInt ret(KErrNone); ret=StartC32(); // KUidC32StartPropertyKey (rootserver load level) will always be 10 at the completion of StartC32 if (ret==KErrNone || ret==KErrAlreadyExists) { RProperty property; TInt propertyValue = 0; ret = property.Attach(KUidSystemCategory, RootServer::KUidC32StartPropertyKey.iUid); if(ret != KErrNone) { // most likely to have run out of memory return ret; } ret = property.Get(propertyValue); if(ret != KErrNone) { return ret; } } if (ret!= KErrNone) return ret; TVersion version(1, 0, 606); TInt result=CreateSession(ETEL_SERVER_NAME,version,32); // Because ETel is now loaded by the Comms Root Server which is generally started during // the boot this should commonly succeed; however for test code this is still a possibility // Hence here we try starting it; this is an atomic operation (and cheap if it's already started) if (result == KErrNotFound || result == KErrServerTerminated) { TInt ret(KErrNone); ret = StartC32(); if (ret!= KErrNone) { return ret; } // at this point, etel server shall be started result=CreateSession(ETEL_SERVER_NAME,version,32); } return KErrNone; }
static TInt MainL() { RDebug::Print(_L("Main() - Starting!")); RFs theFs; TInt r = theFs.Connect(); if (r != KErrNone) { RDebug::Print(_L("Main() - Failed to connect to the fs. Error = %d"), r); return r; } RDebug::Print(_L("Main() - Connected to file server")); r = StartC32(); if (r!=KErrNone && r !=KErrAlreadyExists) { RDebug::Print(_L("Main() - Failed to start C32. Error = %d"), r); return r; } RDebug::Print(_L("E32Main: Started c32")); RUsb usb; TInt err = usb.Connect(); if (err != KErrNone) { RDebug::Print(_L("MainL() - Unable to Connect to USB server")); theFs.Close(); return err; } RDebug::Print(_L("MainL() - Connected to USB server")); TUsbServiceState state; err = usb.GetCurrentState(state); if (err != KErrNone) { RDebug::Print(_L("MainL() - Failed to fetch service state from usbman, error %d"), err); } else { RDebug::Print(_L("MainL() - Usb service state = 0x%x"), state); } TRequestStatus status; usb.Start(status); User::WaitForRequest(status); RDebug::Print(_L("Start completed with status %d"), status.Int()); theFs.Close(); RDebug::Print(_L("MainL() - Exiting normally")); return KErrNone; }
TVerdict CT_StreamStep::doTestStepL() /** @return - TVerdict code.\n Override of base class virtual.\n Tests streaming conversions.\n */ { INFO_PRINTF1(_L("Test Started")); iFs.Connect(); iScheduler = new CActiveScheduler; __ASSERT_ALWAYS(iScheduler,User::Panic(_L("test"),KErrServerTerminated)); CActiveScheduler::Install(iScheduler); TInt ret=0; #if defined(__WINS__) ret=FbsStartup(); TEST(ret==KErrNone); #else FbsStartup(); StartC32(); #endif ret=RFbsSession::Connect(); TEST(!ret); __UHEAP_MARK; SetTestStepID(_L("UIF-StreamStep-TestPrintSetupL")); TRAPD(r,TestPrintSetupL()); TEST(r==KErrNone); RecordTestResultL(); SetTestStepID(_L("UIF-StreamStep-TestModelRestoreL")); TRAP(r,TestModelRestoreL()); TEST(r==KErrNone); RecordTestResultL(); SetTestStepID(_L("UIF-StreamStep-TestHeaderFooterL")); TRAP(r,TestHeaderFooterL()); TEST(r==KErrNone); RecordTestResultL(); // Do more tests here... CloseTMSGraphicsStep(); __UHEAP_MARKEND; delete iScheduler; INFO_PRINTF1(_L("Test Finished")); return TestStepResult(); }
TInt CPARAM_MESS_NAMEStep::Exec_SendReceive() { _LIT(KEsockSessStartMutex,"KESSMTX"); //Keep the descriptor short RMutex mutex; TInt r; // Protect the openning of the session // with a mutex to stop thread collision FOREVER { r = mutex.CreateGlobal(KEsockSessStartMutex()); if (r == KErrNone) break; if (r != KErrAlreadyExists) return r; r=mutex.OpenGlobal(KEsockSessStartMutex()); if (r == KErrNone) break; if (r != KErrNotFound) return r; } mutex.Wait(); // the exclusion ensures the session is started atomically iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version()); // Because ESock is now loaded by the Comms Root Server which is generally started during // the boot this should commonly succeed; however for test code this is still a possibility // Hence here we try starting it; this is an atomic operation (and cheap if it's already started) if (iResult_Server==KErrNotFound) { r=StartC32(); if (r==KErrNone || r==KErrAlreadyExists) { iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version()); } } mutex.Signal(); mutex.Close(); if (iResult_Server == KErrNone) { iSessionCreated = ETrue; const TInt test_id = dispatch_num<PARAM_MESS_VALUE>::result; iResult_SR = do_execute(Int2Type<test_id>()); } else { iSessionCreated = EFalse; return 0; } return r; }
static void InitCommsL() { TInt ret = User::LoadPhysicalDevice(PDD_NAME); User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); #ifndef __WINS__ ret = User::LoadPhysicalDevice(PDD2_NAME); ret = User::LoadPhysicalDevice(PDD3_NAME); ret = User::LoadPhysicalDevice(PDD4_NAME); #endif ret = User::LoadLogicalDevice(LDD_NAME); User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); ret = StartC32(); User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); }
void init_nw() { #if defined (__WINS__) #define PDD_NAME _L("ECDRV") #define LDD_NAME _L("ECOMM") #else #define PDD_NAME _L("EUART1") #define LDD_NAME _L("ECOMM") // alternatively "FCOMM" #endif TInt err=User::LoadPhysicalDevice(PDD_NAME); if (err!=KErrNone && err!=KErrAlreadyExists) User::Leave(err); err=User::LoadLogicalDevice(LDD_NAME); if (err!=KErrNone && err!=KErrAlreadyExists) User::Leave(err); User::LeaveIfError(StartC32()); }
/** * Function to load the Bluetooth stack. */ TInt CPanConnections::Initialise() { #if defined (__WINS__) _LIT(KPDDName, "ECDRV"); #else _LIT(KPDDName, "EUART1"); #endif _LIT(KLDDName, "ECOMM"); TInt rerr = KErrNone; rerr = StartC32();// For any Serial comms // Load required drivers rerr = User::LoadPhysicalDevice(KPDDName); if(rerr != KErrNone && rerr != KErrAlreadyExists) { return rerr; } rerr = User::LoadLogicalDevice(KLDDName); if(rerr != KErrNone && rerr != KErrAlreadyExists) { return rerr; } rerr = iSockSvr.Connect(); if(rerr) { return rerr; } TProtocolDesc iProtocolInfo; TRequestStatus status; rerr = iSockSvr.FindProtocol(_L("L2CAP"), iProtocolInfo); if(rerr) { return rerr; } // After Socket server is connected, start L2CAP protocol iSockSvr.StartProtocol(iProtocolInfo.iAddrFamily, iProtocolInfo.iSockType, iProtocolInfo.iProtocol, status); User::WaitForRequest(status); // Register SDP record. TRAP(rerr, RegisterSdpL()); return rerr; }
static void InitCommsL() { TInt err=0; err = User::LoadPhysicalDevice (PDD_NAME); if ( err != KErrAlreadyExists && err) User::Leave(err); err = User::LoadLogicalDevice (LDD_NAME); if ( err != KErrAlreadyExists && err) User::Leave(err); StartC32(); RCommServ ComSer; ComSer.Connect(); err=ComSer.LoadCommModule(_L("ECUART")); if ( err != KErrAlreadyExists && err) User::Leave(err); }
TInt E32Main() /** * Loads the USB serial driver and prints its capabilities. */ { TInt r; test.Title(); test.Start(_L("Starting E32Main")); __UHEAP_MARK; test.Next(_L("loading LDD")); r = User::LoadLogicalDevice(KCommDriverName); test(r == KErrNone || r == KErrAlreadyExists); #ifdef __WINS__ test.Next(_L("loading PDD")); r = User::LoadPhysicalDevice(KCommPhysDriverName); test(r == KErrNone || r == KErrAlreadyExists); #endif test.Next(_L("starting C32")); r = StartC32(); test(r == KErrNone || r == KErrAlreadyExists); test.Next(_L("connecting to comms server")); test(CommServ.Connect() == KErrNone); test.Next(_L("loading CommPort module")); r = CommServ.LoadCommModule(KCommModuleCsyName); test(r == KErrNone || r == KErrAlreadyExists); test.Next(_L("opening CommPort port")); test(CommPort.Open(CommServ, KCommModulePortNameAndNumber, ECommExclusive) == KErrNone); test.Next(_L("getting caps")); TCommCaps2 cc2; CommPort.Caps(cc2); test.Printf(_L("TCommCapsV01")); test.Printf(_L("iRate\t0x%x\n"), cc2().iRate); test.Printf(_L("iDataBits\t0x%x\n"), cc2().iDataBits); test.Printf(_L("iStopBits\t0x%x\n"), cc2().iStopBits); test.Printf(_L("iParity\t0x%x\n"), cc2().iParity); test.Printf(_L("iHandshake\t0x%x\n"), cc2().iHandshake); test.Printf(_L("iSignals\t0x%x\n"), cc2().iSignals); test.Printf(_L("iFifo\t%d\n"), cc2().iFifo); test.Printf(_L("iSIR\t%d\n"), cc2().iSIR); test.Printf(_L("TCommCapsV02")); test.Printf(_L("iNotificationCaps\t0x%x\n"), cc2().iNotificationCaps); test.Printf(_L("iRoleCaps\t0x%x\n"), cc2().iRoleCaps); test.Printf(_L("iFlowControlCaps\t0x%x\n"), cc2().iFlowControlCaps); CommPort.Close(); test(CommServ.UnloadCommModule(KCommModulePortName) == KErrNone); CommServ.Close(); #ifdef __WINS__ test(User::FreePhysicalDevice(KCommPhysDeviceName) == KErrNone); #endif test(User::FreeLogicalDevice(KCommDeviceName) == KErrNone); __UHEAP_MARKEND; test.End(); test.Close(); return KErrNone; }