-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtt.py
More file actions
45 lines (35 loc) · 826 Bytes
/
rtt.py
File metadata and controls
45 lines (35 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
import getpass
import sys
import telnetlib
import signal
from datetime import datetime
from time import strftime
HOST = "localhost"
PORT = "19021"
filename = "log.txt"
method = 'aw'
if(len(sys.argv) > 1):
filename = sys.argv[1]
if(len(sys.argv) > 2):
method = sys.argv[2]
fp = open(filename, method)
#date_time = strftime("%Y-%m-%d %H:%M:%S")
#string = "\n----------------------------------\n" + date_time + "\n----------------------------------\n"
#fp.write(string)
#print string
print "\nConnecting with Jlink/GDB Server....\n"
while True:
try:
tn = telnetlib.Telnet(HOST, PORT)
while True:
line = tn.read_eager()
if (len(line)>0 and line!=" "):
sys.stdout.write(line)
fp.write(line)
except KeyboardInterrupt:
fp.close()
tn.close()
sys.exit(0)
except:
continue