Ejemplo n.º 1
0
void SimulatedCar::run(){
	if (!_manuel) {
		//_speed = random(0,200);
		_speed += SIMULATION_SPEED_STEP;
		if (_speed > MAX_SPEED)
			_speed = MIN_SPEED;

		//_rpm = random(0,16384);
		// @TODO @WARNING FIX THIS
		_rpm = random(50,310);

		//_fuelLevel = random(0,100);
		_fuelLevel -= SIMULATION_FUELLEVEL_STEP;
		if (_fuelLevel < MIN_TEMP)
			_fuelLevel = MAX_TEMP;

		//_temp = random(-40,215);
		_temp += SIMULATION_TEMP_STEP;
		if (_temp > MAX_TEMP)
			_temp = MIN_TEMP;		
		
	}
	_sendMessage(PID_SPEED,_speed);
	_sendMessage(PID_RPM,_rpm);
	_sendMessage(PID_FUEL_LEVEL,_fuelLevel);
	_sendMessage(PID_COOLANT_TEMP,_temp);
	Thread::run();
}
Ejemplo n.º 2
0
static void _setBreakpoint(struct GDBStub* stub, const char* message) {
	const char* readAddress = &message[2];
	unsigned i = 0;
	uint32_t address = _readHex(readAddress, &i);
	readAddress += i + 1;
	uint32_t kind = _readHex(readAddress, &i);

	switch (message[0]) {
	case '0':
		ARMDebuggerSetSoftwareBreakpoint(stub->d.platform, address, kind == 2 ? MODE_THUMB : MODE_ARM);
		break;
	case '1':
		stub->d.platform->setBreakpoint(stub->d.platform, address);
		break;
	case '2':
		stub->d.platform->setWatchpoint(stub->d.platform, address, WATCHPOINT_WRITE);
		break;
	case '3':
		stub->d.platform->setWatchpoint(stub->d.platform, address, WATCHPOINT_READ);
		break;
	case '4':
		stub->d.platform->setWatchpoint(stub->d.platform, address, WATCHPOINT_RW);
		break;
	default:
		stub->outgoing[0] = '\0';
		_sendMessage(stub);
		return;
	}
	strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
	_sendMessage(stub);
}
Ejemplo n.º 3
0
static void _writeMemoryBinary(struct GDBStub* stub, const char* message) {
	const char* readAddress = message;
	unsigned i = 0;
	uint32_t address = _readHex(readAddress, &i);
	readAddress += i + 1;

	i = 0;
	uint32_t size = _readHex(readAddress, &i);
	readAddress += i + 1;

	if (size > 512) {
		_error(stub, GDB_BAD_ARGUMENTS);
		return;
	}

	struct ARMCore* cpu = stub->d.core->cpu;
	for (i = 0; i < size; i++) {
		uint8_t byte = *readAddress;
		++readAddress;

		// Parse escape char
		if (byte == 0x7D) {
			byte = *readAddress ^ 0x20;
			++readAddress;
		}

		GBAPatch8(cpu, address + i, byte, 0);
	}

	strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
	_sendMessage(stub);
}
Ejemplo n.º 4
0
void WildThumperCom::sendGripperDistance(int gripperDistance) {
	_txMessageBuffer[TEAM_NUMBER_BYTE] = _teamNumber;
	_txMessageBuffer[COMMAND_BYTE] = COMMAND_SET_GRIPPER_DISTANCE;
	_txMessageBuffer[SET_GRIPPER_DISTANCE_LSB] = (byte) gripperDistance;
	_txMessageBuffer[SET_GRIPPER_DISTANCE_MSB] = (byte)(gripperDistance >> 8);
	_sendMessage (SET_GRIPPER_DISTANCE_LENGTH);
}
Ejemplo n.º 5
0
bool LMEConnection::ServiceAccept(std::string serviceName)
{
	if (!IsInitialized()) {
		PRINT("State: not connected to HECI.\n");
		return false;
	}

	//APF_SERVICE_ACCEPT_MESSAGE
	//memcpy(pCurrent, "127.0.0.1", APF_STR_SIZE_OF("127.0.0.1"));
	//pCurrent += APF_STR_SIZE_OF("127.0.0.1");
	unsigned char *buf = new unsigned char[sizeof(APF_SERVICE_ACCEPT_MESSAGE) + serviceName.length()];
	if (buf == NULL) {
		PRINT("Failed to allocate memory for ServiceAccept.\n");
		return false;
	}

	unsigned char *pCurrent = buf;
	*pCurrent = APF_SERVICE_ACCEPT;
	++pCurrent;
	*((UINT32 *)pCurrent) = htonl(serviceName.size());
	pCurrent += 4;

	memcpy(pCurrent, serviceName.c_str(), serviceName.size());
	pCurrent += serviceName.size();

	PRINT("Sending service accept to LME: %s\n", serviceName.c_str());
	int len = pCurrent - buf;
	int res = _sendMessage(buf, len);

	delete [] buf;

	return (res == len);
}
Ejemplo n.º 6
0
bool LMEConnection::ChannelOpenForwardedRequest(UINT32 senderChannel,
						UINT32 connectedPort,
						std::string originatorIP,
						UINT32 originatorPort)
{
	if (!IsInitialized()) {
		PRINT("State: not connected to HECI.\n");
		return false;
	}

	unsigned char buf[5 + APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED) + 16 +
		APF_STR_SIZE_OF("127.0.0.1") + 8 +  16  + 4];
	unsigned char *pCurrent = buf;

	if (originatorIP.size() > 16) {
		return false;
	}

	*pCurrent = APF_CHANNEL_OPEN;
	++pCurrent;

	*((UINT32 *)pCurrent) = htonl(APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
	pCurrent += sizeof(UINT32);

	memcpy(pCurrent, APF_OPEN_CHANNEL_REQUEST_FORWARDED, APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
	pCurrent += APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED);

	*((UINT32 *)pCurrent) = htonl(senderChannel);
	pCurrent += sizeof(UINT32);

	*((UINT32 *)pCurrent) = htonl(RX_WINDOW_SIZE);
	pCurrent += sizeof(UINT32);

	*((UINT32 *)pCurrent) = 0xFFFFFFFF;
	pCurrent += sizeof(UINT32);

	*((UINT32 *)pCurrent) = htonl(APF_STR_SIZE_OF("127.0.0.1"));
	pCurrent += sizeof(UINT32);

	memcpy(pCurrent, "127.0.0.1", APF_STR_SIZE_OF("127.0.0.1"));
	pCurrent += APF_STR_SIZE_OF("127.0.0.1");

	*((UINT32 *)pCurrent) = htonl(connectedPort);
	pCurrent += sizeof(UINT32);

	*((UINT32 *)pCurrent) = htonl((UINT32)originatorIP.size());
	pCurrent += sizeof(UINT32);

	memcpy(pCurrent, originatorIP.c_str(), originatorIP.size());
	pCurrent += originatorIP.size();

	*((UINT32 *)pCurrent) = htonl(originatorPort);
	pCurrent += sizeof(UINT32);

	PRINT("Sending channel open request to LME. Address: %s, requested port: %d.\n",
		originatorIP.c_str(), connectedPort);
	int res = _sendMessage(buf, (int)(pCurrent - buf));

	return (res == pCurrent - buf);
}
Ejemplo n.º 7
0
static void _step(struct GDBStub* stub, const char* message) {
	stub->d.core->step(stub->d.core);
	snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "S%02x", SIGTRAP);
	_sendMessage(stub);
	// TODO: parse message
	UNUSED(message);
}
Ejemplo n.º 8
0
    void send(double * u, uint64_t timeStamp) {
        // attitude states (rad)
        float roll = u[0];
        float pitch = u[1];
        float yaw = u[2];

        // body rates
        float rollRate = u[3];
        float pitchRate = u[4];
        float yawRate = u[5];

        // position
        int32_t lat = u[6]*_rad2deg*1e7;
        int32_t lon = u[7]*_rad2deg*1e7;
        int16_t alt = u[8]*1e3;

        int16_t vx = u[9]*1e2;
        int16_t vy = u[10]*1e2;
        int16_t vz = u[11]*1e2;

        int16_t xacc = u[12]*1e3/_g0;
        int16_t yacc = u[13]*1e3/_g0;
        int16_t zacc = u[14]*1e3/_g0;

        mavlink_message_t msg;
        mavlink_msg_hil_state_pack(_system.sysid, _system.compid, &msg, 
            timeStamp,
            roll,pitch,yaw,
            rollRate,pitchRate,yawRate,
            lat,lon,alt,
            vx,vy,vz,
            xacc,yacc,zacc);
        _sendMessage(msg);
    }
