本文整理汇总了C++中TBuf8::Fill方法的典型用法代码示例。如果您正苦于以下问题:C++ TBuf8::Fill方法的具体用法?C++ TBuf8::Fill怎么用?C++ TBuf8::Fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBuf8
的用法示例。
在下文中一共展示了TBuf8::Fill方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
GLDEF_C TInt E32Main()
{
#if defined (__WINS__)
// Connect to all the local drives first as will be the case in ARM
TBusLocalDrive Drive[KMaxLocalDrives];
TBool ChangedFlag[KMaxLocalDrives];
TInt i;
for (i=0;i<KMaxLocalDrives;i++)
Drive[i].Connect(i,ChangedFlag[i]);
#endif
test.Title();
//
test.Start(_L("Load/open logical device"));
TInt r;
r=User::LoadLogicalDevice(_L("D_PCCDIF"));
test(r==KErrNone||r==KErrAlreadyExists);
RPcCardCntrlIf pccdDrv;
r=pccdDrv.Open(KSocket,pccdDrv.VersionRequired());
test(r==KErrNone);
//
test.Next(_L("Power card and configure."));
UserSvr::ForceRemountMedia(ERemovableMedia0); // Media change - ensures test always starts from same state
User::After(300000); // Allow 0.3s after power down for controller to detect door closed.
pccdDrv.Reset();
TRequestStatus mrs;
test(pccdDrv.RegisterEvent(EPcCardEvMediaChange,&mrs)==KErrNone);
TRequestStatus prs;
pccdDrv.PwrUp(&prs);
User::WaitForRequest(prs);
test(prs.Int()==KErrNone);
TPcCardStatus s;
TSocketSignals ind;
test(pccdDrv.SocketInfo(s,ind)==KErrNone);
test(s==EPcCardReady);
TPcCardTypePckg tyBuf;
TPcCardType &ty=tyBuf();
test(pccdDrv.CardInfo(&tyBuf)==KErrNone);
test(ty.iFuncType[0]==EFFixedDiskCard);
test(pccdDrv.ReqConfig(KFunc,1)==KErrNone);
// Test we can get the same chunk as the controllers attrib. chunk (its shareable).
test.Next(_L("Request 64K attribute chunk at 0H."));
TPcCardChnk ch;
ch.iMemType=EPcCardAttribMem;
ch.iMemBaseAddr=0;
ch.iMemLen=0x10000;
TInt win0,win1,win2;
test(pccdDrv.ReqMem(ch,EAccSpeed600nS,win0)==KErrNone);
TBuf8<8> rdBuf;
rdBuf.Fill(0,8);
test(pccdDrv.ReadMem(win0,0,8,rdBuf)==KErrNone);
// test(rdBuf.Compare(_L("\x01\xFF\x04\xFF\xDF\xFF\x72\xFF"))==0);
test(rdBuf[0]==0x01&&rdBuf[2]==0x04&&rdBuf[4]==0xDF&&rdBuf[6]==0x72);
// Test we can get small chunk within the controllers attrib. chunk (Win0 already allocated).
test.Next(_L("Request 16byte attribute chunk at 10H."));
ch.iMemType=EPcCardAttribMem;
ch.iMemBaseAddr=0x10;
ch.iMemLen=0x10;
test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrAccessDenied); // 1st chunk isn't shared
pccdDrv.RelMem(win0);
test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrNone);
rdBuf.Fill(0,8);
test(pccdDrv.ReadMem(win1,0,8,rdBuf)==KErrNone);
// test(rdBuf.Compare(_L("\x03\xFF\xD9\xFF\x01\xFF\xFF\xFF"))==0);
test(rdBuf[0]==0x03&&rdBuf[2]==0xD9&&rdBuf[4]==0x01&&rdBuf[6]==0xFF);
// Test we can get a second small chunk, also within the controllers attrib. chunk but
// not clashing with previous chunk (Win1 already allocated).
test.Next(_L("Request 16byte attribute chunk at 20H."));
ch.iMemType=EPcCardAttribMem;
ch.iMemBaseAddr=0x20;
ch.iMemLen=0x10;
test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win0)==KErrNone);
rdBuf.Fill(0,8);
test(pccdDrv.ReadMem(win0,0,8,rdBuf)==KErrNone);
// test(rdBuf.Compare(_L("\x20\xFF\x06\xFF\x45\xFF"))==2&&rdBuf[6]==0x00&&rdBuf[7]==0xFF); // 'Null causes problems with compare
test(rdBuf[0]==0x20&&rdBuf[2]==0x06&&rdBuf[4]==0x45&&rdBuf[6]==0x00);
// Test that requesting a chunk which lies partly but not entirely within the controllers
// chunk fails (Win0/Win1 already allocated).
test.Next(_L("Request 64K attribute chunk at 800H."));
test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win2)==KErrInUse);
pccdDrv.RelMem(win1);
ch.iMemType=EPcCardAttribMem;
ch.iMemBaseAddr=0x800;
ch.iMemLen=0x10000;
test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrAccessDenied);
// Test we can get a small chunk beyond the controllers chunk (Win0 already allocated).
test.Next(_L("Request 16byte attribute chunk at 10800H."));
ch.iMemType=EPcCardAttribMem;
ch.iMemBaseAddr=0x10800;
ch.iMemLen=0x10;
test(pccdDrv.ReqMem(ch,EAccSpeed300nS,win1)==KErrNone);
pccdDrv.RelMem(win1);
// Test we can get a large chunk beyond the controllers chunk (Win0 already allocated).
//.........这里部分代码省略.........
示例2: OpenSockets
TVerdict CEsockTest29::easyTestStepL()
{
// Open Sockets, one to manipulate mBufPool and one to send/revieve with tcp or udp
TESTL( OpenSockets() == KErrNone );
// Bind Test Socket To local Address
TInetAddr local;
SetPort( local, KPort, KLocal );
iTestSocket.Bind( local );
// Connect Test Socket to LoopBack Address
TInetAddr loopBack;
SetPort( loopBack, KPort, KLoopback );
ConnectSocketL( iTestSocket, loopBack );
// Gobble all the Buf's in the MBuf Pool return the number of mBufs in Use
TInt totalUsedBufs = iDummySocket.SetOpt( KDummyOptionSetGobbleMBufs, 0, 0 );
TInt bufsToBeFreed = 0;
// Data to be used during socket Send
GetIntFromConfig(KSection29, KBufSize, iBufSize);
TBool keepSending = ETrue;
TBuf8<4500> recvBuf;
TBuf8<4500> sendData;
sendData.Fill(TChar('z'), iBufSize );
TRequestStatus sendStatus;
TRequestStatus recvStatus;
const TInt KOneSecond = 1000000;
for( TInt freeBufCounter = 0; freeBufCounter < totalUsedBufs && keepSending; freeBufCounter += bufsToBeFreed )
// OOB loop that will gradually release more MBufs
{
// release some mBufs and send
iDummySocket.SetOpt( KDummyOptionSetFreeSomeMBufs, bufsToBeFreed , 0);
iTestSocket.Send( sendData, 0, sendStatus );
// Wait for a second to allow time for server/protocol to send
User::After( KOneSecond );
// Cancel the send and start to recv
iTestSocket.CancelSend();
User::WaitForRequest(sendStatus);
iTestSocket.Recv(recvBuf, 0, recvStatus);
// Wait for a second to allow time for server/protocol to recieve
User::After( KOneSecond );
iTestSocket.CancelRecv();
User::WaitForRequest( recvStatus );
if( freeBufCounter % 5 == 0 )
{
INFO_PRINTF2( _L("freeBufs now >= %d "), freeBufCounter );
}
if( recvBuf.Compare(sendData) == 0 )
// if we have recieved data then exit the loop
{
keepSending = EFalse;
}
bufsToBeFreed = 2;
}
// Now do a regular send for good measure to make sure everything is ok
sendData.Fill(TChar('c'), iBufSize );
INFO_PRINTF1( _L("End of Loop, Now sending....") );
iTestSocket.Send( sendData, 0, sendStatus );
User::WaitForRequest( sendStatus );
INFO_PRINTF2( _L("Send Returned %d, now recieving...."), sendStatus.Int() );
iTestSocket.Recv( recvBuf, 0, recvStatus );
User::After( KOneSecond );
iTestSocket.CancelRecv();
User::WaitForRequest( recvStatus );
INFO_PRINTF2( _L("Recieve returned %d ") , recvStatus.Int() );
if( recvBuf.Compare(sendData) != 0 )
{
return EFail;
}
return EPass;
}
示例3: testSyncAccess
LOCAL_C TInt testSyncAccess(TAny* aData)
///
/// Test read file handling.
///
/// @param aData pointer to the thread data area
{
TThreadData& data = *(TThreadData*)aData;
TFileName fileName = data.iFile;
TBool dowrite = (data.iData != NULL);
RFs myFs;
TInt r = myFs.Connect();
TEST(r==KErrNone);
r = myFs.SetSessionPath(gSessionPath);
if (r != KErrNone)
TTest::Fail(HERE, _L("SetSessionPath returned %d"), r);
TVolumeInfo vol;
TInt drv;
r = myFs.CharToDrive(fileName[0], drv);
if (r != KErrNone)
TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), fileName[0], r);
r = myFs.Volume(vol, drv);
if (r != KErrNone)
TTest::Fail(HERE, _L("Volume() returned %d"), r);
TInt maxwrite = TInt(vol.iFree / 2 - KBufLen);
if (maxwrite < KBufLen*2)
TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"),
TInt(vol.iFree/1024));
RFile f;
RTimer timer;
TTime startTime;
TTime endTime;
TTimeIntervalMicroSeconds timeTaken;
TBuf8<KBufLen> buff;
TRequestStatus tstat;
TInt wrnum = 0;
TInt rdnum = 0;
timer.CreateLocal();
if (dowrite)
{
// write tests
r = f.Replace(myFs, fileName, EFileStreamText | EFileWrite);
TEST(r==KErrNone);
// wait for both tasks to have a chance to complete opening the files
User::After(1000);
buff.Fill('_', KBufLen);
timer.After(tstat, KTimeBM * KSecond);
startTime.HomeTime();
while (tstat == KRequestPending)
{
TInt pos = (wrnum * KBufLen) % maxwrite;
r = f.Write(pos, buff);
TEST(r==KErrNone);
++wrnum;
}
endTime.HomeTime();
timeTaken=endTime.MicroSecondsFrom(startTime);
TInt64 dtime = timeTaken.Int64();
TInt64 dsize = wrnum * KBufLen * TInt64(KSecond);
TInt32 speed = TInt32((dsize + dtime/2) / dtime);
AddStats(gWrStats, dsize, dtime);
TTest::Printf(_L("%8d writes in %6d mS = %8d bytes per second\n"),
wrnum, TInt32(dtime)/1000, speed);
timer.Cancel();
f.Close();
}
else
{
// read tests
r = f.Open(myFs, fileName, EFileStreamText);
TEST(r==KErrNone);
// wait for both tasks to have a chance to complete opening the files
User::After(1000);
timer.After(tstat, KTimeBM * KSecond);
startTime.HomeTime();
while (tstat == KRequestPending)
{
//.........这里部分代码省略.........
示例4: TestCliServDataParamL
/**
@SYMTestCaseID SYSLIB-LOGENG-CT-4004
@SYMTestCaseDesc Tests Message schema validation for the messages accepting
TLogClientServerData parameters.
@SYMTestPriority High
@SYMTestActions Sends messages to the test server to test the validation of messages
against the message schema. The messages contain either valid or invalid
parameters.
@SYMTestExpectedResults The server should validate the message and handle bad messages appropriately
@SYMDEF INC114113
*/
void TestCliServDataParamL()
{
RClientMessageTestSession session;
TInt err = session.Connect();
TEST2(err, KErrNone);
CleanupClosePushL(session);
TLogClientServerData data;
TPckg<TLogClientServerData> pData(data);
TBuf8<sizeof(TLogClientServerData)> buf;
buf.SetLength(sizeof(TLogClientServerData));
buf.Fill(0xFF);
data.iOperationType = ELogOperationEventAdd;
data.iOperationId = 1;
err = session.TestCliServDataParam(ELogOperationInitiate,pData);
TEST2(err, KErrBadDescriptor);
data.iOperationType = ELogOperationViewWindowFetch;
data.iOperationId = 5;
err = session.TestCliServDataParam(ELogOperationInitiate,pData);
TEST2(err, KErrArgument);
data.iOperationType = ELogOperationEventAdd;
data.iOperationId = 0x8FFFFFFF;
err = session.TestCliServDataParam(ELogOperationInitiate,pData);
TEST2(err, KErrBadDescriptor);
data.iOperationType = ELogOperationEventAdd;
data.iOperationId = 0x8FFFFFFF;
err = session.TestCliServDataParam(ELogOperationInitiate,buf);
TEST2(err, KErrArgument);
data.iOperationType = ELogOperationEventAdd;
data.iOperationId = 1;
err = session.TestCliServDataParam(ELogOperationCancel,pData);
TEST2(err, KErrCancel);
data.iOperationType = ELogOperationEventAdd;
data.iOperationId = 1;
err = session.TestCliServDataParam(ELogOperationCancel,buf);
TEST2(err, KErrArgument);
CLogPackage* package = CLogPackage::NewL();
TPtr8 ptr(package->Ptr());
data.iOperationType = ELogOperationEventAdd;
data.iOperationId = 1;
err = session.TestCliServDataParam(ELogOperationGetResult,buf, ptr, 0);
TEST2(err, KErrArgument);
data.iOperationType = ELogOperationEventAdd;
data.iOperationId = 1;
err = session.TestCliServDataParam(ELogOperationGetResult,pData, ptr, -1 );
TEST2(err, KErrNone);
delete package;
TBuf8<8> smallBuf;
data.iOperationType = ELogOperationEventAdd;
data.iOperationId = 1;
err = session.TestCliServDataParam(ELogOperationGetResult,buf, smallBuf, 0);
TEST2(err, KErrArgument);
CleanupStack::PopAndDestroy(&session);
}
示例5: FillDiskL
void CPopsTestHarness::FillDiskL()
//
// Fill all available space on C: drive leaving aLeaveFreeByes free.
//
{
TInt leaveFreeBytes = KTestDiskSpace;
// Check that there is a C-drive and that it is less than 10MB in size.
TestAvailableSpaceOnDriveL();
// NOTE: This test harness should be used with a dedicated small partition or
// subst'ed floppy drive as the EPOC C: drive. As a safety precaution, it
// tests the free space on the partition to ensure that it does not attempt
// to eat 20 GB of free space and either crash Windows or at least cause a
// headache of some sort...
// Delete any old dummy fill files - if there is one to delete.
iTestUtils->FileSession().Delete(KMsvTestFillDiskFile);
// Create the delay timer
CDelayTimer* delayTimer = new(ELeave)CDelayTimer;
CleanupStack::PushL(delayTimer);
delayTimer->ConstructL();
// Check that available disk space does not exceed the max free space to fill.
// See above...
TInt64 freeSpace;
TInt64 freeSpaceLeft;
TInt error = CheckDiskSpace(freeSpace);
TInt reclaimActive = 0;
do
{
delayTimer->Delay(KMsvTestBackgroundDeleteInitialWait);
error = CheckDiskSpace(freeSpaceLeft);
if (freeSpaceLeft == freeSpace)
reclaimActive++;
freeSpace = freeSpaceLeft;
}
while (!error && reclaimActive<3);
User::LeaveIfError(error);
CleanupStack::PopAndDestroy(); //delayTimer
// Free space in kb.
freeSpace/=KFillDiskOneKByte;
// Check free space on C: drive is not too big.
TInt freeSpaceInKb = I64INT(freeSpace);
if (freeSpaceInKb>KFillDiskTooBigFreeSize)
User::Leave(KErrTooBig);
// Fill disk with large file.
TBuf8<KFillDiskMaxBlockSize> dummy;
dummy.SetMax();
dummy.Fill('?');
// Open dummy file.
RFile fillDiskFile;
User::LeaveIfError(fillDiskFile.Replace(iTestUtils->FileSession(), KMsvTestFillDiskFile, EFileWrite));
// Establish required dummy file size.
freeSpaceLeft-=leaveFreeBytes;
if (freeSpaceLeft<0)
// Uh oh, we have less space available than what was asked for...
User::Leave(KErrDiskFull);
// Write dummy file.
while (freeSpaceLeft>0 && error==KErrNone)
{
dummy.SetLength(Min(KFillDiskMaxBlockSize,I64INT(freeSpaceLeft)));
error=fillDiskFile.Write(dummy);
freeSpaceLeft-=KFillDiskMaxBlockSize;
}
fillDiskFile.Close();
if (error==KErrDiskFull)
error=KErrNone;
User::LeaveIfError(error);
}
示例6: PrintBuf
/* ???
LOCAL_C void PrintBuf(TDes8 &aBuf)
//
// Print the contents of a buffer
//
{
TInt len=aBuf.Length();
for (TInt i=0;i<=len/8;i++)
{
test.Printf(_L("%4d: "),i*8);
for (TInt j=0;j<8;j++)
{
if ((i*8)+j>=len)
break;
TInt v=aBuf[(i*8)+j];
test.Printf(_L("%02x "),v);
}
test.Printf(_L("\n\r"));
}
}
*/
LOCAL_C void testLoopBack(TLineRate aLineRate,TBps aBaudRate)
//
// Perform an analogue loopback test at the specified linerate
//
{
TInt err;
TBuf<64> b;
TPtrC bd=BaudRateInText(aBaudRate);
b.Format(_L("Loopback test(%S)"),&bd);
test.Start(b);
TBuf8<KBlockSize> txBuf;
theSerialPort->ResetBuffers();
txBuf.Format(_L8("AT&F+MS=%d,0,%d,%d\\N0&K3&D2M0\r"),LineModeData[aLineRate],LineRateData[aLineRate],LineRateData[aLineRate]);
test(theSerialPort->WriteS(txBuf)==KErrNone);
TBuf8<KBlockSize> rxBuf;
User::After(2000000); // 2Secs
err=theSerialPort->QueryReceiveBuffer();
test(err>0);
rxBuf.SetLength(err);
TRequestStatus rxStat;
theSerialPort->ReadOneOrMore(rxStat,rxBuf);
User::WaitForRequest(rxStat);
// test.Printf(_L(" Rx(%d):"),rxStat); // ???
test(rxStat==KErrNone);
txBuf.Append(_L("\r\nOK\r\n"));
err=rxBuf.Compare(txBuf);
// test(TranslateCrLf(rxBuf)==KErrNone); // ???
// test.Printf(_L(" %S\r\n"),&rxBuf); // ???
test(err==0);
test.Next(_L("Get loopback"));
txBuf.Format(_L8("AT&T1\r"));
test(theSerialPort->WriteS(txBuf)==KErrNone);
User::After(5000000); // 5Secs
err=theSerialPort->QueryReceiveBuffer();
test(err>0);
rxBuf.SetLength(err);
theSerialPort->ReadOneOrMore(rxStat,rxBuf);
User::WaitForRequest(rxStat);
test.Printf(_L(" Rx(%d):"),rxStat);
test(rxStat==KErrNone);
txBuf.AppendFormat(_L8("\r\nCONNECT %d\r\n"),LineConnectData[aLineRate]);
err=rxBuf.Compare(txBuf);
test(TranslateCrLf(rxBuf)==KErrNone);
test.Printf(_L(" %S\r\n"),&rxBuf); // Print what we got back (without CR/LF etc).
// Sometimes get extra character as modem goes on-line so just look for command echo + connect
test(err>=0);
User::After(2000000); // 2Secs
TInt totalBlocksToTransfer;
if (aBaudRate<EBps1200||aLineRate<EV22_1200)
totalBlocksToTransfer=KBlocksShort;
else if (aBaudRate<EBps4800||aLineRate<EV32_4800)
totalBlocksToTransfer=KBlocksMedium;
else if (aLineRate<EV34_28800)
totalBlocksToTransfer=KBlocksLong;
else
totalBlocksToTransfer=KBlocksVeryLong;
b.Format(_L("Transfering data(%dK)"),(totalBlocksToTransfer*KBlockSize)/1024);
test.Next(b);
TInt loopBackFail=KErrGeneral;
TRequestStatus txStat;
txBuf.SetLength(KBlockSize);
TInt i;
for (i=0; i<KBlockSize; i++)
txBuf[i]=(TUint8)i;
theSerialPort->Write(txStat,txBuf,KBlockSize);
TInt txBlks=(totalBlocksToTransfer-1);
rxBuf.Fill(0,KBlockSize);
theSerialPort->Read(rxStat,rxBuf,KBlockSize);
TInt rxBlks=0;
TRequestStatus tStat;
RTimer tim;
test(tim.CreateLocal()==KErrNone);
//.........这里部分代码省略.........