From 7467c05b1514ea6693a295ff55e2b37a3671b3e5 Mon Sep 17 00:00:00 2001 From: Takuya Sasaki Date: Wed, 20 Nov 2024 16:41:14 +0900 Subject: [PATCH] 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 --- ...t-Remove-exit-code-from-Linux-driver.patch | 40 +++++++++++++++++++ zero/meta-libcsp/recipes-libcsp/libcsp_0.bb | 1 + 2 files changed, 41 insertions(+) create mode 100644 zero/meta-libcsp/recipes-libcsp/files/0001-drivers-usart-Remove-exit-code-from-Linux-driver.patch diff --git a/zero/meta-libcsp/recipes-libcsp/files/0001-drivers-usart-Remove-exit-code-from-Linux-driver.patch b/zero/meta-libcsp/recipes-libcsp/files/0001-drivers-usart-Remove-exit-code-from-Linux-driver.patch new file mode 100644 index 0000000..9fbc078 --- /dev/null +++ b/zero/meta-libcsp/recipes-libcsp/files/0001-drivers-usart-Remove-exit-code-from-Linux-driver.patch @@ -0,0 +1,40 @@ +From 90316c0f7fe41d1eac1d38d24b8d381c94d63466 Mon Sep 17 00:00:00 2001 +From: Takuya Sasaki +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 +--- + 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 + diff --git a/zero/meta-libcsp/recipes-libcsp/libcsp_0.bb b/zero/meta-libcsp/recipes-libcsp/libcsp_0.bb index 451edb8..6f6ce82 100644 --- a/zero/meta-libcsp/recipes-libcsp/libcsp_0.bb +++ b/zero/meta-libcsp/recipes-libcsp/libcsp_0.bb @@ -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"