From patchwork Sun Aug 7 18:21:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: F6BVP X-Patchwork-Id: 12938197 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB3EC19F2A for ; Sun, 7 Aug 2022 18:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234046AbiHGSVn (ORCPT ); Sun, 7 Aug 2022 14:21:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbiHGSVm (ORCPT ); Sun, 7 Aug 2022 14:21:42 -0400 Received: from shiva-su1.sorbonne-universite.fr (shiva-su1.sorbonne-universite.fr [134.157.0.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F037C103B; Sun, 7 Aug 2022 11:21:35 -0700 (PDT) Received: from nirriti.ent.upmc.fr (nirriti.dsi.upmc.fr [134.157.0.215]) by shiva-su1.sorbonne-universite.fr (Postfix) with ESMTP id 6D2DF412502A; Sun, 7 Aug 2022 20:21:35 +0200 (CEST) Received: from [44.168.19.21] (lfbn-idf1-1-596-24.w86-242.abo.wanadoo.fr [86.242.59.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pidoux) by nirriti.ent.upmc.fr (Postfix) with ESMTPSA id 65C0713C5EEB9; Sun, 7 Aug 2022 20:21:35 +0200 (CEST) Message-ID: Date: Sun, 7 Aug 2022 20:21:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 From: f6bvp Subject: Resend : [PATCH] AX25 rose_call - replacing carriage return by newlines To: linux-hams@vger.kernel.org Cc: Thomas Osterried DL9SAU , netdev@vger.kernel.org, Francois Romieu References: Content-Language: en-US In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org [PATCH] AX25 rose_call - replacing carriage return by newlines Previous patch was reversed... resending correct one. I have been using intensively rose_call application (part of ax25tools/user_call library) while debugging rose connect issue. However once connected rose_call displays remote message without linefeed. Consequently it is impossible to read messages. For example calling local node : # rose_call rose0 f6bvp f6bvp-4 2080175524 Connecting to f6bvp-4 @ 2080175524 ... *** Connected F6BVP-4 (Commands = ?) : Aug 5 2022) for LINUX (help = h) Then issuing command P to the connected local node, all answer lines are superimposed. F6BVP-4 (Commands = ?) : Switch Port Now with the proposed patch is the complete info displayed: # ./rose_call rose0 f6bvp f6bvp-4 2080175524 Connecting to f6bvp-4 @ 2080175524 ... *** Connected User call : F6BVP-0 Welcome to the last release of Fpac! This file is fpac.hello and is displayed when a user connects to the node. FPAC-Node v 4.1.3 (built Aug 5 2022) for LINUX (help = h) F6BVP-4 (Commands = ?) : In file rose_call.c carriage returns are also replaced by newlines in order to let error messages to be correctly displayed. Cc: Thomas DL9SAU Osterried Cc: Francois Romieu Signed-off-by: Bernard Pidoux diff --git a/linuxax25-master-f6bvp/ax25tools/user_call/user_io.c b/linuxax25-master/ax25tools/user_call/user_io.c index 3bd6a26..92c47a6 100644 --- a/linuxax25-master/ax25tools/user_call/user_io.c +++ b/linuxax25-master/ax25tools/user_call/user_io.c @@ -174,6 +174,16 @@ int user_read(int fd, void *buf, size_t count) #endif } +void linefeed_buffer(char *buf, size_t count) +{ + int i; + + for (i=0 ; i < count ; i++) { + if(buf[i] == 0x0D) + buf[i] = 0x0A; + } +} + int select_loop(int s) { fd_set read_fd; @@ -199,8 +209,10 @@ int select_loop(int s) select(s + 1, &read_fd, NULL, NULL, NULL); if (FD_ISSET(s, &read_fd)) { - while ((n = user_read(s, buf, BUFLEN)) > 0) + while ((n = user_read(s, buf, BUFLEN)) > 0) { + linefeed_buffer(buf, BUFLEN); user_write(STDOUT_FILENO, buf, n); + } if (n == 0 || (n < 0 && errno != EAGAIN)) { close(s); break; diff --git a/linuxax25-master/ax25tools/user_call/rose_call.c b/linuxax25-master-f6bvp/ax25tools/user_call/rose_call.c index 7a7dea1..03bba08 100644 --- a/linuxax25-master/ax25tools/user_call/rose_call.c +++ b/linuxax25-master-f6bvp/ax25tools/user_call/rose_call.c @@ -44,13 +44,13 @@ int main(int argc, char **argv) break; case ':': case '?': - err("ERROR: invalid option usage\r"); + err("ERROR: invalid option usage\n"); return 1; } } if (paclen_in < 1 || paclen_out < 1) { - err("ERROR: invalid paclen\r"); + err("ERROR: invalid paclen\n"); return 1; } @@ -58,12 +58,12 @@ int main(int argc, char **argv) * Arguments should be "rose_call port mycall remcall remaddr" */ if ((argc - optind) != 4) { - strcpy(buffer, "ERROR: invalid number of parameters\r"); + strcpy(buffer, "ERROR: invalid number of parameters\n"); err(buffer); } if (rs_config_load_ports() == 0) { - strcpy(buffer, "ERROR: problem with rsports file\r"); + strcpy(buffer, "ERROR: problem with rsports file\n"); err(buffer); } @@ -75,27 +75,27 @@ int main(int argc, char **argv) addr = rs_config_get_addr(argv[optind]); if (addr == NULL) { - sprintf(buffer, "ERROR: invalid Rose port name - %s\r", argv[optind]); + sprintf(buffer, "ERROR: invalid Rose port name - %s\n", argv[optind]); err(buffer); } if (rose_aton(addr, rosebind.srose_addr.rose_addr) == -1) { - sprintf(buffer, "ERROR: invalid Rose port address - %s\r", argv[optind]); + sprintf(buffer, "ERROR: invalid Rose port address - %s\n", argv[optind]); err(buffer); } if (ax25_aton_entry(argv[optind + 1], rosebind.srose_call.ax25_call) == -1) { - sprintf(buffer, "ERROR: invalid callsign - %s\r", argv[optind + 1]); + sprintf(buffer, "ERROR: invalid callsign - %s\n", argv[optind + 1]); err(buffer); } if (ax25_aton_entry(argv[optind + 2], roseconnect.srose_call.ax25_call) == -1) { - sprintf(buffer, "ERROR: invalid callsign - %s\r", argv[optind + 2]); + sprintf(buffer, "ERROR: invalid callsign - %s\n", argv[optind + 2]); err(buffer); } if (rose_aton(argv[optind + 3], roseconnect.srose_addr.rose_addr) == -1) { - sprintf(buffer, "ERROR: invalid Rose address - %s\r", argv[optind + 3]); + sprintf(buffer, "ERROR: invalid Rose address - %s\n", argv[optind + 3]); err(buffer); } @@ -104,7 +104,7 @@ int main(int argc, char **argv) */ s = socket(AF_ROSE, SOCK_SEQPACKET, 0); if (s < 0) { - sprintf(buffer, "ERROR: cannot open Rose socket, %s\r", strerror(errno)); + sprintf(buffer, "ERROR: cannot open Rose socket, %s\n", strerror(errno)); err(buffer); } @@ -112,11 +112,11 @@ int main(int argc, char **argv) * Set our AX.25 callsign and Rose address accordingly. */ if (bind(s, (struct sockaddr *)&rosebind, addrlen) != 0) { - sprintf(buffer, "ERROR: cannot bind Rose socket, %s\r", strerror(errno)); + sprintf(buffer, "ERROR: cannot bind Rose socket, %s\n", strerror(errno)); err(buffer); } - sprintf(buffer, "Connecting to %s @ %s ...\r", argv[optind + 2], argv[optind + 3]); + sprintf(buffer, "Connecting to %s @ %s ...\n", argv[optind + 2], argv[optind + 3]); user_write(STDOUT_FILENO, buffer, strlen(buffer)); /* @@ -132,16 +132,16 @@ int main(int argc, char **argv) if (connect(s, (struct sockaddr *)&roseconnect, addrlen) != 0) { switch (errno) { case ECONNREFUSED: - strcpy(buffer, "*** Connection refused - aborting\r"); + strcpy(buffer, "*** Connection refused - aborting\n"); break; case ENETUNREACH: - strcpy(buffer, "*** No known route - aborting\r"); + strcpy(buffer, "*** No known route - aborting\n"); break; case EINTR: - strcpy(buffer, "*** Connection timed out - aborting\r"); + strcpy(buffer, "*** Connection timed out - aborting\n"); break; default: - sprintf(buffer, "ERROR: cannot connect to Rose address, %s\r", strerror(errno)); + sprintf(buffer, "ERROR: cannot connect to Rose address, %s\n", strerror(errno)); break; } @@ -153,12 +153,12 @@ int main(int argc, char **argv) */ alarm(0); - strcpy(buffer, "*** Connected\r"); + strcpy(buffer, "*** Connected\n"); user_write(STDOUT_FILENO, buffer, strlen(buffer)); select_loop(s); - strcpy(buffer, "\r*** Disconnected\r"); + strcpy(buffer, "\n*** Disconnected\n"); user_write(STDOUT_FILENO, buffer, strlen(buffer)); end_compress();