* set default terminal from pseudoterm to pyterm
* updated pyterm
This commit is contained in:
parent
04936c6c0f
commit
473a0f108c
2
Jamrules
2
Jamrules
@ -39,7 +39,7 @@ SUFFIX ?= "" ; # must be at least "" !!!
|
|||||||
TARGET = "$(BOARD)-$(PROJECT)$(SUFFIX)$(SUFEXE)" ; # main target binary
|
TARGET = "$(BOARD)-$(PROJECT)$(SUFFIX)$(SUFEXE)" ; # main target binary
|
||||||
OPENOCD_IF ?= olimex-jtag-tiny-a ;
|
OPENOCD_IF ?= olimex-jtag-tiny-a ;
|
||||||
|
|
||||||
TERMINAL ?= board/msba2/tools/bin/pseudoterm ;
|
TERMINAL ?= tools/pyterm/pyterm.py ;
|
||||||
|
|
||||||
if $(NT) || $(OS) = CYGWIN {
|
if $(NT) || $(OS) = CYGWIN {
|
||||||
PORT = $(PORT:E=1) ;
|
PORT = $(PORT:E=1) ;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import cmd, serial, sys, threading, readline, time, ConfigParser
|
import cmd, serial, sys, threading, readline, time, ConfigParser, logging, os
|
||||||
from datetime import datetime
|
|
||||||
from os import path
|
pytermdir = os.environ['HOME'] + os.path.sep + '.pyterm'
|
||||||
|
|
||||||
class SerCmd(cmd.Cmd):
|
class SerCmd(cmd.Cmd):
|
||||||
|
|
||||||
@ -17,6 +17,26 @@ class SerCmd(cmd.Cmd):
|
|||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
### create Logging object
|
||||||
|
my_millis = ("%.4f" % time.time())
|
||||||
|
date_str = '%s.%s' % (time.strftime('%Y%m%d-%H:%M:%S'), my_millis[-4:])
|
||||||
|
# create formatter
|
||||||
|
fmt_str = '%(asctime)s - %(levelname)s # %(message)s'
|
||||||
|
formatter = logging.Formatter(fmt_str)
|
||||||
|
logging.basicConfig(filename=pytermdir + os.path.sep + date_str + '.log', level=logging.DEBUG, format=fmt_str)
|
||||||
|
ch = logging.StreamHandler()
|
||||||
|
ch.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
# create logger
|
||||||
|
self.logger = logging.getLogger('')
|
||||||
|
self.logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
# add formatter to ch
|
||||||
|
ch.setFormatter(formatter)
|
||||||
|
# add ch to logger
|
||||||
|
self.logger.addHandler(ch)
|
||||||
|
|
||||||
|
|
||||||
def preloop(self):
|
def preloop(self):
|
||||||
if not self.port:
|
if not self.port:
|
||||||
sys.stderr.write("No port specified!\n")
|
sys.stderr.write("No port specified!\n")
|
||||||
@ -26,7 +46,7 @@ class SerCmd(cmd.Cmd):
|
|||||||
self.ser.setRTS(0)
|
self.ser.setRTS(0)
|
||||||
|
|
||||||
# start serial->console thread
|
# start serial->console thread
|
||||||
receiver_thread = threading.Thread(target=reader, args=(self.ser,))
|
receiver_thread = threading.Thread(target=reader, args=(self.ser,self.logger))
|
||||||
receiver_thread.setDaemon(1)
|
receiver_thread.setDaemon(1)
|
||||||
receiver_thread.start()
|
receiver_thread.start()
|
||||||
|
|
||||||
@ -39,14 +59,12 @@ class SerCmd(cmd.Cmd):
|
|||||||
self.ser.write("help\n")
|
self.ser.write("help\n")
|
||||||
|
|
||||||
def complete_date(self, text, line, begidx, endidm):
|
def complete_date(self, text, line, begidx, endidm):
|
||||||
date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
date = time.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
return ["%s" % date]
|
return ["%s" % date]
|
||||||
|
|
||||||
def do_reset(self, line):
|
def do_reset(self, line):
|
||||||
self.ser.setDTR(1)
|
self.ser.setDTR(1)
|
||||||
self.ser.setRTS(1)
|
|
||||||
self.ser.setDTR(0)
|
self.ser.setDTR(0)
|
||||||
self.ser.setRTS(0)
|
|
||||||
|
|
||||||
def do_exit(self, line):
|
def do_exit(self, line):
|
||||||
readline.write_history_file()
|
readline.write_history_file()
|
||||||
@ -92,7 +110,7 @@ class SerCmd(cmd.Cmd):
|
|||||||
|
|
||||||
def load_config(self):
|
def load_config(self):
|
||||||
self.config = ConfigParser.SafeConfigParser()
|
self.config = ConfigParser.SafeConfigParser()
|
||||||
self.config.read([path.expanduser('~/.pyterm')])
|
self.config.read([pytermdir + os.path.sep + 'pyterm.conf'])
|
||||||
|
|
||||||
for sec in self.config.sections():
|
for sec in self.config.sections():
|
||||||
if sec == "aliases":
|
if sec == "aliases":
|
||||||
@ -104,13 +122,22 @@ class SerCmd(cmd.Cmd):
|
|||||||
self.__dict__[opt] = self.config.get(sec, opt)
|
self.__dict__[opt] = self.config.get(sec, opt)
|
||||||
|
|
||||||
|
|
||||||
def reader(ser):
|
def reader(ser, logger):
|
||||||
|
output = ""
|
||||||
while (1):
|
while (1):
|
||||||
c = ser.read(1)
|
c = ser.read(1)
|
||||||
sys.stdout.write(c)
|
if c == '\n' or c == '\r':
|
||||||
sys.stdout.flush()
|
logger.info(output)
|
||||||
|
output = ""
|
||||||
|
else:
|
||||||
|
output += c
|
||||||
|
#sys.stdout.write(c)
|
||||||
|
#sys.stdout.flush()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
if not os.path.exists(pytermdir):
|
||||||
|
os.makedirs(pytermdir)
|
||||||
|
|
||||||
if (len(sys.argv) > 1):
|
if (len(sys.argv) > 1):
|
||||||
port = sys.argv[1]
|
port = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user