1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-09 21:51:45 +00:00

uart.mitm: Log when the data for SendLogData is too large.

This commit is contained in:
yellows8 2021-02-18 14:36:21 -05:00
parent 296fb31358
commit 4cb8034ac8
No known key found for this signature in database
GPG key ID: 0AF90DA3F1E60E43
3 changed files with 10 additions and 5 deletions

View file

@ -208,13 +208,13 @@ namespace ams::mitm::uart {
/* Send the specified data to the Logger thread. */
/* dir: false = Send (host->controller), true = Receive (controller->host). */
void UartLogger::SendLogData(FsFile *f, size_t *file_pos, s64 timestamp_base, s64 tick_base, bool dir, const void* buffer, size_t size) {
bool UartLogger::SendLogData(FsFile *f, size_t *file_pos, s64 timestamp_base, s64 tick_base, bool dir, const void* buffer, size_t size) {
/* Ignore log data which is too large. */
if (size > this->QueueBufferSize) return;
if (size > this->QueueBufferSize) return false;
UartLogMessage *msg=nullptr;
this->m_client_queue.Receive(reinterpret_cast<uintptr_t *>(&msg));
if (msg->data == nullptr) return;
if (msg->data == nullptr) return true;
/* Setup the msg and send it. */
msg->type = 1;
@ -233,6 +233,7 @@ namespace ams::mitm::uart {
this->m_finish_event.Clear();
this->m_thread_queue.Send(reinterpret_cast<uintptr_t>(msg));
this->m_request_event.Signal();
return true;
}
/* Send the specified text log to the Logger thread. */

View file

@ -67,7 +67,7 @@ namespace ams::mitm::uart {
void InitializeDataLog(FsFile *f, size_t *datalog_pos);
void SendLogData(FsFile *f, size_t *file_pos, s64 timestamp_base, s64 tick_base, bool dir, const void* buffer, size_t size);
bool SendLogData(FsFile *f, size_t *file_pos, s64 timestamp_base, s64 tick_base, bool dir, const void* buffer, size_t size);
void SendTextLogData(const char *path, size_t *file_pos, const char *str);
};

View file

@ -211,7 +211,11 @@ namespace ams::mitm::uart {
/* Only write to the file if data-logging is enabled and initialized. */
if (this->m_data_logging_enabled && this->m_datalog_ready) {
std::shared_ptr<UartLogger> logger = mitm::uart::g_logger;
logger->SendLogData(&this->m_datalog_file, &this->m_datalog_pos, this->m_timestamp_base, this->m_tick_base, dir, cache_buffer, pkt_len);
if (!logger->SendLogData(&this->m_datalog_file, &this->m_datalog_pos, this->m_timestamp_base, this->m_tick_base, dir, cache_buffer, pkt_len)) {
char str[256];
std::snprintf(str, sizeof(str), "WriteUartData(): SendLogData dropped packet with size = 0x%lx\n", pkt_len);
this->WriteCmdLog(str);
}
}
(*cache_pos)-= pkt_len;
if (*cache_pos) {