Skip to contentSkip to conversation

ldattach updates

PATCH Applied Tilman Schmidt 2 participants 5 messages Jul 9, 2015 – Jul 15, 2015 Util-Linux package

lore
Share & tools
lore
#0 lore raw

cover ldattach updates

Please merge the following three patches for ldattach.

Thanks,
Tilman

Tilman Schmidt (3):
ldattach: adapt print_table column width to widest entry
ldattach: order line disciplines canonically
ldattach: always set line speed and format for N_GIGASET_M101

 sys-utils/ldattach.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)
Signature · 1 line
1.9.2.459.g68773ac
#1 lore raw

PATCH 1/3 ldattach: adapt print_table column width to widest entry

The hardcoded column width of 10 in print_table() is not enough, as the currently longest table entry to be printed has 12 characters.

---
 sys-utils/ldattach.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sys-utils/ldattach.c +2 -2
index 33c7aa2..5317d22 100644
@@ -161,8 +161,8 @@ static void print_table(FILE * out, const struct ld_table *tab)
 	int i;
 
 	for (t = tab, i = 1; t && t->name; t++, i++) {
-		fprintf(out, "  %-10s", t->name);
-		if (!(i % 6))
+		fprintf(out, "  %-12s", t->name);
+		if (!(i % 5))
 			fputc('\n', out);
 	}
 }
Signature · 1 line
1.9.2.459.g68773ac
#2 lore raw

PATCH 2/3 ldattach: order line disciplines canonically

In reply to Tilman Schmidt

List line disciplines in numerical order and put official names before convenience aliases.

---
 sys-utils/ldattach.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
sys-utils/ldattach.c +7 -6
index 5317d22..bd4fadd 100644
@@ -62,14 +62,15 @@ struct gsm_config
 #ifndef N_GIGASET_M101
 # define N_GIGASET_M101 16
 #endif
-#ifndef N_GSM0710
-# define N_GSM0710 21
-#endif
 
 #ifndef N_PPS
 # define N_PPS 18
 #endif
 
+#ifndef N_GSM0710
+# define N_GSM0710 21
+#endif
+
 #define MAXINTROPARMLEN 32
 
 /* attach a line discipline ioctl */
@@ -86,7 +87,6 @@ struct ld_table {
 
 /* currently supported line disciplines, plus some aliases */
 static const struct ld_table ld_discs[] = {
-	{ "GSM0710",		N_GSM0710},
 	{ "TTY",		N_TTY },
 	{ "SLIP",		N_SLIP },
 	{ "MOUSE",		N_MOUSE },
@@ -101,10 +101,11 @@ static const struct ld_table ld_discs[] = {
 	{ "SYNC_PPP",		N_SYNC_PPP },
 	{ "SYNCPPP",		N_SYNC_PPP },
 	{ "HCI",		N_HCI },
-	{ "PPS",		N_PPS },
+	{ "GIGASET_M101",	N_GIGASET_M101 },
 	{ "M101",		N_GIGASET_M101 },
 	{ "GIGASET",		N_GIGASET_M101 },
-	{ "GIGASET_M101",	N_GIGASET_M101 },
+	{ "PPS",		N_PPS },
+	{ "GSM0710",		N_GSM0710},
 	{ NULL,	0 }
 };
 
Signature · 1 line
1.9.2.459.g68773ac
#3 lore raw

PATCH 3/3 ldattach: always set line speed and format for N_GIGASET_M101

In reply to Tilman Schmidt

The Gigaset M101 exhibits particularly awkward and confusing behaviour when the serial line speed isn't set to what the device expects:
Configuration mode detects the used speed and works anyway, but data mode silently fails. Troubleshooting this is enormously time-consuming.

Spare the users this trouble by setting the line speed and format to these devices' factory default values as long as the command line doesn't say otherwise.

---
 sys-utils/ldattach.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
sys-utils/ldattach.c +11 -1
index bd4fadd..99db32e 100644
@@ -366,6 +366,15 @@ int main(int argc, char **argv)
 	if (ldisc < 0)
 		ldisc = strtos32_or_err(argv[optind], _("invalid line discipline argument"));
 
+	/* ldisc specific option settings */
+	if (ldisc == N_GIGASET_M101) {
+		/* device specific defaults for line speed and data format */
+		if (speed == 0) speed = 115200;
+		if (bits == '-') bits = '8';
+		if (parity == '-') parity = 'n';
+		if (stop == '-') stop = '1';
+	}
+
 	/* open device */
 	dev = argv[optind + 1];
 	if ((tty_fd = open(dev, O_RDWR | O_NOCTTY)) < 0)
@@ -448,12 +457,13 @@ int main(int argc, char **argv)
 		}
 	}
 
-	/* Attach the line discpline. */
+	/* Attach the line discipline. */
 	if (ioctl(tty_fd, TIOCSETD, &ldisc) < 0)
 		err(EXIT_FAILURE, _("cannot set line discipline"));
 
 	dbg("line discipline set to %d", ldisc);
 
+	/* ldisc specific post-attach actions */
 	if (ldisc == N_GSM0710)
 		gsm0710_set_conf(tty_fd);
 
Signature · 1 line
1.9.2.459.g68773ac
maintainer Applied
#4 lore raw
In reply to Tilman Schmidt
Quoted 3 lines · Tilman Schmidt

ldattach: adapt print_table column width to widest entry
ldattach: order line disciplines canonically
ldattach: always set line speed and format for N_GIGASET_M101

Applied, thanks!

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com