TInt CVtConsoleOutputController::SetCursorPosRel(const TPoint& aPoint) { TInt err = KErrInUse; if (iMode == ConsoleMode::EText) { TBuf8<32> buf; if (aPoint.iY == 0) { // Do nothing. } else if (aPoint.iY < 0) { // Move cursor up. _LIT8(KEscapeCursorUp, "\x1b[%uA"); buf.AppendFormat(KEscapeCursorUp, -aPoint.iY); } else if (aPoint.iY > 0) { // Move cursor down. _LIT8(KEscapeCursorDown, "\x1b[%uB"); buf.AppendFormat(KEscapeCursorDown, aPoint.iY); } if (aPoint.iX == 0) { // Do nothing. } else if (aPoint.iX < 0) { // Move cursor left. _LIT8(KEscapeCursorLeft, "\x1b[%uD"); buf.AppendFormat(KEscapeCursorLeft, -aPoint.iY); } else if (aPoint.iX > 0) { // Move cursor right. _LIT8(KEscapeCursorRight, "\x1b[%uC"); buf.AppendFormat(KEscapeCursorRight, aPoint.iY); } err = KErrNone; if (buf.Length() > 0) { err = iOutput.Output(buf); if (err == KErrNone) { iCursorTracker->SetCursorPosRel(aPoint); } } } return err; }
void AssertionFail(const char* aAssertion, const char* aFile, TInt aLine) { __DEBUGGER(); TBuf8<256> buf; TSilentOverflow o; buf.AppendFormat(_L8("Assertion failed: \"%s\" in %s:%i\n"), &o, aAssertion, aFile, aLine); if (buf.Length()*2>buf.MaxLength()) buf.SetLength(buf.MaxLength()/2); console->Write(buf.Expand()); User::Panic(_L("Fed"), aLine); }
// ----------------------------------------------------------------------------- // CSdpConnectionField::EncodeL // Writes attributes in proper format to the stream // ----------------------------------------------------------------------------- // EXPORT_C void CSdpConnectionField::EncodeL( RWriteStream& aStream ) const { __TEST_INVARIANT; TBuf8<20> number; // Is enough for addr as well // c=<network type> <address type> <connection address> RStringF header = iPool.StringF( SdpCodecStringConstants::EConnection, SdpCodecStringConstants::Table ); aStream.WriteL( header.DesC() ); // Network type aStream.WriteL( iNetType.DesC() ); aStream.WriteL( KSPStr ); // Address type aStream.WriteL( iAddressType.DesC() ); aStream.WriteL( KSPStr ); // Connection address aStream.WriteL( *iAddress ); if ( iTTL != KErrNotFound ) { number.Zero(); number.Append( KSlashStr ); number.AppendFormat( _L8("%d"), iTTL ); aStream.WriteL( number ); } if ( iNumOfAddress > 1 ) { number.Zero(); number.Append( KSlashStr ); number.AppendFormat( _L8("%u"), iNumOfAddress ); aStream.WriteL( number ); } // End-of-Line mark aStream.WriteL( KCRLFStr ); }
LOCAL_C void TestReportLog(const TDesC8& aText) { TBuf8<200> buf; TTime now; now.UniversalTime(); TDateTime dateTime; dateTime = now.DateTime(); buf.Format(_L8 ("%02d.%02d:%02d:%06d "),dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond()); buf.AppendFormat(_L8("%S\015\012"),&aText); TestRpt.Write(buf); TestRpt.Flush(); }
void CDTSYLogger::WriteRecord(const TDesC8& aText) { if(iValid) { TBuf8<KGenericBufferSize> buf; TTime now; now.UniversalTime(); TDateTime dateTime; dateTime = now.DateTime(); buf.Format(_L8 ("%04d/%02d/%02d %02d.%02d:%02d:%06d "),dateTime.Year(),dateTime.Month()+1, dateTime.Day()+1,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond()); buf.AppendFormat(_L8("%S\015\012"),&aText); iFile.Write(buf); iFile.Flush(); } }
void CDatabase::PrintDecisionL(CDecisionRecord& aRecord) { _LIT(KDelimiter, ";"); _LIT(KWriteId, "\"%08x\""); _LIT(KWriteString, "\"%S\""); _LIT8(KWriteString8,"\"%S\""); _LIT8(KWriteHex8, "%02x"); iPrinter->PrintfL(KWriteId,aRecord.iClientSid.iId); iPrinter->PrintfL(KDelimiter); iPrinter->PrintfL(KWriteId,aRecord.iEvaluatorId.iUid); iPrinter->PrintfL(KDelimiter); iPrinter->PrintfL(KWriteId,aRecord.iServiceId.iUid); iPrinter->PrintfL(KDelimiter); iPrinter->PrintfL(KWriteId,aRecord.iServerSid.iId); iPrinter->PrintfL(KDelimiter); TBuf8<KUpsMaxFingerprintLength*2> hexdump; TUint8 *ptr = (TUint8 *)aRecord.iFingerprint.Ptr(); TInt i; TInt len = aRecord.iFingerprint.Length(); for(i=0; i<len; ++i) { hexdump.AppendFormat(KWriteHex8,ptr[i]); } iPrinter->Printf8L(KWriteString8,&hexdump); iPrinter->PrintfL(KDelimiter); if(iFlag & EPrintBinary) { iPrinter->Printf8L(KWriteString8,&aRecord.iClientEntity); iPrinter->PrintfL(KDelimiter); } else { hexdump.Zero(); ptr = (TUint8 *)aRecord.iClientEntity.Ptr(); len = aRecord.iClientEntity.Length(); for(i=0; i<len; ++i) { hexdump.AppendFormat(KWriteHex8,ptr[i]); } iPrinter->Printf8L(KWriteString8,&hexdump); iPrinter->PrintfL(KDelimiter); } iPrinter->PrintfL(KWriteString,&aRecord.iDescription); iPrinter->PrintfL(KDelimiter); iPrinter->PrintfL(KWriteId,aRecord.iResult); iPrinter->PrintfL(KDelimiter); iPrinter->PrintfL(KWriteId,aRecord.iEvaluatorInfo); iPrinter->PrintfL(KDelimiter); iPrinter->PrintfL(KWriteId,aRecord.iMajorPolicyVersion); iPrinter->PrintfL(KDelimiter); iPrinter->PrintfL(KWriteId,aRecord.iRecordId); iPrinter->Printf8L(_L8("\n")); }
EXPORT_C void RTestExecuteLogServ::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt, VA_LIST aList) /** * @param aFile - Source file name * @param aLine - Source file line number * @param aSeverity - ERR, WARN, INFO * @param aFmt - UNICODE format string * @param aList - Variable argument list * * Format a log output line */ { if (aSeverity>iLogLevel) { return; } // Create a filename string TBuf16<KMaxFilename> fileName; GetCPPModuleName(fileName, aFile); // Create a buffer for formatting HBufC* buffer = HBufC::New(KMaxTestExecuteLogLineLength*2); if (buffer) { TPtr ptr(buffer->Des()); _LIT(KErr,"ERROR - "); _LIT(KHigh,"HIGH - "); _LIT(KWarn,"WARN - "); _LIT(KMedium,"MEDIUM - "); _LIT(KInfo,"INFO - "); _LIT(KLow,"LOW - "); _LIT(KFormat," %d %S %d "); if(aSeverity == ESevrErr) ptr.Append(KErr); else if(aSeverity == ESevrHigh) ptr.Append(KHigh); else if(aSeverity == ESevrWarn) ptr.Append(KWarn); else if(aSeverity == ESevrMedium) ptr.Append(KMedium); else if (aSeverity == ESevrInfo) ptr.Append(KInfo); else if(aSeverity == ESevrLow) ptr.Append(KLow); else //if(aSeverity == ESevrAll) ptr.Append(KInfo); // Add the thread id ptr.AppendFormat(KFormat,(TInt)RThread().Id(),&fileName, aLine); TTEFDes16Overflow des16OverflowObject; ptr.AppendFormatList(aFmt, aList, &des16OverflowObject); TRAP_IGNORE(WriteL(ptr)); delete buffer; } else { _LIT(KWarn,"WARN - "); TBuf8<KLowMemBufLength> noMemory; AddTime(noMemory); noMemory.Append(KWarn); noMemory.AppendFormat(_L8(" %d "), (TInt)RThread().Id()); noMemory.Append(fileName); noMemory.AppendFormat(_L8(" %d %S"), aLine, &KLoggerNotEnoughMemory8()); TRAP_IGNORE(WriteL(noMemory)); } }
/* ??? 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); tim.After(tStat,40000000); // 40Secs test.Printf(_L(">")); FOREVER { User::WaitForAnyRequest(); if (tStat!=KRequestPending) { // test.Printf(_L("t")); // Timed out theSerialPort->ReadCancel(); // Cancel serial read User::WaitForRequest(rxStat); if (txBlks>0) { theSerialPort->WriteCancel(); // Cancel serial write User::WaitForRequest(txStat); } loopBackFail=KErrTimedOut; // Test failed break; } else if (rxStat!=KRequestPending) { // test.Printf(_L("r")); // Serial rx request complete if (rxStat!=0) { loopBackFail=rxStat.Int(); // Test failed goto endSerial; } for (i=0; i<KBlockSize; i++) { if (rxBuf[i]!=i) { loopBackFail=KErrCorrupt; // Test failed rxBuf[KBlockSize-1]=0; // PrintBuf(rxBuf); // ??? // goto endSerial; // !!!Ignore compare fails for now!!! } } test.Printf(_L("<")); if (++rxBlks<totalBlocksToTransfer) { rxBuf.Fill(0,KBlockSize); theSerialPort->Read(rxStat,rxBuf,KBlockSize); } else { loopBackFail=KErrNone; endSerial: tim.Cancel(); // Cancel timer request. User::WaitForRequest(tStat); if (txBlks>0) { theSerialPort->WriteCancel(); // Cancel serial write User::WaitForRequest(txStat); } break; } } else if (txStat!=KRequestPending) { // test.Printf(_L("s")); // Serial tx request complete if (txBlks>0) { theSerialPort->Write(txStat,txBuf,KBlockSize); test.Printf(_L(">")); txBlks--; } } else { // test.Printf(_L("?")); // Stray signal - cancel everything theSerialPort->ReadCancel(); // Cancel serial read User::WaitForRequest(rxStat); tim.Cancel(); // Cancel timer request. User::WaitForRequest(tStat); if (txBlks>0) { theSerialPort->WriteCancel(); // Cancel serial write User::WaitForRequest(txStat); } loopBackFail=KErrDied; break; } } test.Printf(_L(" (%d)\r\n"),loopBackFail); // !!! At this point RTS may or may not be asserted following the write cancel. The // following seems necessary to make sure RTS is asserted so any remaining Rx data // can be received.and thrown away User::After(2000000); theSerialPort->ResetBuffers(); User::After(1000000); // Wait 1Secs for any remaining Rx data tim.Close(); test.Next(_L("Disconnect")); theSerialPort->ResetBuffers(); // Through away any remaining Rx data. txBuf.Format(_L8("+++")); test(theSerialPort->WriteS(txBuf)==KErrNone); User::After(2000000); // 2Secs err=theSerialPort->QueryReceiveBuffer(); test(err>0); rxBuf.SetLength(err); theSerialPort->ReadOneOrMore(rxStat,rxBuf); User::WaitForRequest(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); txBuf.Format(_L8("ATH0\r")); test(theSerialPort->WriteS(txBuf)==KErrNone); User::After(4000000); // 4Secs err=theSerialPort->QueryReceiveBuffer(); test(err>0); rxBuf.SetLength(err); theSerialPort->ReadOneOrMore(rxStat,rxBuf); User::WaitForRequest(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("Check result")); test(loopBackFail==KErrNone || loopBackFail==KErrCorrupt); // !!!Ignore compare fails for now!!! // test(loopBackFail==KErrNone); test.End(); }