1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 12:42:30 +04:00

Merge remote-tracking branch 'OFW/dev' into dev [ci skip]

This commit is contained in:
MX
2025-02-22 22:55:36 +03:00
7 changed files with 53 additions and 21 deletions

View File

@@ -23,6 +23,7 @@ struct PipeSide {
PipeSideDataArrivedCallback on_data_arrived;
PipeSideSpaceFreedCallback on_space_freed;
PipeSideBrokenCallback on_pipe_broken;
FuriWait stdout_timeout;
};
PipeSideBundle pipe_alloc(size_t capacity, size_t trigger_level) {
@@ -52,12 +53,14 @@ PipeSideBundle pipe_alloc_ex(PipeSideReceiveSettings alice, PipeSideReceiveSetti
.shared = shared,
.sending = alice_to_bob,
.receiving = bob_to_alice,
.stdout_timeout = FuriWaitForever,
};
*bobs_side = (PipeSide){
.role = PipeRoleBob,
.shared = shared,
.sending = bob_to_alice,
.receiving = alice_to_bob,
.stdout_timeout = FuriWaitForever,
};
return (PipeSideBundle){.alices_side = alices_side, .bobs_side = bobs_side};
@@ -100,7 +103,8 @@ static void _pipe_stdout_cb(const char* data, size_t size, void* context) {
furi_assert(context);
PipeSide* pipe = context;
while(size) {
size_t sent = pipe_send(pipe, data, size, FuriWaitForever);
size_t sent = pipe_send(pipe, data, size, pipe->stdout_timeout);
if(!sent) break;
data += sent;
size -= sent;
}
@@ -118,6 +122,11 @@ void pipe_install_as_stdio(PipeSide* pipe) {
furi_thread_set_stdin_callback(_pipe_stdin_cb, pipe);
}
void pipe_set_stdout_timeout(PipeSide* pipe, FuriWait timeout) {
furi_check(pipe);
pipe->stdout_timeout = timeout;
}
size_t pipe_receive(PipeSide* pipe, void* data, size_t length, FuriWait timeout) {
furi_check(pipe);
return furi_stream_buffer_receive(pipe->receiving, data, length, timeout);

View File

@@ -147,6 +147,16 @@ void pipe_free(PipeSide* pipe);
*/
void pipe_install_as_stdio(PipeSide* pipe);
/**
* @brief Sets the timeout for `stdout` write operations
*
* @note This value is set to `FuriWaitForever` when the pipe is created
*
* @param [in] pipe Pipe side to set the timeout of
* @param [in] timeout Timeout value in ticks
*/
void pipe_set_stdout_timeout(PipeSide* pipe, FuriWait timeout);
/**
* @brief Receives data from the pipe.
*