All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v4] monitor: Add option to set fallback width
@ 2021-03-02  0:40 Sonny Sasaka
  2021-03-02 23:37 ` [BlueZ,v4] " bluez.test.bot
  2021-03-03 15:48 ` [PATCH BlueZ v4] " Marcel Holtmann
  0 siblings, 2 replies; 3+ messages in thread
From: Sonny Sasaka @ 2021-03-02  0:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sonny Sasaka, Daniel Winkler

Sometimes we want to be able to pipe the output of btmon to a
non-terminal device. The current fallback width is usually not long
enough so this patch adds an option to specify the column width. This is
especially needed for text logs from bluetoothd.

Reviewed-by: Daniel Winkler <danielwinkler@google.com>

---
 monitor/display.c | 8 +++++++-
 monitor/display.h | 1 +
 monitor/main.c    | 8 +++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/monitor/display.c b/monitor/display.c
index b11b71d5d..4e5693b04 100644
--- a/monitor/display.c
+++ b/monitor/display.c
@@ -28,6 +28,7 @@
 #include "display.h"
 
 static pid_t pager_pid = 0;
+int default_pager_num_columns = FALLBACK_TERMINAL_WIDTH;
 
 bool use_color(void)
 {
@@ -39,6 +40,11 @@ bool use_color(void)
 	return cached_use_color;
 }
 
+void set_default_pager_num_columns(int num_columns)
+{
+	default_pager_num_columns = num_columns;
+}
+
 int num_columns(void)
 {
 	static int cached_num_columns = -1;
@@ -48,7 +54,7 @@ int num_columns(void)
 
 		if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0 ||
 								ws.ws_col == 0)
-			cached_num_columns = FALLBACK_TERMINAL_WIDTH;
+			cached_num_columns = default_pager_num_columns;
 		else
 			cached_num_columns = ws.ws_col;
 	}
diff --git a/monitor/display.h b/monitor/display.h
index f3a614b81..cba39ec7f 100644
--- a/monitor/display.h
+++ b/monitor/display.h
@@ -73,6 +73,7 @@ static inline uint64_t print_bitfield(int indent, uint64_t val,
 	return mask;
 }
 
+void set_default_pager_num_columns(int num_columns);
 int num_columns(void);
 
 void open_pager(void);
diff --git a/monitor/main.c b/monitor/main.c
index 0f5eb4a3b..969c88103 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -30,6 +30,7 @@
 #include "analyze.h"
 #include "ellisys.h"
 #include "control.h"
+#include "display.h"
 
 static void signal_callback(int signum, void *user_data)
 {
@@ -67,6 +68,7 @@ static void usage(void)
 		"\t                       Read data from RTT\n"
 		"\t-R  --rtt [<address>],[<area>],[<name>]\n"
 		"\t                       RTT control block parameters\n"
+		"\t-C, --columns [width]  Output width if not a terminal\n"
 		"\t-h, --help             Show help options\n");
 }
 
@@ -90,6 +92,7 @@ static const struct option main_options[] = {
 	{ "no-pager",  no_argument,       NULL, 'P' },
 	{ "jlink",     required_argument, NULL, 'J' },
 	{ "rtt",       required_argument, NULL, 'R' },
+	{ "columns",   required_argument, NULL, 'C' },
 	{ "todo",      no_argument,       NULL, '#' },
 	{ "version",   no_argument,       NULL, 'v' },
 	{ "help",      no_argument,       NULL, 'h' },
@@ -121,7 +124,7 @@ int main(int argc, char *argv[])
 		struct sockaddr_un addr;
 
 		opt = getopt_long(argc, argv,
-					"r:w:a:s:p:i:d:B:V:MNtTSAE:PJ:R:vh",
+					"r:w:a:s:p:i:d:B:V:MNtTSAE:PJ:R:C:vh",
 					main_options, NULL);
 		if (opt < 0)
 			break;
@@ -205,6 +208,9 @@ int main(int argc, char *argv[])
 		case 'R':
 			rtt = optarg;
 			break;
+		case 'C':
+			set_default_pager_num_columns(atoi(optarg));
+			break;
 		case '#':
 			packet_todo();
 			lmp_todo();
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [BlueZ,v4] monitor: Add option to set fallback width
  2021-03-02  0:40 [PATCH BlueZ v4] monitor: Add option to set fallback width Sonny Sasaka
@ 2021-03-02 23:37 ` bluez.test.bot
  2021-03-03 15:48 ` [PATCH BlueZ v4] " Marcel Holtmann
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2021-03-02 23:37 UTC (permalink / raw)
  To: linux-bluetooth, sonnysasaka

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

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=440755

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ v4] monitor: Add option to set fallback width
  2021-03-02  0:40 [PATCH BlueZ v4] monitor: Add option to set fallback width Sonny Sasaka
  2021-03-02 23:37 ` [BlueZ,v4] " bluez.test.bot
@ 2021-03-03 15:48 ` Marcel Holtmann
  1 sibling, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2021-03-03 15:48 UTC (permalink / raw)
  To: Sonny Sasaka; +Cc: Bluetooth Kernel Mailing List, Daniel Winkler

Hi Sonny,

> Sometimes we want to be able to pipe the output of btmon to a
> non-terminal device. The current fallback width is usually not long
> enough so this patch adds an option to specify the column width. This is
> especially needed for text logs from bluetoothd.
> 
> Reviewed-by: Daniel Winkler <danielwinkler@google.com>
> 
> ---
> monitor/display.c | 8 +++++++-
> monitor/display.h | 1 +
> monitor/main.c    | 8 +++++++-
> 3 files changed, 15 insertions(+), 2 deletions(-)

patch has been applied.

Regards

Marcel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-04  0:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02  0:40 [PATCH BlueZ v4] monitor: Add option to set fallback width Sonny Sasaka
2021-03-02 23:37 ` [BlueZ,v4] " bluez.test.bot
2021-03-03 15:48 ` [PATCH BlueZ v4] " Marcel Holtmann

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.