From ce8dfab5302bb75bdd3d024259054d20b39b6460 Mon Sep 17 00:00:00 2001 From: nv-h Date: Fri, 17 Jun 2022 18:39:12 +0900 Subject: [PATCH] Add timestamp option --- pyrtt-viewer | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyrtt-viewer b/pyrtt-viewer index 5b9f147..3f6beec 100755 --- a/pyrtt-viewer +++ b/pyrtt-viewer @@ -24,6 +24,7 @@ import sys import time import threading +from datetime import datetime import logging import argparse @@ -127,6 +128,9 @@ class RTT: if s.strip() == "": continue try: + if self._args.timestamp: + now_str = datetime.now().strftime('%Y/%m/%d %H:%M:%S') + s = now_str + ' ' + s sys.stdout.buffer.write(bytes(s, "ascii")) except TypeError: continue @@ -167,6 +171,7 @@ def main(): parser = argparse.ArgumentParser("pyrtt-viewer") parser.add_argument("-s", "--segger-id", help="SEGGER ID of the nRF device", type=int) parser.add_argument("-c", "--channel", help="RTT channel", type=int, default=0) + parser.add_argument('-t', '--timestamp', action='store_true', help='Show timestamp') args = parser.parse_args() nrf = connect(args.segger_id) if not nrf: