示例#1
0
void print_debug_inf_before_launch()
{
      Wait ( 500 ) ;
      PrintToScreen ( "\nVEX Debugger Utility\nby James Swineson\n\nStarting...\n" ) ;
    PrintToScreen("Now you can switch to graphic display.\n");
    ResetGD ( ) ;
}
示例#2
0
//MailSlot of flush DNS cache sender
bool WINAPI FlushDNSMailSlotSender(
	const wchar_t *Domain)
{
//Mailslot initialization
	HANDLE hFile = CreateFileW(MAILSLOT_NAME, GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		PrintToScreen(true, L"Create mailslot error, error code is %lu.\n", GetLastError());
		return false;
	}

//Message initialization
	std::wstring Message(MAILSLOT_MESSAGE_FLUSH_DNS);
	if (Domain != nullptr)
	{
		Message.append(L": ");
		Message.append(Domain);
	}

//Write into mailslot.
	DWORD cbWritten = 0;
	if (!WriteFile(hFile, Message.c_str(), (DWORD)(sizeof(wchar_t) * Message.length() + 1U), &cbWritten, nullptr))
	{
		PrintToScreen(true, L"MailSlot write messages error, error code is %lu.\n", GetLastError());
		CloseHandle(hFile);

		return false;
	}
	else {
		CloseHandle(hFile);
		PrintToScreen(true, L"Flush DNS cache message was sent successfully.\n");
	}

	return true;
}
示例#3
0
//Catch Control-C exception from keyboard.
BOOL WINAPI CtrlHandler(
	const DWORD fdwCtrlType)
{
//Print to screen.
	if (GlobalRunningStatus.Console)
	{
		switch (fdwCtrlType)
		{
		//Handle the CTRL-C signal.
			case CTRL_C_EVENT:
			{
				PrintToScreen(true, L"Get Control-C.\n");
			}break;
		//Handle the CTRL-Break signal.
			case CTRL_BREAK_EVENT:
			{
				PrintToScreen(true, L"Get Control-Break.\n");
			}break;
		//Handle other signals.
			default:
			{
				PrintToScreen(true, L"Get closing signal.\n");
			}break;
		}
	}

	return FALSE;
}
示例#4
0
GLDEF_C void TryUSBMS()
	{
	// Check first whether this boot is intended to load and boot an image from
	// the media.
	if (LoadDevice == EBootUSBMS)
		{
		PrintToScreen(_L("USB-MS boot scanning drives\r\n"));
		// search drives for file - returns true if an image has been found
		if (SearchDrives())
			DoDownload();
		}

	PrintToScreen(_L("Starting USB Mass Storage\r\n"));
	DisableMenu();
	if(StartUSBMS())
		{
		// USB Mass Storage boot has started - don't continue with the
		// bootloader, sleep here.
		while(1)
			User::After(10000000);
		}
	else
		{
		EnableMenu();
		// Not started (probably no card in drive) revert to normal bootloader
		// mode and notify the variant to rewrite it's configuration.
		PrintToScreen(_L("NO VALID MEDIA\r\n"));
		PrintToScreen(_L("Leaving USB Mass Storage mode\r\n"));
		LoadDevice = ELoadDrive;
		WriteConfig();
		}

	return;
	}
void WaitForTouch() {
    int pressed = !GetDigitalInput(button);
    while(pressed == 1 && IsAutoActive()) {
        SetDrive(0,0);
    }
    PrintToScreen ("Pressed!\n");
}
示例#6
0
static void setArmPID() {
    long armDegrees = ArmState;
    long armPIDPosition = degreesToIMEticks(armDegrees);

    PrintToScreen("SetArmPID: %d, %d\n", armDegrees, armPIDPosition); 
    UpdateSetpointIntegratedMotorEncoderPID(armL, armPIDPosition); 
    UpdateSetpointIntegratedMotorEncoderPID(armR, -armPIDPosition);
}
示例#7
0
GLDEF_C void BootFault(TUint aId, TInt aLine, char aFileName[])
{
    PrintToScreen(_L("BOOTFAULT: 0x%X in file %s @ line %d"), aId, aFileName, aLine);
    User::After(1000);	// delay to let the LCD draw the message
    RDebug::Print(_L("BOOTFAULT: 0x%X in file %s @ line %d"), aId, aFileName, aLine);
    User::LeaveIfError(KErrUnknown);
//	Kern::Fault((const char*)buf.Ptr(),aLine);
}
示例#8
0
void ProcessHeader(TZipInfo& a)
	{
	FileName=a.iName;
	LoadSize=a.iUncompressedSize;
	TInt size_mod_4k=LoadSize & 0xfff;
	if (size_mod_4k==0)
		ImageHeaderPresent=EFalse;
	else if (size_mod_4k==256)
		ImageHeaderPresent=ETrue;
	else
		{
		PrintToScreen(_L("\r\n\r\nInvalid size\r\n"));
		BOOT_FAULT();
		}
	ImageSize=ImageHeaderPresent ? LoadSize-256 : LoadSize;

	PrintToScreen(_L("Unzip %lS, size %d\r\n"),&FileName,LoadSize);

#ifdef __SUPPORT_FLASH_REPRO__
	if (LoadToFlash)
		{
		TInt r=InitFlashWrite();
		if (r!=KErrNone)
			{
			PrintToScreen(_L("InitFlashWrite returned %d\r\n"),r);
			BOOT_FAULT();
			}
		}
#endif

	a.iOutBuf=(TUint8*)DestinationAddress();

	a.iHeaderDone=2;
	TRequestStatus* pS=&a.iProcessedHeader;

	
	RThread t;
	t.SetHandle(a.iThreadHandle);
	t.RequestComplete(pS,0);
	}
示例#9
0
//Flush DNS cache FIFO sender
bool FlushDNSFIFOSender(
	const uint8_t *Domain)
{
//Message initialization
	std::string Message(FIFO_MESSAGE_FLUSH_DNS);
	if (Domain != nullptr)
	{
		Message.append(": ");
		Message.append((const char *)Domain);
	}

//Write into FIFO file.
	errno = 0;
	int FIFO_Handle = open(FIFO_PATH_NAME, O_WRONLY|O_TRUNC|O_NONBLOCK, 0);
	if (FIFO_Handle > 0)
	{
		if (write(FIFO_Handle, Message.c_str(), Message.length() + 1U) > 0)
		{
			close(FIFO_Handle);
			PrintToScreen(true, L"Flush DNS cache message was sent successfully.\n");

			return true;
		}
		else {
			close(FIFO_Handle);
		}
	}

//Print error log.
	std::lock_guard<std::mutex> ScreenMutex(ScreenLock);
	PrintToScreen(false, L"FIFO write messages error");
	if (errno > 0)
		PrintToScreen(false, L", error code is %d.\n", errno);
	else 
		PrintToScreen(false, L".\n");

	return false;
}
示例#10
0
GLDEF_C void AcceptUnzippedBlock(TZipInfo& aInfo, TUint8*& aOutPtr, TInt aError)
	{
	if (aError!=KErrNone)
		{
		PrintToScreen(_L("Error!\r\n"));
		BOOT_FAULT();
		}
#ifdef __SUPPORT_FLASH_REPRO__
	if (LoadToFlash)
		{
		// signal flash programming thread
		TInt got=(TInt)((TLinAddr)aOutPtr-(TLinAddr)DestinationAddress());
		NotifyDataAvailable(got);
		}
#endif
	}
示例#11
0
void DebugArm() {
    long l, r;
    l = GetIntegratedMotorEncoder(armL); 
    r = GetIntegratedMotorEncoder(armR);
    PrintToScreen("arm encs: %ld, %ld\n", l, r);
}
示例#12
0
TInt DoZipDownload(RFile &aBootFile)
	{
	TZipInfo z;
	z.iRemain=FileSize;
	InitProgressBar(0,(TUint)FileSize,_L("LOAD"));
	TInt r=Initialise(z);
	CHECK(r);
	RThread t;
	t.SetHandle(z.iThreadHandle);

	while (z.iRemain && z.iThreadStatus==KRequestPending)
		{
		TRequestStatus dummy;
		TRequestStatus* pS=&dummy;

		r=ReadBlockToBuffer(z, aBootFile);
		if (r != KErrNone)
			{
			PrintToScreen(_L("FAULT: Unzip Error %d\r\n"),r);
			if (z.iFileBufW-z.iFileBufR==z.iFileBufSize)
				{
				PrintToScreen(_L("Check there is only one image\n\rin the zip file.\r\n"));
				}
			CHECK(r);
			}

		UpdateProgressBar(0,(TUint)(FileSize-z.iRemain));
		t.RequestComplete(pS,0);		// same process
		while(z.iHeaderDone==0 && z.iThreadStatus==KRequestPending)
			{
			DELAY(20000);
			}
		if (z.iHeaderDone==1 && z.iThreadStatus==KRequestPending)
			{
			// after reading first block, process the header
			ProcessHeader(z);
			}
		}	// while

	User::WaitForRequest(z.iThreadStatus);

	TInt exitType=t.ExitType();
	TInt exitReason=t.ExitReason();
	if (z.iRemain || exitType!=EExitKill || exitReason!=KErrNone)
		{
		TBuf<32> exitCat=t.ExitCategory();
		PrintToScreen(_L("Exit code %d,%d,%S\n"),exitType,exitReason,&exitCat);
		TEST(0);
		}

	PrintToScreen(_L("Unzip complete\r\n"));
	
	TUint8* pD=Buffer;
	TInt len=1024;

	r=ReadInputData(pD,len);
	TEST(r==KErrEof);


	DELAY(20000);

	Cleanup(z);
	return KErrNone;
	}