Ejemplo n.º 9
0
static void _processQWriteCommand(struct GDBStub* stub, const char* message) {
	stub->outgoing[0] = '\0';
	if (!strncmp("StartNoAckMode#", message, 16)) {
		stub->lineAck = GDB_ACK_OFF;
		strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
	}
	_sendMessage(stub);
}
Ejemplo n.º 10
0
void WildThumperCom::sendJointAngle(byte jointNumber, int jointAngle) {
	_txMessageBuffer[TEAM_NUMBER_BYTE] = _teamNumber;
	_txMessageBuffer[COMMAND_BYTE] = COMMAND_SET_JOINT_ANGLE;
	_txMessageBuffer[SET_JOINT_ANGLE_JOINT_NUMBER] = jointNumber;
	_txMessageBuffer[SET_JOINT_ANGLE_ANGLE_LSB] = (byte) jointAngle;
	_txMessageBuffer[SET_JOINT_ANGLE_ANGLE_MSB] = (byte)(jointAngle >> 8);
	_sendMessage (SET_JOINT_ANGLE_LENGTH);
}
Ejemplo n.º 11
0
void WildThumperCom::sendBatteryVoltageReply(int batteryMillivolts) {
	_txMessageBuffer[TEAM_NUMBER_BYTE] = _teamNumber;
	_txMessageBuffer[COMMAND_BYTE] = COMMAND_BATTERY_VOLTAGE_REPLY;
	_txMessageBuffer[BATTERY_VOLTAGE_REPLY_LSB] = (byte) batteryMillivolts;
	_txMessageBuffer[BATTERY_VOLTAGE_REPLY_MSB] = (byte)(
			batteryMillivolts >> 8);
	_sendMessage (BATTERY_VOLTAGE_REPLY_LENGTH);
}
Ejemplo n.º 12
0
static void _processVReadCommand(struct GDBStub* stub, const char* message) {
	stub->outgoing[0] = '\0';
	if (!strncmp("Attach", message, 6)) {
		strncpy(stub->outgoing, "1", GDB_STUB_MAX_LINE - 4);
		mDebuggerEnter(&stub->d, DEBUGGER_ENTER_MANUAL, 0);
	}
	_sendMessage(stub);
}
Ejemplo n.º 13
0
static void _readRegister(struct GDBStub* stub, const char* message) {
	struct ARMCore* cpu = stub->d.core->cpu;
	const char* readAddress = message;
	unsigned i = 0;
	uint32_t reg = _readHex(readAddress, &i);
	uint32_t value;
	if (reg < 0x10) {
		value = cpu->gprs[reg];
	} else if (reg == 0x19) {
		value = cpu->cpsr.packed;
	} else {
		stub->outgoing[0] = '\0';
		_sendMessage(stub);
		return;
	}
	_int2hex32(value, stub->outgoing);
	stub->outgoing[8] = '\0';
	_sendMessage(stub);
}
Ejemplo n.º 14
0
void WildThumperCom::sendWheelSpeed(byte leftMode, byte rightMode,
		byte leftDutyCycle, byte rightDutyCycle) {
	_txMessageBuffer[TEAM_NUMBER_BYTE] = _teamNumber;
	_txMessageBuffer[COMMAND_BYTE] = COMMAND_WHEEL_SPEED;
	_txMessageBuffer[WHEEL_SPEED_LEFT_MODE] = leftMode;
	_txMessageBuffer[WHEEL_SPEED_RIGHT_MODE] = rightMode;
	_txMessageBuffer[WHEEL_SPEED_LEFT_DUTY_CYCLE] = leftDutyCycle;
	_txMessageBuffer[WHEEL_SPEED_RIGHT_DUTY_CYCLE] = rightDutyCycle;
	_sendMessage (WHEEL_SPEED_MESSAGE_LENGTH);
}
Ejemplo n.º 15
0
bool LMEConnection::TcpForwardCancelReplyFailure()
{
	if (!IsInitialized()) {
		PRINT("State: not connected to HECI.\n");
		return false;
	}

	unsigned char buf = APF_REQUEST_FAILURE;

	PRINT("Sending TCP forward cancel replay failure to LME.\n");
	int res = _sendMessage(&buf, sizeof(buf));

	return (res == sizeof(buf));
}
Ejemplo n.º 16
0
bool LMEConnection::UserAuthSuccess()
{
	if (!IsInitialized()) {
		PRINT("State: not connected to HECI.\n");
		return false;
	}

	unsigned char buf = APF_USERAUTH_SUCCESS;

	PRINT("Sending user authentication success to LME.\n");
	int res = _sendMessage(&buf, sizeof(buf));

	return (res == sizeof(buf));
}
Ejemplo n.º 17
0
void WildThumperCom::sendWheelCurrentReply(int leftWheelMotorsMilliamps,
		int rightWheelMotorsMilliamps) {
	_txMessageBuffer[TEAM_NUMBER_BYTE] = _teamNumber;
	_txMessageBuffer[COMMAND_BYTE] = COMMAND_WHEEL_CURRENT_REPLY;
	_txMessageBuffer[WHEEL_CURRENT_REPLY_LEFT_LSB] =
			(byte) leftWheelMotorsMilliamps;
	_txMessageBuffer[WHEEL_CURRENT_REPLY_LEFT_MSB] = (byte)(
			leftWheelMotorsMilliamps >> 8);
	_txMessageBuffer[WHEEL_CURRENT_REPLY_RIGHT_LSB] =
			(byte) rightWheelMotorsMilliamps;
	_txMessageBuffer[WHEEL_CURRENT_REPLY_RIGHT_MSB] = (byte)(
			rightWheelMotorsMilliamps >> 8);
	_sendMessage (WHEEL_CURRENT_REPLY_LENGTH);
}
Ejemplo n.º 18
0
static void _writeRegister(struct GDBStub* stub, const char* message) {
	struct ARMCore* cpu = stub->d.core->cpu;
	const char* readAddress = message;

	unsigned i = 0;
	uint32_t reg = _readHex(readAddress, &i);
	readAddress += i + 1;

	uint32_t value = _readHex(readAddress, &i);

#ifdef _MSC_VER
	value = _byteswap_ulong(value);
#else
	value = __builtin_bswap32(value);
#endif

	if (reg <= ARM_PC) {
		cpu->gprs[reg] = value;
		if (reg == ARM_PC) {
			int32_t currentCycles = 0;
			if (cpu->executionMode == MODE_ARM) {
				ARM_WRITE_PC;
			} else {
				THUMB_WRITE_PC;
			}
		}
	} else if (reg == 0x19) {
		cpu->cpsr.packed = value;
	} else {
		stub->outgoing[0] = '\0';
		_sendMessage(stub);
		return;
	}

	strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
	_sendMessage(stub);
}
Ejemplo n.º 19
0
static void _setBreakpoint(struct GDBStub* stub, const char* message) {
	const char* readAddress = &message[2];
	unsigned i = 0;
	uint32_t address = _readHex(readAddress, &i);
	readAddress += i + 1;
	uint32_t kind = _readHex(readAddress, &i); // We don't use this in hardware watchpoints
	UNUSED(kind);

	switch (message[0]) {
	case '0': // Memory breakpoints are not currently supported
	case '1':
		stub->d.platform->setBreakpoint(stub->d.platform, address);
		strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
		_sendMessage(stub);
		break;
	case '2':
		stub->d.platform->setWatchpoint(stub->d.platform, address, WATCHPOINT_WRITE);
		strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
		_sendMessage(stub);
		break;
	case '3':
		stub->d.platform->setWatchpoint(stub->d.platform, address, WATCHPOINT_READ);
		strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
		_sendMessage(stub);
		break;
	case '4':
		stub->d.platform->setWatchpoint(stub->d.platform, address, WATCHPOINT_RW);
		strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
		_sendMessage(stub);
		break;
	default:
		stub->outgoing[0] = '\0';
		_sendMessage(stub);
		break;
	}
}
Ejemplo n.º 20
0
static void _readGPRs(struct GDBStub* stub, const char* message) {
	struct ARMCore* cpu = stub->d.core->cpu;
	UNUSED(message);
	int r;
	int i = 0;
	for (r = 0; r < ARM_PC; ++r) {
		_int2hex32(cpu->gprs[r], &stub->outgoing[i]);
		i += 8;
	}
	_int2hex32(cpu->gprs[ARM_PC] - (cpu->cpsr.a.t ? WORD_SIZE_THUMB : WORD_SIZE_ARM), &stub->outgoing[i]);
	i += 8;

	stub->outgoing[i] = 0;
	_sendMessage(stub);
}
Ejemplo n.º 21
0
void listenForMessages(int mtype, void (*callback)(message*)) {
    message* msg = malloc(sizeof(message));
    ssize_t errorCheck;

    while ((errorCheck = msgrcv(thisNode.msgid, msg, sizeof(message) - sizeof(long int), mtype, 0)) != (ssize_t)-1) {
        if (msg->mdata.destination != thisNode.id) {
            _sendMessage(msg);
        } else {
            callback(msg);
        }
    }
    if (errorCheck == (ssize_t)-1) {
        printf("An error occured while trying to receive message: %d\n", errno);
    }
    free(msg);
}
Ejemplo n.º 22
0
void WildThumperCom::sendPosition(int joint1Angle, int joint2Angle,
		int joint3Angle, int joint4Angle, int joint5Angle) {
	_txMessageBuffer[TEAM_NUMBER_BYTE] = _teamNumber;
	_txMessageBuffer[COMMAND_BYTE] = COMMAND_SET_ARM_POSITION;
	_txMessageBuffer[SET_ARM_POSITION_JOINT_1_LSB] = (byte) joint1Angle;
	_txMessageBuffer[SET_ARM_POSITION_JOINT_1_MSB] = (byte)(joint1Angle >> 8);
	_txMessageBuffer[SET_ARM_POSITION_JOINT_2_LSB] = (byte) joint2Angle;
	_txMessageBuffer[SET_ARM_POSITION_JOINT_2_MSB] = (byte)(joint2Angle >> 8);
	_txMessageBuffer[SET_ARM_POSITION_JOINT_3_LSB] = (byte) joint3Angle;
	_txMessageBuffer[SET_ARM_POSITION_JOINT_3_MSB] = (byte)(joint3Angle >> 8);
	_txMessageBuffer[SET_ARM_POSITION_JOINT_4_LSB] = (byte) joint4Angle;
	_txMessageBuffer[SET_ARM_POSITION_JOINT_4_MSB] = (byte)(joint4Angle >> 8);
	_txMessageBuffer[SET_ARM_POSITION_JOINT_5_LSB] = (byte) joint5Angle;
	_txMessageBuffer[SET_ARM_POSITION_JOINT_5_MSB] = (byte)(joint5Angle >> 8);
	_sendMessage (SET_ARM_POSITION_LENGTH);
}
Ejemplo n.º 23
0
bool LMEConnection::ChannelClose(UINT32 recipientChannel)
{
	if (!IsInitialized()) {
		PRINT("State: not connected to HECI.\n");
		return false;
	}

	APF_CHANNEL_CLOSE_MESSAGE message;

	message.MessageType = APF_CHANNEL_CLOSE;
	message.RecipientChannel = htonl(recipientChannel);

	PRINT("Sending channel close to LME. Recipient: %d.\n", recipientChannel);
	int res = _sendMessage((unsigned char *)&message, sizeof(message));

	return (res == sizeof(message));
}
Ejemplo n.º 24
0
bool LMEConnection::TcpForwardReplySuccess(UINT32 port)
{
	if (!IsInitialized()) {
		PRINT("State: not connected to HECI.\n");
		return false;
	}

	APF_TCP_FORWARD_REPLY_MESSAGE message;

	message.MessageType = APF_REQUEST_SUCCESS;
	message.PortBound = htonl(port);

	PRINT("Sending TCP forward replay success to LME: Port %d.\n", port);
	int res = _sendMessage((unsigned char *)&message, sizeof(message));

	return (res == sizeof(message));
}
Ejemplo n.º 25
0
static void _gdbStubEntered(struct mDebugger* debugger, enum mDebuggerEntryReason reason, struct mDebuggerEntryInfo* info) {
	struct GDBStub* stub = (struct GDBStub*) debugger;
	switch (reason) {
	case DEBUGGER_ENTER_MANUAL:
		snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "S%02x", SIGINT);
		break;
	case DEBUGGER_ENTER_BREAKPOINT:
		if (stub->supportsHwbreak && stub->supportsSwbreak && info) {
			snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "T%02x%cwbreak:;", SIGTRAP, info->a.c.breakType == BREAKPOINT_SOFTWARE ? 's' : 'h');
		} else {
			snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "S%02xk", SIGTRAP);
		}
		break;
	case DEBUGGER_ENTER_WATCHPOINT:
		if (info) {
			const char* type = 0;
			switch (info->a.b.watchType) {
			case WATCHPOINT_WRITE:
				if (info->a.b.newValue == info->a.b.oldValue) {
					if (stub->d.state == DEBUGGER_PAUSED) {
						stub->d.state = DEBUGGER_RUNNING;
					}
					return;
				}
				type = "watch";
				break;
			case WATCHPOINT_READ:
				type = "rwatch";
				break;
			case WATCHPOINT_RW:
				type = "awatch";
				break;
			}
			snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "T%02x%s:%08x;", SIGTRAP, type, info->address);
		} else {
			snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "S%02x", SIGTRAP);
		}
		break;
	case DEBUGGER_ENTER_ILLEGAL_OP:
		snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "S%02x", SIGILL);
		break;
	case DEBUGGER_ENTER_ATTACHED:
		return;
	}
	_sendMessage(stub);
}
Ejemplo n.º 26
0
bool LMEConnection::ChannelWindowAdjust(UINT32 recipientChannel, UINT32 len)
{
	if (!IsInitialized()) {
		PRINT("State: not connected to HECI.\n");
		return false;
	}

	APF_WINDOW_ADJUST_MESSAGE message;

	message.MessageType = APF_CHANNEL_WINDOW_ADJUST;
	message.RecipientChannel = htonl(recipientChannel);
	message.BytesToAdd = htonl(len);

	PRINT("Sending Window Adjust with %d bytes to recipient channel %d.\n", len, recipientChannel);
	int res = _sendMessage((unsigned char *)&message, sizeof(message));

	return (res == sizeof(message));
}
Ejemplo n.º 27
0
static void _readMemory(struct GDBStub* stub, const char* message) {
	const char* readAddress = message;
	unsigned i = 0;
	uint32_t address = _readHex(readAddress, &i);
	readAddress += i + 1;
	uint32_t size = _readHex(readAddress, &i);
	if (size > 512) {
		_error(stub, GDB_BAD_ARGUMENTS);
		return;
	}
	struct ARMCore* cpu = stub->d.core->cpu;
	int writeAddress = 0;
	for (i = 0; i < size; ++i, writeAddress += 2) {
		uint8_t byte = cpu->memory.load8(cpu, address + i, 0);
		_int2hex8(byte, &stub->outgoing[writeAddress]);
	}
	stub->outgoing[writeAddress] = 0;
	_sendMessage(stub);
}
Ejemplo n.º 28
0
static void _writeGPRs(struct GDBStub* stub, const char* message) {
	struct ARMCore* cpu = stub->d.core->cpu;
	const char* readAddress = message;

	int r;
	for (r = 0; r <= ARM_PC; ++r) {
		cpu->gprs[r] = _hex2int(readAddress, 8);
		readAddress += 8;
	}
	int32_t currentCycles = 0;
	if (cpu->executionMode == MODE_ARM) {
		ARM_WRITE_PC;
	} else {
		THUMB_WRITE_PC;
	}

	strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
	_sendMessage(stub);
}
Ejemplo n.º 29
0
static void _processQReadCommand(struct GDBStub* stub, const char* message) {
	stub->outgoing[0] = '\0';
	if (!strncmp("HostInfo#", message, 9)) {
		_writeHostInfo(stub);
		return;
	}
	if (!strncmp("Attached#", message, 9)) {
		strncpy(stub->outgoing, "1", GDB_STUB_MAX_LINE - 4);
	} else if (!strncmp("VAttachOrWaitSupported#", message, 23)) {
		strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
	} else if (!strncmp("C#", message, 2)) {
		strncpy(stub->outgoing, "QC1", GDB_STUB_MAX_LINE - 4);
	} else if (!strncmp("fThreadInfo#", message, 12)) {
		strncpy(stub->outgoing, "m1", GDB_STUB_MAX_LINE - 4);
	} else if (!strncmp("sThreadInfo#", message, 12)) {
		strncpy(stub->outgoing, "l", GDB_STUB_MAX_LINE - 4);
	}
	_sendMessage(stub);
}
Ejemplo n.º 30
0
bool LMEConnection::ProtocolVersion(const LMEProtocolVersionMessage versionMessage)
{
	if (!IsInitialized()) {
		PRINT("State: not connected to HECI.\n");
		return false;
	}

	APF_PROTOCOL_VERSION_MESSAGE protVersion;
	memset(&protVersion, 0, sizeof(protVersion));

	protVersion.MessageType = APF_PROTOCOLVERSION;
	protVersion.MajorVersion = htonl(versionMessage.MajorVersion);
	protVersion.MinorVersion = htonl(versionMessage.MinorVersion);
	protVersion.TriggerReason = htonl(versionMessage.TriggerReason);

	PRINT("Sending protocol version to LME: %d.%d\n", versionMessage.MajorVersion, versionMessage.MinorVersion);
	int res = _sendMessage((unsigned char *)&protVersion, sizeof(protVersion));

	return (res == sizeof(protVersion));
}