usbmgmt/usbmgrtest/showcaps/src/showcaps.cpp
changeset 0 c9bc50fca66e
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 1997-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:
       
    15 * SER-COMMS\USB\TESTSRC\SHOWCAPS.CPP
       
    16 *
       
    17 */
       
    18 
       
    19 #include <c32comm.h>
       
    20 #include <e32test.h>
       
    21 
       
    22 #ifndef __WINS__
       
    23 _LIT(KCommDriverName, "EUSBC");
       
    24 _LIT(KCommDeviceName, "USBC");
       
    25 _LIT(KCommModuleCsyName, "ECACM");
       
    26 _LIT(KCommModulePortNameAndNumber, "ACM::0");
       
    27 _LIT(KCommModulePortName, "ACM");
       
    28 #else
       
    29 _LIT(KCommPhysDriverName, "ECDRV");
       
    30 _LIT(KCommPhysDeviceName, "Comm.Wins");
       
    31 _LIT(KCommDriverName, "ECOMM");
       
    32 _LIT(KCommDeviceName, "Comm");
       
    33 _LIT(KCommModuleCsyName, "ECUART");
       
    34 _LIT(KCommModulePortNameAndNumber, "COMM::0");
       
    35 _LIT(KCommModulePortName, "COMM");
       
    36 #endif
       
    37 
       
    38 LOCAL_D RCommServ CommServ;
       
    39 LOCAL_D RComm CommPort;
       
    40 LOCAL_D RTest test(_L("SHOWCAPS"));
       
    41 
       
    42 TInt E32Main()
       
    43 /**
       
    44  * Loads the USB serial driver and prints its capabilities.
       
    45  */
       
    46 	{
       
    47 	TInt r;
       
    48 
       
    49 	test.Title();
       
    50 	test.Start(_L("Starting E32Main"));
       
    51 
       
    52  	__UHEAP_MARK;
       
    53 
       
    54 	test.Next(_L("loading LDD"));
       
    55 	r = User::LoadLogicalDevice(KCommDriverName);
       
    56 	test(r == KErrNone || r == KErrAlreadyExists);
       
    57 
       
    58 #ifdef __WINS__
       
    59 	test.Next(_L("loading PDD"));
       
    60 	r = User::LoadPhysicalDevice(KCommPhysDriverName);
       
    61 	test(r == KErrNone || r == KErrAlreadyExists);
       
    62 #endif
       
    63 
       
    64 	test.Next(_L("starting C32"));
       
    65 	r = StartC32();
       
    66 	test(r == KErrNone || r == KErrAlreadyExists);
       
    67 
       
    68 	test.Next(_L("connecting to comms server"));
       
    69 	test(CommServ.Connect() == KErrNone);
       
    70 
       
    71 	test.Next(_L("loading CommPort module"));
       
    72 	r = CommServ.LoadCommModule(KCommModuleCsyName);
       
    73 	test(r == KErrNone || r == KErrAlreadyExists);
       
    74 
       
    75 	test.Next(_L("opening CommPort port"));
       
    76 	test(CommPort.Open(CommServ, KCommModulePortNameAndNumber, ECommExclusive) == KErrNone);
       
    77 
       
    78 	test.Next(_L("getting caps"));
       
    79 	TCommCaps2 cc2;
       
    80 	CommPort.Caps(cc2);
       
    81 	test.Printf(_L("TCommCapsV01"));
       
    82 	test.Printf(_L("iRate\t0x%x\n"), cc2().iRate);
       
    83 	test.Printf(_L("iDataBits\t0x%x\n"), cc2().iDataBits);
       
    84 	test.Printf(_L("iStopBits\t0x%x\n"), cc2().iStopBits);
       
    85 	test.Printf(_L("iParity\t0x%x\n"), cc2().iParity);
       
    86 	test.Printf(_L("iHandshake\t0x%x\n"), cc2().iHandshake);
       
    87 	test.Printf(_L("iSignals\t0x%x\n"), cc2().iSignals);
       
    88 	test.Printf(_L("iFifo\t%d\n"), cc2().iFifo);
       
    89 	test.Printf(_L("iSIR\t%d\n"), cc2().iSIR);
       
    90 	test.Printf(_L("TCommCapsV02"));
       
    91 	test.Printf(_L("iNotificationCaps\t0x%x\n"), cc2().iNotificationCaps);
       
    92 	test.Printf(_L("iRoleCaps\t0x%x\n"), cc2().iRoleCaps);
       
    93 	test.Printf(_L("iFlowControlCaps\t0x%x\n"), cc2().iFlowControlCaps);
       
    94 
       
    95 	CommPort.Close();
       
    96 	test(CommServ.UnloadCommModule(KCommModulePortName) == KErrNone);
       
    97 	CommServ.Close();
       
    98 #ifdef __WINS__
       
    99 	test(User::FreePhysicalDevice(KCommPhysDeviceName) == KErrNone);
       
   100 #endif
       
   101 	test(User::FreeLogicalDevice(KCommDeviceName) == KErrNone);
       
   102 
       
   103 	__UHEAP_MARKEND;
       
   104 
       
   105 	test.End();
       
   106 	test.Close();
       
   107 
       
   108 
       
   109 	return KErrNone;
       
   110 	}