SI_DeviceGBA: use SI_ERROR_NO_RESPONSE when client isn't connected
Slight behavior change, but fills a gaping hole in the state logic.
This commit is contained in:
parent
8dee8e6494
commit
f004dfa92b
|
@ -5,6 +5,7 @@
|
||||||
#include "Core/HW/SI/SI_DeviceGBA.h"
|
#include "Core/HW/SI/SI_DeviceGBA.h"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
@ -303,6 +304,12 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int length)
|
||||||
#endif
|
#endif
|
||||||
m_sock_server.Send(buffer);
|
m_sock_server.Send(buffer);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
constexpr u32 reply = SI_ERROR_NO_RESPONSE;
|
||||||
|
std::memcpy(buffer, &reply, sizeof(reply));
|
||||||
|
return sizeof(reply);
|
||||||
|
}
|
||||||
m_last_cmd = buffer[3];
|
m_last_cmd = buffer[3];
|
||||||
m_timestamp_sent = CoreTiming::GetTicks();
|
m_timestamp_sent = CoreTiming::GetTicks();
|
||||||
m_next_action = NextAction::WaitTransferTime;
|
m_next_action = NextAction::WaitTransferTime;
|
||||||
|
@ -322,22 +329,21 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int length)
|
||||||
case NextAction::ReceiveResponse:
|
case NextAction::ReceiveResponse:
|
||||||
{
|
{
|
||||||
int num_data_received = m_sock_server.Receive(buffer);
|
int num_data_received = m_sock_server.Receive(buffer);
|
||||||
if (m_sock_server.IsConnected())
|
if (!m_sock_server.IsConnected())
|
||||||
{
|
{
|
||||||
|
m_next_action = NextAction::SendCommand;
|
||||||
|
constexpr u32 reply = SI_ERROR_NO_RESPONSE;
|
||||||
|
std::memcpy(buffer, &reply, sizeof(reply));
|
||||||
|
return sizeof(reply);
|
||||||
|
}
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
LogTypes::LOG_LEVELS log_level = (m_last_cmd == CMD_STATUS || m_last_cmd == CMD_RESET) ?
|
LogTypes::LOG_LEVELS log_level = (m_last_cmd == CMD_STATUS || m_last_cmd == CMD_RESET) ?
|
||||||
LogTypes::LERROR :
|
LogTypes::LERROR :
|
||||||
LogTypes::LWARNING;
|
LogTypes::LWARNING;
|
||||||
GENERIC_LOG(LogTypes::SERIALINTERFACE, log_level,
|
GENERIC_LOG(LogTypes::SERIALINTERFACE, log_level,
|
||||||
"%01d [< %02x%02x%02x%02x%02x] (%i)",
|
"%01d [< %02x%02x%02x%02x%02x] (%i)", m_device_number,
|
||||||
m_device_number, buffer[3], buffer[2], buffer[1], buffer[0], buffer[7],
|
buffer[3], buffer[2], buffer[1], buffer[0], buffer[7], num_data_received);
|
||||||
num_data_received);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
num_data_received = RECV_MAX_SIZE;
|
|
||||||
}
|
|
||||||
if (num_data_received > 0)
|
if (num_data_received > 0)
|
||||||
m_next_action = NextAction::SendCommand;
|
m_next_action = NextAction::SendCommand;
|
||||||
return num_data_received;
|
return num_data_received;
|
||||||
|
|
Loading…
Reference in New Issue