Skip to content

Commit

Permalink
zero: libcsp: Remove exit code from Linux driver
Browse files Browse the repository at this point in the history
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
sasataku committed Nov 20, 2024
1 parent 5eef6f4 commit 7467c05
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
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

1 change: 1 addition & 0 deletions zero/meta-libcsp/recipes-libcsp/libcsp_0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=2915dc85ab8fd26629e560d023ef175c"
SRCREV = "${AUTOREV}"
SRCBRANCH = "develop"
SRC_URI = "git://github.com/libcsp/libcsp.git;protocol=https;branch=${SRCBRANCH};"
SRC_URI += "file://0001-drivers-usart-Remove-exit-code-from-Linux-driver.patch"

DEPENDS += "libsocketcan"

Expand Down

0 comments on commit 7467c05

Please sign in to comment.