示例#13
0
void SaveState() {
    SetSaveCompetitionIme(armL);
    SetSaveCompetitionIme(armR);
    GlobalData(GDATA_ARM) = ArmState;
    PrintToScreen("save: %d, %d\n", ArmState);
}
示例#14
0
/*-----------------------------------------------------------------------------------
--	FUNCTION: MonitorInputThread
--
--	DATE:			October 3, 2015
--
--	REVISIONS:		N/A
--
--	DESIGNER:		Alvin Man
--
--	PROGRAMMER:		Alvin Man
--
--	INTERFACE:		DWORD WINAPI MonitorInputThread(LPVOID hwnd)
--
--	RETURNS:		DWORD
--
--	NOTES:			This is the main read thread code that handles receiving
--					characters from the serial port asynchronously.  
-----------------------------------------------------------------------------------*/
DWORD WINAPI MonitorInputThread(LPVOID hwnd) {

	DWORD readBytes;
	DWORD dwRes;
	DWORD readThreadExitCode;
	char readBuffer[80] = "\0\0\0\0\0\0\0\0\0\0";
	BOOL waitingOnRead = FALSE;

	if (!SetupComm()) {
		OutputDebugString("Error occurred while setting up communications");
		return 0;
	}

	// create manual reset event for asynchronous I/O
	o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	if (o.hEvent == NULL) {
		OutputDebugString("Error creating reset event");
		return 0;
	}

	// read loop
	while (1) {
		//check if the session is still connected
		if (!connected) {
			if (GetExitCodeThread(readThread, &readThreadExitCode) != 0) {

				readThread = 0;
				if (!CloseHandle(hComm)) {
					OutputDebugString("Error closing handle");
				} else {
					OutputDebugString("thread closed");
				}
				
				ExitThread(readThreadExitCode);
			}
		}

		if (!waitingOnRead) {
			//attempt to read the character from the serial port
			if (!ReadFile(hComm, readBuffer, sizeof(readBuffer), &readBytes, &o)) {
				if (GetLastError() != ERROR_IO_PENDING) {
					MessageBox(NULL, "Error reading from serial port", "", MB_OK);
					readThread = 0;
					break;
				} else {
					waitingOnRead = TRUE;
				}
			}
		}

		if (waitingOnRead) {
			//wait for overlapped I/O to complete
			dwRes = WaitForSingleObject(o.hEvent, READ_TIMEOUT);
			switch (dwRes) {
			case WAIT_OBJECT_0:
				if (!GetOverlappedResult(hComm, &o, &readBytes, FALSE)) {
					MessageBox(NULL, "Error reading file", "", MB_OK);
					break;
				}
				waitingOnRead = FALSE;
				break;
			case WAIT_TIMEOUT:
				break;
			default:
				break;
			}
		}

		// If we have read characters, print them to the screen
		if (readBytes) {
			PrintToScreen(readBuffer);
		}
	}
	return 0;
}
示例#15
0
TInt YModem::GetInnerCompression(TBool &aImageDeflated, TBool &aRomLoaderHeaderExists)
    {
    // Read, analyse and buffer ROM Image Header
    
    DEBUG_PRINT((_L(">>YModem::GetInnerCompression()\r\n")))
    // Try to read first 1k from the ROM Image
    iDataSizeInPuffer = KHeaderBufferSize;
    TUint8* pD=(TUint8*)iHeaderBuf.Ptr();
    TInt r=ReadPackets(pD, iDataSizeInPuffer);
    
    DEBUG_PRINT((_L("r:%d (0x%08x).\r\n"), r, r));
    DEBUG_PRINT((_L("pD->:0x%08x.\r\n"), (TUint8*)pD));
    DEBUG_PRINT((_L("iHeaderBuf.Ptr()->:0x%08x.\r\n"), (TUint8*)iHeaderBuf.Ptr()));
    DEBUG_PRINT((_L("iDataSizeInPuffer:%d (0x%08x).\r\n"), iDataSizeInPuffer, iDataSizeInPuffer));
    
    if( iDataSizeInPuffer != pD - iHeaderBuf.Ptr())
        {
        BOOT_FAULT();
        }
        
    
    // Analyse the inner compression method
    const TUint8 * romLoaderSignature1 = (const TUint8*)"EPOC";
    const TUint8 * romLoaderSignature2 = (const TUint8*)"ROM";
    pD = (TUint8*)iHeaderBuf.Ptr();
    r = KErrNone;
    
    // Check headers
	TRomHeader* romHeader= (TRomHeader *)pD;  
	DEBUG_PRINT((_L("pD       ->:0x%08x.\r\n"), (TUint8*)pD));
	DEBUG_PRINT((_L("romHeader->:0x%08x.\r\n"), (TUint8*)romHeader));
	
	aRomLoaderHeaderExists = EFalse;
	
	if( !memcmp1(pD, romLoaderSignature1, 4) && !memcmp1((pD+8), romLoaderSignature2, 3) )
	    {
        // We have TRomLoaderHeader skip it
        romHeader = (TRomHeader *) (pD +TROM_LOADER_HEADER_SIZE);
        aRomLoaderHeaderExists = ETrue;
	    }

    DEBUG_PRINT((_L("TRomLoaderHeader exists:%d.\r\n"), aRomLoaderHeaderExists));
    DEBUG_PRINT((_L("romHeader->:0x%08x (0x%08x).\r\n"), (TUint8*)romHeader, (TUint8*)romHeader-pD));

    if(romHeader->iCompressionType == 0 )
        {
         aImageDeflated = EFalse;   
        }
    else if (romHeader->iCompressionType == KUidCompressionDeflate )
        {
        iImageDeflated = aImageDeflated = ETrue;
        }
    else
        {
        PrintToScreen(_L("Not supported compression method:0x%08x\r\n"), romHeader->iCompressionType);
        r = KErrNotSupported;
        }

    DEBUG_PRINT((_L("iCompressionType :0x%08x\r\n"), romHeader->iCompressionType));
	DEBUG_PRINT((_L("iCompressedSize  :0x%08x\r\n"), romHeader->iCompressedSize));
	DEBUG_PRINT((_L("iUncompressedSize:0x%08x\r\n"), romHeader->iUncompressedSize));
    // Buffer it.
    iHeaderStored = true;
 
    DEBUG_PRINT((_L("<<YModem::GetInnerCompression():%d\r\n"), r))
	return r;   
    }
