Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyrtt-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import sys
import time
import threading
from datetime import datetime
import logging
import argparse

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down