This commit is contained in:
cormoran 2026-01-29 16:30:44 -08:00 committed by GitHub
commit c030c85f42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 2 deletions

View File

@ -188,7 +188,11 @@ static int send_response(const zmk_studio_Response *resp) {
pb_ostream_t stream = pb_ostream_for_tx_buf(user_data); pb_ostream_t stream = pb_ostream_for_tx_buf(user_data);
uint8_t framing_byte = FRAMING_SOF; uint8_t framing_byte = FRAMING_SOF;
ring_buf_put(&rpc_tx_buf, &framing_byte, 1); if (ring_buf_put(&rpc_tx_buf, &framing_byte, 1) != 1) {
LOG_ERR("RPC TX buffer full");
k_mutex_unlock(&rpc_transport_mutex);
return -ENOMEM;
}
selected_transport->tx_notify(&rpc_tx_buf, 1, false, user_data); selected_transport->tx_notify(&rpc_tx_buf, 1, false, user_data);
@ -199,11 +203,15 @@ static int send_response(const zmk_studio_Response *resp) {
#if !IS_ENABLED(CONFIG_NANOPB_NO_ERRMSG) #if !IS_ENABLED(CONFIG_NANOPB_NO_ERRMSG)
LOG_ERR("Failed to encode the message %s", stream.errmsg); LOG_ERR("Failed to encode the message %s", stream.errmsg);
#endif // !IS_ENABLED(CONFIG_NANOPB_NO_ERRMSG) #endif // !IS_ENABLED(CONFIG_NANOPB_NO_ERRMSG)
k_mutex_unlock(&rpc_transport_mutex);
return -EINVAL; return -EINVAL;
} }
framing_byte = FRAMING_EOF; framing_byte = FRAMING_EOF;
ring_buf_put(&rpc_tx_buf, &framing_byte, 1); // If response is large, tx buffer can be full for async transport.
while (ring_buf_put(&rpc_tx_buf, &framing_byte, 1) == 0) {
k_sleep(K_MSEC(1));
}
selected_transport->tx_notify(&rpc_tx_buf, 1, true, user_data); selected_transport->tx_notify(&rpc_tx_buf, 1, true, user_data);