-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zero: libcsp: Remove exit code from Linux driver
This commit adds the patch for resolve issue below. The Linux USART driver for libcsp calls `exit()` API the rx_thread if a read operation fails. This behavior terminates the entire process, even if communication via interfaces other than USART is still possible. Therefore, the exit() code will be removed. Signed-off-by: Takuya Sasaki <takuya.sasaki@spacecubics.com>
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...a-libcsp/recipes-libcsp/files/0001-drivers-usart-Remove-exit-code-from-Linux-driver.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From 90316c0f7fe41d1eac1d38d24b8d381c94d63466 Mon Sep 17 00:00:00 2001 | ||
From: Takuya Sasaki <takuya.sasaki@spacecubics.com> | ||
Date: Wed, 20 Nov 2024 11:15:38 +0900 | ||
Subject: [PATCH] drivers: usart: Remove exit() code from Linux driver | ||
|
||
The Linux USART driver for libcsp calls `exit()` API the rx_thread if | ||
a read operation fails. This behavior terminates the entire process, | ||
even if communication via interfaces other than USART is still possible. | ||
Therefore, the exit() code will be removed. | ||
|
||
Signed-off-by: Takuya Sasaki <takuya.sasaki@spacecubics.com> | ||
--- | ||
src/drivers/usart/usart_linux.c | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/src/drivers/usart/usart_linux.c b/src/drivers/usart/usart_linux.c | ||
index 48aa3d2..46d6539 100644 | ||
--- a/src/drivers/usart/usart_linux.c | ||
+++ b/src/drivers/usart/usart_linux.c | ||
@@ -38,7 +38,7 @@ static void * usart_rx_thread(void * arg) { | ||
uint8_t * cbuf = malloc(CBUF_SIZE); | ||
if (cbuf == NULL) { | ||
csp_print("%s: malloc() failed, returned NULL\n", __func__); | ||
- exit(1); | ||
+ return NULL; | ||
} | ||
|
||
// Receive loop | ||
@@ -46,7 +46,7 @@ static void * usart_rx_thread(void * arg) { | ||
int length = read(ctx->fd, cbuf, CBUF_SIZE); | ||
if (length <= 0) { | ||
csp_print("%s: read() failed, returned: %d\n", __func__, length); | ||
- exit(1); | ||
+ return NULL; | ||
} | ||
ctx->rx_callback(ctx->user_data, cbuf, length, NULL); | ||
} | ||
-- | ||
2.34.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters