mirror of https://github.com/ARMmbed/mbed-os.git
Added flow control test
Since this requires a separate serial port connection, added this as a new attribute of the MUTs.pull/135/head
parent
2ac6c4c531
commit
d0b2fb6c66
|
@ -0,0 +1,34 @@
|
|||
#include "mbed.h"
|
||||
|
||||
#if defined(TARGET_LPC1768)
|
||||
#define UART_TX p9
|
||||
#define UART_RX p10
|
||||
#define FLOW_CONTROL_RTS p11
|
||||
#define FLOW_CONTROL_CTS p12
|
||||
#define RTS_CHECK_PIN p13
|
||||
#else
|
||||
#error This test is not supported on this target
|
||||
#endif
|
||||
|
||||
Serial pc(UART_TX, UART_RX);
|
||||
|
||||
#ifdef RTS_CHECK_PIN
|
||||
InterruptIn in(RTS_CHECK_PIN);
|
||||
DigitalOut led(LED1);
|
||||
static void checker(void) {
|
||||
led = !led;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
char buf[256];
|
||||
|
||||
pc.set_flow_control(Serial::RTSCTS, FLOW_CONTROL_RTS, FLOW_CONTROL_CTS);
|
||||
#ifdef RTS_CHECK_PIN
|
||||
in.fall(checker);
|
||||
#endif
|
||||
while (1) {
|
||||
pc.gets(buf, 256);
|
||||
pc.printf("%s", buf);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2013 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from host_test import Test
|
||||
|
||||
|
||||
class EchoTest(Test):
|
||||
def __init__(self):
|
||||
Test.__init__(self)
|
||||
self.mbed.init_serial()
|
||||
self.mbed.extra_serial.rtscts = True
|
||||
self.mbed.reset()
|
||||
|
||||
def test(self):
|
||||
self.mbed.flush()
|
||||
self.notify("Starting the ECHO test")
|
||||
TEST="longer serial test"
|
||||
check = True
|
||||
for i in range(1, 100):
|
||||
self.mbed.extra_serial.write(TEST + "\n")
|
||||
l = self.mbed.extra_serial.readline().strip()
|
||||
if not l: continue
|
||||
|
||||
if l != TEST:
|
||||
check = False
|
||||
self.notify('"%s" != "%s"' % (l, TEST))
|
||||
else:
|
||||
if (i % 10) == 0:
|
||||
self.notify('.')
|
||||
|
||||
return check
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
EchoTest().run()
|
|
@ -38,6 +38,9 @@ class Mbed:
|
|||
|
||||
parser.add_option("-t", "--timeout", dest="timeout",
|
||||
help="Timeout", metavar="TIMEOUT")
|
||||
|
||||
parser.add_option("-e", "--extra", dest="extra",
|
||||
help="Extra serial port (used by some tests)", metavar="EXTRA")
|
||||
|
||||
(self.options, _) = parser.parse_args()
|
||||
|
||||
|
@ -46,14 +49,19 @@ class Mbed:
|
|||
|
||||
self.port = self.options.port
|
||||
self.disk = self.options.disk
|
||||
self.extra_port = self.options.extra
|
||||
self.extra_serial = None
|
||||
self.serial = None
|
||||
self.timeout = 10 if self.options.timeout is None else self.options.timeout
|
||||
|
||||
print 'Mbed: "%s" "%s"' % (self.port, self.disk)
|
||||
|
||||
def init_serial(self, baud=9600):
|
||||
def init_serial(self, baud=9600, extra_baud=9600):
|
||||
self.serial = Serial(self.port, timeout = 1)
|
||||
self.serial.setBaudrate(baud)
|
||||
if self.extra_port:
|
||||
self.extra_serial = Serial(self.extra_port, timeout = 1)
|
||||
self.extra_serial.setBaudrate(extra_baud)
|
||||
self.flush()
|
||||
|
||||
def reset(self):
|
||||
|
@ -64,7 +72,9 @@ class Mbed:
|
|||
def flush(self):
|
||||
self.serial.flushInput()
|
||||
self.serial.flushOutput()
|
||||
|
||||
if self.extra_serial:
|
||||
self.extra_serial.flushInput()
|
||||
self.extra_serial.flushOutput()
|
||||
|
||||
class Test:
|
||||
def __init__(self):
|
||||
|
|
|
@ -57,9 +57,9 @@ class ProcessObserver(Thread):
|
|||
pass
|
||||
|
||||
|
||||
def run_host_test(client, name, disk, port, duration):
|
||||
def run_host_test(client, name, disk, port, duration, extra_serial):
|
||||
print "{%s}" % name,
|
||||
cmd = ["python", "%s.py" % name, '-p', port, '-d', disk, '-t', str(duration)]
|
||||
cmd = ["python", "%s.py" % name, '-p', port, '-d', disk, '-t', str(duration), "-e", extra_serial]
|
||||
proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS)
|
||||
obs = ProcessObserver(proc)
|
||||
start = time()
|
||||
|
@ -144,6 +144,7 @@ class Tester(BaseRequestHandler):
|
|||
|
||||
disk = mut['disk']
|
||||
port = mut['port']
|
||||
extra_serial = mut.get('extra_serial', "")
|
||||
target = TARGET_MAP[mut['mcu']]
|
||||
|
||||
# Program
|
||||
|
@ -169,7 +170,7 @@ class Tester(BaseRequestHandler):
|
|||
|
||||
# Host test
|
||||
self.request.setblocking(0)
|
||||
result = run_host_test(self.request, test.host_test, disk, port, duration)
|
||||
result = run_host_test(self.request, test.host_test, disk, port, duration, extra_serial)
|
||||
self.send_result(result)
|
||||
|
||||
|
||||
|
|
|
@ -203,6 +203,15 @@ TESTS = [
|
|||
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
|
||||
"automated": True,
|
||||
},
|
||||
{
|
||||
"id": "MBED_A22", "description": "Serial echo with RTS/CTS flow control",
|
||||
"source_dir": join(TEST_DIR, "mbed", "echo_flow_control"),
|
||||
"dependencies": [MBED_LIBRARIES],
|
||||
"automated": "True",
|
||||
"host_test": "echo_flow_control",
|
||||
"mcu": ["LPC1768"],
|
||||
"peripherals": ["extra_serial"]
|
||||
},
|
||||
|
||||
# Size benchmarks
|
||||
{
|
||||
|
@ -392,7 +401,7 @@ TESTS = [
|
|||
"dependencies": [MBED_LIBRARIES],
|
||||
"mcu": ["LPC1768", "LPC4088"]
|
||||
},
|
||||
|
||||
|
||||
# CMSIS RTOS tests
|
||||
{
|
||||
"id": "CMSIS_RTOS_1", "description": "Basic",
|
||||
|
|
Loading…
Reference in New Issue