示例#16
0
void RestoreState(long *encR, long *encL) {
    ArmState = GlobalData(GDATA_ARM);
    *encR = GetSavedCompetitionIme(armR);
    *encL = GetSavedCompetitionIme(armL);
    PrintToScreen("restore: %d, %d\n", ArmState);
}
示例#17
0
//saves the robot state to be passed from auto to user control
void SetRunningMode(MODE_TYPE mode) {
    GlobalData(GDATA_LAST_MODE) = mode;
    PrintToScreen("run mode: %d\n", mode);
}
示例#18
0
void printArmIMEdegrees() {
    PrintToScreen("%d\n", getArmIMEdegrees(armL));
}
示例#19
0
//restores robot state from autonomous
MODE_TYPE GetLastMode() {
    MODE_TYPE mode = (MODE_TYPE) GlobalData(GDATA_LAST_MODE);
    PrintToScreen("last mode: %d\n", mode);
    return mode;
}
示例#20
0
// autonomous command to set the intake and arm to specific states
void SetScorer(ARM_STATES armStateAuto, INTAKE_STATES intakeStateAuto) {
    //if(!IsAutoActive()) return;
    SetIntake(intakeStateAuto);
    SetArmState(armStateAuto);
    PrintToScreen("armState: %d", ArmState); 
}