コード例 #1
0
void RunCommandPlugin::configChanged() {
    sendConfig();
}
コード例 #2
0
// service a client request; test the opcode and then do appropriate servicing
void CPicoServSession::DispatchMessageL(const RMessage &aMessage)
{
	switch (aMessage.Function()) {
		case PicoMsgLoadState: 
			if(!rom_data) User::Leave(-1); // no ROM
			User::LeaveIfError(saveLoadGame(1));
			gamestate = PGS_Running;
			return;

		case PicoMsgSaveState:
			if(!rom_data) User::Leave(-1);
			User::LeaveIfError(saveLoadGame(0));
			gamestate = PGS_Running;
			return;

		case PicoMsgLoadROM:
			loadROM();
			return;
		
		case PicoMsgResume:
			if(rom_data) gamestate = PGS_Running;
			return;

		case PicoMsgReset: 
			if(rom_data) {
				PicoReset(0);
				pico_was_reset = 1;
				gamestate = PGS_Running;
			}
			return;

		case PicoMsgKeys:
			gamestate = PGS_KeyConfig;
			return;

		case PicoMsgPause:
			gamestate = PGS_Paused;
			return;

		case PicoMsgQuit:
			DEBUGPRINT(_L("got quit msg."));
			gamestate = PGS_Quit;
			return;

		// config change
		case PicoMsgConfigChange: // launcher -> emu
			changeConfig();
			return;

		case PicoMsgRetrieveConfig: // emu -> launcher
			sendConfig();
			return;

		case PicoMsgRetrieveDebugStr: // emu -> launcher
			sendDebug();
			return;

		// requests we don't understand at all are a different thing,
		// so panic the client here, this function also completes the message
		default:
			PanicClient(EBadRequest);
			return;
	}
}
コード例 #3
0
void Telemetry::main(const State& state, Config& config)
{
	// Re-initialize variables
	cmd_ = 0;
	checksum_ = 0;

	// Check whether we have a request available
	if ((n_bytes_available_ = Serial_Telemetry.available()) > 0)
	{
		// Read all data to tmp buffer. It is possible that not all the data has arrived yet
		Serial_Telemetry.readBytes(&(rx_data_buffer_[ptr_]), n_bytes_available_);
		ptr_ += n_bytes_available_;
	}
	else	// No more data to receive 
	{
		if(ptr_ > 0)	// We have data to process
		{
			// Check for the magic word
			if (rx_data_buffer_[0] == magic_word_[0] && rx_data_buffer_[1] == magic_word_[1])
			{
				cmd_ = rx_data_buffer_[2];
			}

			if (cmd_ == TELEMETRY_CMD_IN_CONFIG)
			{
				Telemetry::receiveConfig(config);
			}
			else
			{
				// Send Magic Word
				write8((uint8_t)magic_word_[0]);
				write8((uint8_t)magic_word_[1]);

				// Send cmd
				write8(cmd_);

				// Perform desired operation
				switch (cmd_)
				{
					case TELEMETRY_CMD_OUT_STATUS:
						sendStatus(state);
						break;
					case TELEMETRY_CMD_OUT_IMU:
						sendIMU(state);
						break;
					case TELEMETRY_CMD_OUT_MAG:
						sendMagnetometer(state);
						break;
					case TELEMETRY_CMD_OUT_BARO:
						sendBarometer(state);
						break;
					case TELEMETRY_CMD_OUT_TEMP:
						sendTemperature(state);
						break;
					case TELEMETRY_CMD_OUT_RC:
						sendRC(state);
						break;
					case TELEMETRY_CMD_OUT_GPS:
						sendGPS(state);
						break;
					case TELEMETRY_CMD_OUT_SONAR:
						sendSonar(state);
						break;
					case TELEMETRY_CMD_OUT_ATTITUDE:
						sendAttitude(state);
						break;
					case TELEMETRY_CMD_OUT_CONTROL:
						sendControl(state);
						break;
					case TELEMETRY_CMD_OUT_CONFIG:
						sendConfig(config);
						break;
				} // switch cmd
				sendCheckSum();
			} // config_in
			ptr_ = 0; // Prepare for next package
		} // ptr_ > 0
	} // n_bytes > 0
}