4 Copyright (c) 2011-2016 ARM Limited
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
21 from serial
import Serial, SerialException
22 from mbed_host_tests
import host_tests_plugins
24 from .conn_primitive
import ConnectorPrimitive, ConnectorPrimitiveException
28 def __init__(self, name, port, baudrate, config):
29 ConnectorPrimitive.__init__(self, name)
38 self.
skip_resetskip_reset = config.get(
'skip_reset',
False)
48 if serial_port
is None:
51 if serial_port != self.
portport:
53 self.
loggerlogger.prn_inf(
"serial port changed from '%s to '%s')"% (self.
portport, serial_port))
54 self.
portport = serial_port
56 startTime = time.time()
64 except SerialException
as e:
71 self.
loggerlogger.prn_err(str(e))
80 """! Reset device using selected method, calls one of the reset plugins """
81 reset_type = self.
configconfig.get(
'reset_type',
'default')
83 reset_type =
'default'
84 disk = self.
configconfig.get(
'disk',
None)
86 self.
loggerlogger.prn_inf(
"reset device using '%s' plugin..."% reset_type)
87 result = host_tests_plugins.call_plugin(
'ResetMethod',
92 polling_timeout=self.
configconfig.get(
'polling_timeout'))
95 self.
loggerlogger.prn_inf(
"waiting %.2f sec after reset"% delay)
97 self.
loggerlogger.prn_inf(
"wait for it...")
101 """! Read data from serial port RX buffer """
109 except SerialException
as e:
112 self.
loggerlogger.prn_err(str(e))
115 def write(self, payload, log=False):
116 """! Write data to serial port TX buffer """
121 self.
loggerlogger.prn_txd(payload)
123 except SerialException
as e:
125 self.
LAST_ERRORLAST_ERRORLAST_ERROR =
"connection lost, serial.write(%d bytes): %s"% (len(payload), str(e))
126 self.
loggerlogger.prn_err(str(e))
134 return bool(self.
serialserial)
def finish(self)
Handle DUT dtor like (close resource) operations here.
def reset(self)
Reset the dut.
def reset_dev_via_serial(self, delay=1)
Reset device using selected method, calls one of the reset plugins.
def finish(self)
Handle DUT dtor like (close resource) operations here.
def connected(self)
Check if there is a connection to DUT.
def flush(self)
Flush read/write channels of DUT.
def __init__(self, name, port, baudrate, config)
def read(self, count)
Read data from serial port RX buffer.
def write(self, payload, log=False)
Write data to serial port TX buffer.
Base class for all plugins used with host tests.