Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mbedmicro/mbed
Browse files Browse the repository at this point in the history
  • Loading branch information
bcostm committed Sep 5, 2014
2 parents 3566062 + 449b984 commit f9e7f69
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{ \
__asm( \
"svc %0\n" \
"bx r14" : : "I" (number) : "r0" \
"bx r14" : : "I" ((uint32_t)number) : "r0" \
); \
}
#elif defined (__ICCARM__)
Expand Down
4 changes: 3 additions & 1 deletion libraries/tests/mbed/echo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ int main() {

Serial pc(TXPIN, RXPIN);
pc.baud(115200);

pc.puts("{{");
pc.puts(TEST_ENV_START); // Host test is expecting preamble
pc.puts("}}");

while (1) {
pc.gets(buf, 256);

pc.printf("%s", buf);
}
}
4 changes: 3 additions & 1 deletion libraries/tests/net/echo/tcp_client_loop/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "mbed.h"
#include "test_env.h"
#include "EthernetInterface.h"

struct s_ip_address
Expand All @@ -11,6 +12,7 @@ struct s_ip_address

#define MAX_ECHO_LOOPS 100


int main() {
char buffer[256] = {0};
char out_buffer[] = "Hello World\n";
Expand All @@ -36,7 +38,7 @@ int main() {
wait(1);
}

// Test loop for multiple client conenctions
// Test loop for multiple client connections
bool result = true;
int count_error = 0;
for (int i = 0; i < MAX_ECHO_LOOPS; i++) {
Expand Down
8 changes: 5 additions & 3 deletions libraries/tests/net/helloworld/udpclient/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace {
const char *HTTP_SERVER_NAME = "utcnist.colorado.edu";
const int HTTP_SERVER_PORT = 37;
const float YEARS_TO_PASS = 114.0;
}


int main() {
bool result = false;
EthernetInterface eth;
Expand All @@ -30,14 +32,14 @@ int main() {

const int n = sock.receiveFrom(nist, in_buffer_tab, sizeof(in_buffer_tab));
if (n > 0) {
result = true;
const unsigned int timeRes = ntohl(in_buffer_uint);
const float years = timeRes / 60.0 / 60.0 / 24.0 / 365;
printf("UDP: Received %d bytes from server %s on port %d\r\n", n, nist.get_address(), nist.get_port());
printf("UDP: %u seconds since 01/01/1900 00:00 GMT ... %s\r\n", timeRes, timeRes > 0 ? "[OK]" : "[FAIL]");
printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > 114.0 ? "[OK]" : "[FAIL]");
result = true;
printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]");

if (years < 114.0) {
if (years < YEARS_TO_PASS) {
result = false;
}
}
Expand Down
8 changes: 4 additions & 4 deletions workspace_tools/export/gcc_arm_arch_ble.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %}
LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %}
LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %}
LINKER_SCRIPT = {{linker_script}}
SOFTDEVICE = mbed/TARGET_NRF51822/TARGET_NORDIC/TARGET_NRF51822/Lib/s110_nrf51822_6_0_0/s110_nrf51822_6.0.0_softdevice.hex
SOFTDEVICE = mbed/TARGET_ARCH_BLE/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_softdevice.hex

###############################################################################
AS = $(GCC_BIN)arm-none-eabi-as
Expand All @@ -23,7 +23,7 @@ CPU = -mcpu=cortex-m0 -mthumb
CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections
CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %}

LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float
LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections -Wl,--wrap=main --specs=nano.specs -u _printf_float -u _scanf_float
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys

ifeq ($(DEBUG), 1)
Expand All @@ -32,7 +32,7 @@ else
CC_FLAGS += -DNDEBUG -Os
endif

all: $(PROJECT).hex merge
all: $(PROJECT).hex

clean:
rm -f $(PROJECT).hex $(PROJECT).elf $(OBJECTS)
Expand All @@ -54,4 +54,4 @@ $(PROJECT).hex: $(PROJECT).elf
$(OBJCOPY) -O ihex $< $@

merge:
$(SREC_CAT) $(SOFTDEVICE) -intel $(PROJECT).hex -binary --offset 0x14000 -o combined.hex -intel --line-length=46
$(SREC_CAT) $(SOFTDEVICE) -intel $(PROJECT).hex -intel -o combined.hex -intel --line-length=44
6 changes: 3 additions & 3 deletions workspace_tools/export/gcc_arm_nrf51822.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %}
LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %}
LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %}
LINKER_SCRIPT = {{linker_script}}
SOFTDEVICE = mbed/TARGET_NRF51822/TARGET_NORDIC/TARGET_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_softdevice.hex
SOFTDEVICE = mbed/TARGET_NRF51822/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_softdevice.hex

###############################################################################
AS = $(GCC_BIN)arm-none-eabi-as
Expand All @@ -32,7 +32,7 @@ else
CC_FLAGS += -DNDEBUG -Os
endif

all: $(PROJECT).hex merge
all: $(PROJECT).hex

clean:
rm -f $(PROJECT).hex $(PROJECT).elf $(OBJECTS)
Expand All @@ -54,4 +54,4 @@ $(PROJECT).hex: $(PROJECT).elf
$(OBJCOPY) -O ihex $< $@

merge:
$(SREC_CAT) $(SOFTDEVICE) -intel $(PROJECT).hex -intel --offset 0x16000 -o combined.hex -intel --line-length=46
$(SREC_CAT) $(SOFTDEVICE) -intel $(PROJECT).hex -intel -o combined.hex -intel --line-length=44
13 changes: 12 additions & 1 deletion workspace_tools/host_tests/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
limitations under the License.
"""
import uuid
from sys import stdout
from host_test import Test


Expand All @@ -26,10 +27,20 @@ def __init__(self):

def test(self):
# Let's wait for Mbed to print its readiness, usually "{{start}}"
c = self.mbed.serial_read(16)
if self.mbed.serial_timeout(None) is None:
self.print_result("ioerr_serial")
return

c = self.mbed.serial_read(len('{{start}}'))
if c is None:
self.print_result("ioerr_serial")
return
print c
stdout.flush()

if self.mbed.serial_timeout(1) is None:
self.print_result("ioerr_serial")
return

self.mbed.flush()
self.notify("Starting the ECHO test")
Expand Down
1 change: 1 addition & 0 deletions workspace_tools/host_tests/hello_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def run(self):
self.print_result("ioerr_serial")
return
print "Read %d bytes"% len(c)
print c
stdout.flush()
result = True
# Because we can have targetID here let's try to decode
Expand Down
3 changes: 3 additions & 0 deletions workspace_tools/host_tests/rtc_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def run(self):
result_msg = "OK" if (time_str == correct_time_str) else "FAIL"
print "Got RTC time: " + c[:-1] + " ... " + result_msg
stdout.flush()
else:
test_result = False
break

if test_result: # All numbers are the same
self.print_result('success')
Expand Down
14 changes: 12 additions & 2 deletions workspace_tools/host_tests/stdio_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ def run(self):
test_result = True

# Let's wait for Mbed to print its readiness, usually "{{start}}"
c = self.mbed.serial_read(16)
if self.mbed.serial_timeout(None) is None:
self.print_result("ioerr_serial")
return

c = self.mbed.serial_read(len('{{start}}'))
if c is None:
self.print_result("ioerr_serial")
return
print c
stdout.flush()

if self.mbed.serial_timeout(1) is None:
self.print_result("ioerr_serial")
return

for i in range(1, 5):
random_integer = random.randint(-99999, 99999)
Expand Down Expand Up @@ -60,7 +70,7 @@ def run(self):
stdout.flush()
break
else:
print "Error: No IP and port information sent from server"
print "Error: No data from MUT sent"
self.print_result('error')
exit(-2)

Expand Down
19 changes: 19 additions & 0 deletions workspace_tools/host_tests/tcpecho_client_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import socket
from host_test import Test
from sys import stdout
from time import sleep

SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
SERVER_PORT = 7
Expand All @@ -31,7 +32,25 @@ def __init__(self):
def send_server_ip_port(self, ip_address, port_no):
print "Resetting target..."
self.mbed.reset()

# Let's wait for Mbed to print its readiness, usually "{{start}}"
if self.mbed.serial_timeout(None) is None:
self.print_result("ioerr_serial")
return

c = self.mbed.serial_read(len('TCPCllient waiting for server IP and port...'))
if c is None:
self.print_result("ioerr_serial")
return
print c
stdout.flush()

if self.mbed.serial_timeout(1) is None:
self.print_result("ioerr_serial")
return

print "Sending server IP Address to target..."
stdout.flush()
connection_str = ip_address + ":" + str(port_no) + "\n"
self.mbed.serial_write(connection_str)

Expand Down
17 changes: 17 additions & 0 deletions workspace_tools/host_tests/udpecho_client_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ def __init__(self):
def send_server_ip_port(self, ip_address, port_no):
print "Resetting target..."
self.mbed.reset()

# Let's wait for Mbed to print its readiness, usually "{{start}}"
if self.mbed.serial_timeout(None) is None:
self.print_result("ioerr_serial")
return

c = self.mbed.serial_read(len('UDPCllient waiting for server IP and port...'))
if c is None:
self.print_result("ioerr_serial")
return
print c
stdout.flush()

if self.mbed.serial_timeout(1) is None:
self.print_result("ioerr_serial")
return

print "Sending server IP Address to target..."
connection_str = ip_address + ":" + str(port_no) + "\n"
self.mbed.serial_write(connection_str)
Expand Down
14 changes: 7 additions & 7 deletions workspace_tools/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ def run_host_test(self, name, disk, port, duration, reset=None, reset_tout=None,

if verbose:
print "Executing '" + " ".join(cmd) + "'"
print "Test::Output::Start"

proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS)
obs = ProcessObserver(proc)
Expand All @@ -813,7 +814,8 @@ def run_host_test(self, name, disk, port, duration, reset=None, reset_tout=None,

if c:
output.append(c)
sys.stdout.write(c)
if verbose:
sys.stdout.write(c)
# Give the mbed under test a way to communicate the end of the test
if c in ['\n', '\r']:
if '{end}' in line:
Expand All @@ -829,15 +831,13 @@ def run_host_test(self, name, disk, port, duration, reset=None, reset_tout=None,

if c:
output.append(c)
sys.stdout.write(c)
# Stop test process
obs.stop()
if verbose:
sys.stdout.write(c)

# Handle verbose mode
if verbose:
print "Test::Output::Start"
print "".join(output)
print "Test::Output::Finish"
# Stop test process
obs.stop()

# Parse test 'output' data
result = self.TEST_RESULT_TIMEOUT
Expand Down
2 changes: 1 addition & 1 deletion workspace_tools/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@
{
"id": "NET_13", "description": "TCP client echo loop",
"source_dir": join(TEST_DIR, "net", "echo", "tcp_client_loop"),
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB],
"automated": True,
"duration": 15,
"host_test": "tcpecho_client_auto",
Expand Down

0 comments on commit f9e7f69

Please sign in to comment.