fix: improve field diagnostics and mirror logs to USB CDC
This commit is contained in:
@@ -26,7 +26,8 @@
|
||||
#include "rws_string.h"
|
||||
#include <netdb.h>
|
||||
#include "sockets.h"
|
||||
#include "ql_rtos.h"
|
||||
#include "ql_rtos.h"
|
||||
#include "net_diag.h"
|
||||
#include <time.h>
|
||||
#include "rws_handshake.h"
|
||||
#ifdef LIBRWS_USING_MBED_TLS
|
||||
@@ -212,13 +213,14 @@ static int rws_tls_send_all(_rws_socket *s, const unsigned char *data, size_t si
|
||||
// need close socket on error
|
||||
rws_bool rws_socket_send(_rws_socket *s, const void *data, const size_t data_size)
|
||||
{
|
||||
int sended = -1;
|
||||
int sended = -1;
|
||||
unsigned int diag_write_start = ql_rtos_get_systicks();
|
||||
// rws_error_delete_clean(&s->error);
|
||||
|
||||
#ifdef LIBRWS_USING_MBED_TLS
|
||||
if (s->scheme && strcmp(s->scheme, "wss") == 0)
|
||||
{
|
||||
LOG_D("[T:%.8d, L:%.5d, %*.*s] try send data with tls", ql_rtos_get_systicks(), __LINE__, DBG_FUNCTION_NUM, DBG_FUNCTION_NUM, __FUNCTION__);
|
||||
/* Individual frame tracing overwhelms field logs; report slow writes below. */
|
||||
sended = rws_tls_send_all(s, (const unsigned char *)data, data_size);
|
||||
}
|
||||
else
|
||||
@@ -243,7 +245,13 @@ rws_bool rws_socket_send(_rws_socket *s, const void *data, const size_t data_siz
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sended == (int)data_size)
|
||||
if (net_diag_is_enabled()) {
|
||||
unsigned long elapsed = (unsigned int)(ql_rtos_get_systicks() - diag_write_start) * 5UL;
|
||||
if (elapsed >= 200UL || sended != (int)data_size)
|
||||
printf("[现场诊断][%lu ms][底层发送] 请求=%lu 字节 已写=%d 耗时=%lu ms;未代表服务端已收到\r\n",
|
||||
(unsigned long)ql_rtos_get_systicks() * 5UL, (unsigned long)data_size, sended, elapsed);
|
||||
}
|
||||
if (sended == (int)data_size)
|
||||
{
|
||||
rws_socket_error_cnt = 0;
|
||||
rws_socket_error_staus = 0;
|
||||
|
||||
Reference in New Issue
Block a user