コード例 #1
0
ファイル: XBus.c プロジェクト: simonwood/MSP430G
void ParsePacket()
{
  if (crc8(XBusBuffer, nXBusIndex-1) == XBusBuffer[nXBusIndex-1])
  {
	  if (XBusBuffer[0] == 0xA4)
	  {
		  ExtractChannels();
	  }
          if (XBusBuffer[0] == 0xD1)
          {
            ExtractDMX();
          }
	  if (XBusBuffer[0] == 0x20)
	  {
		  PerformCommand(XBusBuffer);
	  }
	  if (XBusBuffer[0] == 0x21)
	  {
		  PerformStatus(XBusBuffer);
	  }
  }
  memset(XBusBuffer, 0, sizeof(XBusBuffer));
  nXBusIndex = 0;
  nNewPacket = 0;
}
コード例 #2
0
ファイル: uart.c プロジェクト: jssmile/TestEPW2
void receive_task(void *p)
{
    int i , j;
	struct  receive_cmd_list * receive_cmd_type;
    
	while (1) {
		if(Receive_String_Ready ){
			//GPIO_ToggleBits(GPIOD,GPIO_Pin_14);

            /*load the accept command string to the command list structure*/
            receive_cmd_type = received_string;

            /*identifier the command's format, if yes, analyze the command list and perform it. */
            if(receive_cmd_type->Identifier[0] =='c' && receive_cmd_type->Identifier[1] =='m' && receive_cmd_type->Identifier[2] =='d'){
                PerformCommand(receive_cmd_type->group,receive_cmd_type->control_id, receive_cmd_type->value);
                
            }

            
			/*clear the received string and the flag*/
			Receive_String_Ready = 0;
			for( i = 0 ; i< MAX_STRLEN ; i++){
				received_string[i]= 0;
			}
		} 

	}
}
コード例 #3
0
short 
XPFPrefs::PoseSaveDialog ()
{
	// We only use the install dialog if we can't start up from the target disk already
	bool useInstallDialog = (fInstallCD != NULL) && !fRebootInMacOS9 && (fTargetDisk->getBootStatus () != kStatusOK);
	
	short retVal = PoseConfirmDialog (useInstallDialog, true);
		
	if (retVal == kStdOkItemIndex) {
		if (useInstallDialog) {
			PerformCommand (TH_new XPFInstallCommand (this));
		} else {
			PerformCommand (TH_new XPFRestartCommand (this, false));
		}		
	}
	
	return retVal;
}
コード例 #4
0
void FloppyController::WritePortByte(Byte offset, Byte data)
{
	assert(offset == 2 || offset == 5);

	//Offset 2: Digital output register
	if(offset == 2)
	{

	}

	//Offset 5: Data register
	else
	{
		//If this is the first command byte
		if(commandBytes.empty())
		{
			//Ensure the command is recognised
			//Read command
			if((data & 0x1f) == 0x06)
			{
				commandBytes.push_back(data);
				numCommandBytes = 9;
			}

			//Write command
			else if((data & 0x3f) == 0x05)
			{
				commandBytes.push_back(data);
				numCommandBytes = 9;
			}
#ifdef DEBUG_OUTPUT
			else
			{
				dbgOut << "Unrecognised command 0x" << static_cast<Dword>(data);
				dbgOut << " written to floppy controller" << std::endl;
			}
#endif
		}
		else
		{
			//Otherwise, add the data to the command bytes
			commandBytes.push_back(data);

			//If this command is now complete, perform it
			if(commandBytes.size() == numCommandBytes)
			{
				PerformCommand();
			}
		}
	}
}
コード例 #5
0
void
XPFPrefs::checkForUpdates (bool forInstall)
{
	XPFUpdate update (fTargetDisk, fTargetDisk->getHelperDisk (), forInstall ? fInstallCD : NULL);
		
	if (update.getRequiresAction ()) {
		if (!forInstall && fTargetDisk->getIsWriteable ()) {
			MAParamText ("$VOLUME$", fTargetDisk->getVolumeName ());
			
			XPFUpdateWindow *dialog = (XPFUpdateWindow *) TViewServer::fgViewServer->NewTemplateWindow (kUpdateWindow, NULL);
			dialog->setUpdateItemList (update.getItemList ());
			
			IDType result = dialog->PoseModally ();
			dialog->Close ();
			
			if (result == 'upda') PerformCommand (TH_new XPFUpdateCommand (&update));
		}	
	}
}
コード例 #6
0
void
XPFPrefs::Close ()
{
#ifndef __MACH__
	// Sync with changes to balloon help
	setShowHelpTags (HMGetBalloons ());
#endif

	// Do the superclass Close, so that we save if we need to save etc.
	Inherited::Close ();
	
	bool synchronizationFailed = false;
	
	try {	
		// Now, we check NVRAM and do whatever copying is necessary
		XPFNVRAMSettings *nvram = XPFNVRAMSettings::GetSettings ();
		nvram->readFromNVRAM ();
		
		char *bootArgs = nvram->getStringValue ("boot-args");
		char *bootDevice = nvram->getStringValue ("boot-device");
		
		if (!strstr (bootDevice, "/AAPL,ROM")) {
			MountedVolume *bootDisk = MountedVolume::WithOpenFirmwarePath (bootDevice);
			MountedVolume *rootDisk = bootDisk;
			
			char *rdString = strstr (bootArgs, "rd=*");
			if (rdString) {
				char rootPath[256];
				strcpy (rootPath, rdString + strlen ("rd=*"));
				char *pos = strchr (rootPath, ' ');
				if (pos) *pos = 0;
				
				rootDisk = MountedVolume::WithOpenFirmwarePath (rootPath);
				if (!rootDisk) rootDisk = bootDisk;
			}	
						
			if (rootDisk && (rootDisk != bootDisk)) {
				XPFUpdate update (rootDisk, bootDisk);
				if (update.getRequiresSynchronization ()) {
					PerformCommand (TH_new XPFSynchronizeCommand (&update));
				}
				
				// If the root disk was not writeable, then force an update if necessary
				// The XPFUpdate class checks and updates /Library/Extensions in the helper
				// directory in this case.
				if (!rootDisk->getIsWriteable () && update.getRequiresAction ()) {
					PerformCommand (TH_new XPFUpdateCommand (&update));
				}
			}
		}
	}
	
	catch (CException_AC &ex) {
		synchronizationFailed = true;
		ErrorAlert (ex.GetError (), ex.GetExceptionMessage ());
	}
		
#ifdef __MACH__
	restartStartupItem ();
#endif

	if (synchronizationFailed) {
		// If synchronization fails, then we put up a warning message and set up
		// reboot in Mac OS 9.
		
		// FIXME -- this will not work on some newer "New World" machines which cannot
		// boot in Mac OS 9. I'm not sure how to identify them, though. And they are not
		// the machines that people are likely to be using with XPostFacto :-)
		fRebootInMacOS9 = true;
		ErrorAlert (kSynchronizationFailed, 0);
		try {
			writePrefsToNVRAM (false);
		}
		catch (CException_AC &ex) {
			ErrorAlert (ex.GetError (), ex.GetExceptionMessage ());
		}
		fRebootInMacOS9 = false; // so we don't save the pref that way
	} else {
		if (fRestartOnClose) tellFinderToRestart ();
	}
	
	if (!gApplication->GetDone ()) gApplication->DoMenuCommand (cQuit);
}