49def reset_dev(port=None,
54 baudrate=DEFAULT_BAUD_RATE,
57 """! Reset device using pythonic interface
58 @param port Switch -p <port>
59 @param disk Switch -d <disk>
60 @param reset_type Switch -r <reset_type>
61 @param reset_timeout Switch -R <reset_timeout>
62 @param serial_port Serial port handler, set to None if you want this function to open serial
64 @param baudrate Serial port baudrate
65 @param timeout Serial port timeout
66 @param verbose Verbose mode
72 with Serial(port, baudrate=baudrate, timeout=timeout)
as serial_port:
73 result = host_tests_plugins.call_plugin(
'ResetMethod',
78 except SerialException
as e:
80 print(
"%s" % (str(e)))
84def handle_send_break_cmd(port,
90 """! Resets platforms and prints serial port output
91 @detail Mix with switch -r RESET_TYPE and -p PORT for versatility
94 reset_type =
'default'
96 port_config = port.split(
':')
97 if len(port_config) == 2:
100 baudrate = int(port_config[1])
if not baudrate
else baudrate
101 elif len(port_config) == 3:
103 port = port_config[0]
104 baudrate = int(port_config[1])
if not baudrate
else baudrate
105 timeout = float(port_config[2])
109 baudrate = DEFAULT_BAUD_RATE
112 print(
"mbedhtrun: serial port configuration: %s:%s:%s"% (port, str(baudrate), str(timeout)))
115 serial_port = Serial(port, baudrate=baudrate, timeout=timeout)
116 except Exception
as e:
117 print(
"mbedhtrun: %s" % (str(e)))
121 "baudrate" : baudrate,
123 "reset_type" : reset_type,
129 result = host_tests_plugins.call_plugin(
'ResetMethod', reset_type, serial=serial_port, disk=disk)
131 print(
"mbedhtrun: reset plugin failed")
135 "baudrate" : baudrate,
137 "reset_type" : reset_type
141 print(
"mbedhtrun: serial dump started (use ctrl+c to break)")
144 test_output = serial_port.read(512)
146 sys.stdout.write(
'%s'% test_output)
147 if "{end}" in test_output:
150 print(
"mbedhtrun: stopped (found '{end}' terminator)")
152 except KeyboardInterrupt:
153 print(
"ctrl+c break")