Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --gdb argument for debugging #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 18 additions & 3 deletions btptester.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def main():
parser.add_argument('--rerun-until-failure', action='store_true',
help='Run the tests again after completion until one test fails')
parser.add_argument('--fail-fast', action='store_true',
help='Stops the run at first failure')
help='Stops the run at first failure'),
parser.add_argument('--gdb', type=str,
help="Skip selected board reset to avoid gdb server"
" disconnection e.g. --gdb central/prph/both")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I'd say, either use short or full names, so either central/peripheral or cent/perph


args = parser.parse_args()

Expand All @@ -73,15 +76,27 @@ def main():
central_os, central_sn = args.central
peripheral_os, peripheral_sn = args.peripheral

gdb_central = False
gdb_prph = False

if args.gdb is not None:
if args.gdb == 'both':
gdb_central = True
gdb_prph = True
elif args.gdb == 'prph':
gdb_prph = True
else:
gdb_central = True

if central_os == IutCtl.TYPE_MYNEWT:
central = MynewtCtl(NordicBoard(central_sn))
central = MynewtCtl(NordicBoard(central_sn), gdb_central)
elif central_os == IutCtl.TYPE_ANDROID:
central = AndroidCtl(central_sn)
else:
raise ValueError("Central OS is not implemented.")

if peripheral_os == IutCtl.TYPE_MYNEWT:
peripheral = MynewtCtl(NordicBoard(peripheral_sn))
peripheral = MynewtCtl(NordicBoard(peripheral_sn), gdb_prph)
elif peripheral_os == IutCtl.TYPE_ANDROID:
peripheral = AndroidCtl(peripheral_sn)
else:
Expand Down
23 changes: 13 additions & 10 deletions projects/mynewt/iutctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
class MynewtCtl(IutCtl):
"""Mynewt OS Control Class"""

def __init__(self, board: Board):
def __init__(self, board: Board, gdb=None):
log("%s.%s board=%r", self.__class__,
self.__init__.__name__, board)

Expand All @@ -51,6 +51,7 @@ def __init__(self, board: Board):
self._socat_process = None
self._btp_socket = None
self._btp_worker = None
self.gdb = gdb

self.log_filename = "iut-mynewt-{}.log".format(self.id)
self.log_file = open(self.log_filename, "w")
Expand Down Expand Up @@ -125,20 +126,22 @@ def reset(self):
if not self.board:
return

self.board.reset(self.log_file)
if not self.gdb:
self.board.reset(self.log_file)

def wait_iut_ready_event(self):
"""Wait until IUT sends ready event after power up"""
self.reset()

tuple_hdr, tuple_data = self._btp_worker.read()
if (tuple_hdr.svc_id != defs.BTP_SERVICE_ID_CORE or
tuple_hdr.op != defs.CORE_EV_IUT_READY):
err = BTPError("Failed to get ready event")
log("Unexpected event received (%s), expected IUT ready!", err)
raise err
else:
log("IUT ready event received OK")
if not self.gdb:
tuple_hdr, tuple_data = self._btp_worker.read()
if (tuple_hdr.svc_id != defs.BTP_SERVICE_ID_CORE or
tuple_hdr.op != defs.CORE_EV_IUT_READY):
err = BTPError("Failed to get ready event")
log("Unexpected event received (%s), expected IUT ready!", err)
raise err
else:
log("IUT ready event received OK")

def stop(self):
"""Stop IUT related processes"""
Expand Down