Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp981224pxb; Wed, 3 Mar 2021 23:23:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjtFrZ7fHgSvy77gag4EnonGzdnD/l4gxNT2HoYt6h1CPeYoDufJFycQOzx8U7XFEA2MMi X-Received: by 2002:a17:907:216b:: with SMTP id rl11mr2744898ejb.147.1614842599768; Wed, 03 Mar 2021 23:23:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614842599; cv=none; d=google.com; s=arc-20160816; b=u5vpQHi40QvRm8c/GHEjHYRCO2tPPzgFVUUjXgtE55tDF85p/2aeF1al496Ach3v10 l/Q/zP6LqyYkrN6vnmjNUl4LEfLVglCJkpmMpkNQahHKvK6erMYM7JnG6mtnIly/mhTF 7PQbyTu473uE057RVgFxs/BF8PPpUP2BZ0nwX2aQe85Rhc0Tl1Wa1He9GaEXffrEJy1T m0oGYuqJLWfdUw2SDPMspIT+tGxu0oYPATn7zD33NiRKhkbIy77PnDZR7UZZD8isECZO Mzw/IYKiRcXjQl9YfHRK769bGDKrZtx1QCN37t5iWy0UpDH3M1grTBOwEjv0Rxl7+mm6 UOEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=eaWQ9ofDP5pUPPuiyfJHoupQKH7hrKU1Fz/HCg3Dn8M=; b=j200PKkL86oTepRhPM5HRTWeNFyxPPHbwt16DgGlr6IpgBZflR9NMh8qKwBuiGxstt M1nDhh0kKrPqHkjZ84pJ/99LzDDn32QcgBeCiaoLVbwckcK7GL2av4LH4wRZI4MhVQ4I Fh/2SGtcfJHU0B4mOdJ+FbPBrTg25iBVeOMidy6b7dmPofFAX5l9x7nPgfMAn5FfxqZH FPcWevLheFavwayiNOpaBbcXy+M1/avG4AfjLZGwFBtxpbb6nsxp82QQrgipTl9zVAkX 3a6ZClCRvD/JF3PQtUSq4gz9h4VFJ4NFRKER4yJ/+aWF18SPAAxlBnY8Z9HJ/dkuOA4n szWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Q3+zPq+P; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si16513441edq.523.2021.03.03.23.22.34; Wed, 03 Mar 2021 23:23:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Q3+zPq+P; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345362AbhCBWeu (ORCPT + 99 others); Tue, 2 Mar 2021 17:34:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345394AbhCBAlI (ORCPT ); Mon, 1 Mar 2021 19:41:08 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3856EC061756 for ; Mon, 1 Mar 2021 16:40:28 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id s16so10978023plr.9 for ; Mon, 01 Mar 2021 16:40:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eaWQ9ofDP5pUPPuiyfJHoupQKH7hrKU1Fz/HCg3Dn8M=; b=Q3+zPq+P+ToAILo0WMvsQs7AjNtPfHAzLS/kqKlGiHK240YRNo5UDNnSLHK8vhYAqZ Aay6390sivV/0bopsh9exMsUw6ev89y2YoW8W/KumnPS/PJGx/1W2vhTouCZNd9epWs+ n5mEpSzPYgy73uB/Lhzc6eEELtyLAtenURNPg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eaWQ9ofDP5pUPPuiyfJHoupQKH7hrKU1Fz/HCg3Dn8M=; b=o4IJ2H1kXZPLe5NJp4F2nBntr1stFOnNrQOX/fgR8sHm3Fyh5OlZ5LcD02dljuzcak Cjc4YEsHmd1lCJN2fSjlhSOKDLULhgex2kl0fe6ICZ4XlSNeHOe8mXObNhy5DGV4W+97 rf+2nwt9RjYkhUIIupeEAN31NStjS3Efg5GihpvQY2zWlY/AUzbeeJiy9P2O/YpP84NQ 4ef3er9JKQBTIbkYsXQGGB13rnFkbE5DJEGijlqmb648HcOeZM+uqGF93I2bgpr4F57/ f4rfIQ3kdTpQrCUdFfnp3ehmOzKwXncxMuqICK5owHvvaUEySv64eReFn/dlLv228Qax +Vvg== X-Gm-Message-State: AOAM5318cPrU9UB6e0D8BziZlT7xeEaRcxJmsGP7xiuvx9ne2GbZd+lK +Z7e0X6Lh7OmauQSAX/NB92ruffKWVlqPQ== X-Received: by 2002:a17:90a:e97:: with SMTP id 23mr1546274pjx.136.1614645627547; Mon, 01 Mar 2021 16:40:27 -0800 (PST) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:6d7e:f36e:c2fc:82cb]) by smtp.gmail.com with ESMTPSA id m4sm17119286pgu.4.2021.03.01.16.40.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Mar 2021 16:40:26 -0800 (PST) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka , Daniel Winkler Subject: [PATCH BlueZ v4] monitor: Add option to set fallback width Date: Mon, 1 Mar 2021 16:40:19 -0800 Message-Id: <20210302004019.7150-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 --- 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 [
],[],[]\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