All of lore.kernel.org
 help / color / mirror / Atom feed
From: f6bvp <f6bvp@free.fr>
To: linux-hams@vger.kernel.org
Cc: Thomas Osterried DL9SAU <thomas@x-berg.in-berlin.de>,
	netdev@vger.kernel.org, Francois Romieu <romieu@fr.zoreil.com>
Subject: Resend : [PATCH] AX25 rose_call - replacing carriage return by newlines
Date: Sun, 7 Aug 2022 20:21:34 +0200	[thread overview]
Message-ID: <d3e987ef-2c6d-4ae4-9b58-75d25f7793c2@free.fr> (raw)
In-Reply-To: <Yuf04XIsXrQMJuUy@electric-eye.fr.zoreil.com>

[-- Attachment #1: Type: text/plain, Size: 1345 bytes --]

[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 <thomas@osterried.de>
Cc: Francois Romieu <romieu@fr.zoreil.com>
Signed-off-by: Bernard Pidoux <f6bvp@free.fr>


[-- Attachment #2: replace_return-linefeed_in_rose_call.patch --]
[-- Type: text/x-patch, Size: 5274 bytes --]

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();

  parent reply	other threads:[~2022-08-07 18:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-30 15:08 rose timer t error displayed in /proc/net/rose Bernard f6bvp
2022-08-01  0:39 ` Francois Romieu
2022-08-01  8:06   ` Thomas Osterried
2022-08-01  9:19     ` Bernard f6bvp
2022-08-01 15:44     ` Francois Romieu
2022-08-01 19:06       ` Thomas Osterried
2022-08-01 19:33       ` Bernard f6bvp
2022-08-07 18:04       ` [PATCH] AX25 rose_call - replacing carriage return by newlines f6bvp
2022-08-07 18:21       ` f6bvp [this message]
     [not found]         ` <ABFC096C-8F65-49C9-8BB9-7B75B3CE30B7@osterried.de>
2022-08-08 12:31           ` Resend : " f6bvp
2022-08-01  8:54   ` rose timer t error displayed in /proc/net/rose Bernard f6bvp
2022-08-01 10:43   ` Bernard f6bvp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3e987ef-2c6d-4ae4-9b58-75d25f7793c2@free.fr \
    --to=f6bvp@free.fr \
    --cc=linux-hams@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fr.zoreil.com \
    --cc=thomas@x-berg.in-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.