Skip to content

Commit

Permalink
On error on rtt close app and add hint text
Browse files Browse the repository at this point in the history
  • Loading branch information
blavka committed Jul 25, 2022
1 parent 94a6bcb commit 67c727a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/hardwario/chester/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ def command_console(ctx, reset, latency, history_file, console_file):
if reset:
prog.reset()
prog.go()
Console(prog, history_file, console_file, latency=latency)
c = Console(prog, history_file, console_file, latency=latency)

click.echo('TIP: After J-Link connection, it is crucial to power cycle the target device; otherwise, the CPU debug mode results in a permanently increased power consumption.')

if c.exception:
raise c.exception


def validate_pib_param(ctx, param, value):
Expand Down
11 changes: 9 additions & 2 deletions src/hardwario/chester/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import asyncio
import logging
import sys
import re
from functools import partial
from datetime import datetime
Expand All @@ -23,8 +24,7 @@
from prompt_toolkit.application.current import get_app
from prompt_toolkit.lexers import Lexer
from prompt_toolkit.styles.named_colors import NAMED_COLORS

from .nrfjprog import NRFJProg, NRFJProgRTTNoChannels
from .nrfjprog import NRFJProg, NRFJProgRTTNoChannels, NRFJProgException


def getTime():
Expand Down Expand Up @@ -231,6 +231,9 @@ async def task_rtt_read():
line = prog.rtt_read(channel)
except NRFJProgRTTNoChannels:
return
except NRFJProgException as e:
self.exit(e)
return
if line:
# buffer.insert_text(line.replace('\r', ''))
for sline in line.splitlines():
Expand Down Expand Up @@ -263,3 +266,7 @@ def accept(buff):
self.app.run()

prog.rtt_stop()

def exit(self, exception=None):
self.exception = exception
self.app.exit()

0 comments on commit 67c727a

Please sign in to comment.