TC and UDP client updates. Added automation information to test suite. Added new peripherial: 'ethernet'

pull/216/head
Przemek Wirkus 2014-03-17 17:39:24 +00:00
parent b345a189cf
commit 47a8df4b51
4 changed files with 46 additions and 34 deletions

View File

@ -14,7 +14,6 @@ int main() {
char out_buffer[] = "Hello World\n"; char out_buffer[] = "Hello World\n";
char out_success[] = "{{success}}\n{{end}}\n"; char out_success[] = "{{success}}\n{{end}}\n";
char out_failure[] = "{{failure}}\n{{end}}\n"; char out_failure[] = "{{failure}}\n{{end}}\n";
s_ip_address ip_addr = {0, 0, 0, 0}; s_ip_address ip_addr = {0, 0, 0, 0};
int port = 0; int port = 0;
@ -25,7 +24,7 @@ int main() {
EthernetInterface eth; EthernetInterface eth;
eth.init(); //Use DHCP eth.init(); //Use DHCP
eth.connect(); eth.connect();
printf("TCPClient IP Address is %s\r\n", eth.getIPAddress()); printf("TCPClient IP Address is %s\r\n", eth.getIPAddress());
sprintf(buffer, "%d.%d.%d.%d", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4); sprintf(buffer, "%d.%d.%d.%d", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4);

View File

@ -32,34 +32,34 @@ int main() {
CHECK(rc, "connect"); CHECK(rc, "connect");
printf("IP: %s\n", eth.getIPAddress()); printf("IP: %s\n", eth.getIPAddress());
UDPSocket sock; UDPSocket socket;
rc = sock.init(); rc = socket.init();
CHECK(rc, "sock init"); CHECK(rc, "socket init");
printf("UDPClient IP Address is %s\r\n", eth.getIPAddress()); printf("UDPClient IP Address is %s\r\n", eth.getIPAddress());
sprintf(buffer, "%d.%d.%d.%d", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4); sprintf(buffer, "%d.%d.%d.%d", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4);
Endpoint echo_server; Endpoint echo_server;
rc = echo_server.set_address(buffer, port); rc = echo_server.set_address(buffer, port);
CHECK(rc, "set_address"); CHECK(rc, "set_address");
rc = sock.sendTo(echo_server, out_buffer, sizeof(out_buffer)); rc = socket.sendTo(echo_server, out_buffer, sizeof(out_buffer));
CHECK(rc, "sendTo"); CHECK(rc, "sendTo");
int n = sock.receiveFrom(echo_server, buffer, sizeof(buffer)); int n = socket.receiveFrom(echo_server, buffer, sizeof(buffer));
CHECK(n, "receiveFrom"); CHECK(n, "receiveFrom");
if (n > 0) if (n > 0)
{ {
buffer[n] = '\0'; buffer[n] = '\0';
printf("%s", buffer); printf("%s", buffer);
if (strncmp(out_buffer, buffer, sizeof(out_buffer) - 1) == 0) { if (strncmp(out_buffer, buffer, sizeof(out_buffer) - 1) == 0) {
sock.sendTo(echo_server, out_success, sizeof(out_success) - 1); socket.sendTo(echo_server, out_success, sizeof(out_success) - 1);
} }
} }
sock.sendTo(echo_server, out_failure, sizeof(out_failure) - 1); socket.sendTo(echo_server, out_failure, sizeof(out_failure) - 1);
sock.close(); socket.close();
eth.disconnect(); eth.disconnect();
return 0; return 0;
} }

View File

@ -30,15 +30,14 @@ class StdioTest(DefaultTest):
print "\n{%s}\n{end}" % result print "\n{%s}\n{end}" % result
def run(self): def run(self):
test_result = True test_result = True
for i in range(1, 5): for i in range(1, 5):
random_integer = random.randint(-10000, 10000) random_integer = random.randint(-10000, 10000)
print "Generated number: " + str(random_integer) print "Generated number: " + str(random_integer)
self.mbed.serial.write(str(random_integer) + "\n") self.mbed.serial.write(str(random_integer) + "\n")
serial_stdio_msg = "" serial_stdio_msg = ""
ip_msg_timeout = self.mbed.options.timeout ip_msg_timeout = self.mbed.options.timeout
start_serial_pool = time(); start_serial_pool = time();
while (time() - start_serial_pool) < ip_msg_timeout: while (time() - start_serial_pool) < ip_msg_timeout:

View File

@ -29,33 +29,33 @@ Wiring:
* Ground: * Ground:
* LPC1*: p1 * LPC1*: p1
* KL25Z: GND * KL25Z: GND
* Vout * Vout
* LPC1*: p40 * LPC1*: p40
* KL25Z: P3V3 * KL25Z: P3V3
* TMP102 (I2C): * TMP102 (I2C):
* LPC1*: (SDA=p28 , SCL=p27) * LPC1*: (SDA=p28 , SCL=p27)
* KL25Z: (SDA=PTC9, SCL=PTC8) * KL25Z: (SDA=PTC9, SCL=PTC8)
* digital_loop (Digital(In|Out|InOut), InterruptIn): * digital_loop (Digital(In|Out|InOut), InterruptIn):
* LPC1*: (p5 <-> p25 ) * LPC1*: (p5 <-> p25 )
* KL25Z: (PTA5<-> PTC6) * KL25Z: (PTA5<-> PTC6)
* NUCLEO_F103RB: (PC_6 <-> PB_8) * NUCLEO_F103RB: (PC_6 <-> PB_8)
* port_loop (Port(In|Out|InOut)): * port_loop (Port(In|Out|InOut)):
* LPC1*: (p5 <-> p25 ), (p6 <-> p26 ) * LPC1*: (p5 <-> p25 ), (p6 <-> p26 )
* KL25Z: (PTA5 <-> PTC6), (PTA4 <-> PTC5) * KL25Z: (PTA5 <-> PTC6), (PTA4 <-> PTC5)
* NUCLEO_F103RB: (PC_6 <-> PB_8), (PC_5 <-> PB_9) * NUCLEO_F103RB: (PC_6 <-> PB_8), (PC_5 <-> PB_9)
* analog_loop (AnalogIn, AnalogOut): * analog_loop (AnalogIn, AnalogOut):
* LPC1*: (p17 <-> p18 ) * LPC1*: (p17 <-> p18 )
* KL25Z: (PTE30 <-> PTC2) * KL25Z: (PTE30 <-> PTC2)
* SD (SPI): * SD (SPI):
* LPC1*: (mosi=p11 , miso=p12 , sclk=p13 , cs=p14 ) * LPC1*: (mosi=p11 , miso=p12 , sclk=p13 , cs=p14 )
* KL25Z: (mosi=PTD2, miso=PTD3, sclk=PTD1, cs=PTD0) * KL25Z: (mosi=PTD2, miso=PTD3, sclk=PTD1, cs=PTD0)
* MMA7660 (I2C): * MMA7660 (I2C):
* LPC1*: (SDA=p28 , SCL=p27) * LPC1*: (SDA=p28 , SCL=p27)
@ -255,7 +255,7 @@ TESTS = [
"source_dir": join(BENCHMARKS_DIR, "all"), "source_dir": join(BENCHMARKS_DIR, "all"),
"dependencies": [MBED_LIBRARIES] "dependencies": [MBED_LIBRARIES]
}, },
# Not automated MBED tests # Not automated MBED tests
{ {
"id": "MBED_1", "description": "I2C SRF08", "id": "MBED_1", "description": "I2C SRF08",
@ -267,6 +267,8 @@ TESTS = [
"id": "MBED_2", "description": "stdio", "id": "MBED_2", "description": "stdio",
"source_dir": join(TEST_DIR, "mbed", "stdio"), "source_dir": join(TEST_DIR, "mbed", "stdio"),
"dependencies": [MBED_LIBRARIES], "dependencies": [MBED_LIBRARIES],
"automated": True,
"host_test": "stdio_auto"
}, },
{ {
"id": "MBED_3", "description": "PortOut", "id": "MBED_3", "description": "PortOut",
@ -427,7 +429,7 @@ TESTS = [
"source_dir": join(TEST_DIR, "mbed", "pin_toggling"), "source_dir": join(TEST_DIR, "mbed", "pin_toggling"),
"dependencies": [MBED_LIBRARIES], "dependencies": [MBED_LIBRARIES],
}, },
# CMSIS RTOS tests # CMSIS RTOS tests
{ {
"id": "CMSIS_RTOS_1", "description": "Basic", "id": "CMSIS_RTOS_1", "description": "Basic",
@ -473,7 +475,7 @@ TESTS = [
"source_dir": join(TEST_DIR, "rtos", "cmsis", "isr"), "source_dir": join(TEST_DIR, "rtos", "cmsis", "isr"),
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES], "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES],
}, },
# mbed RTOS tests # mbed RTOS tests
{ {
"id": "RTOS_1", "description": "Basic", "id": "RTOS_1", "description": "Basic",
@ -521,7 +523,7 @@ TESTS = [
"source_dir": join(TEST_DIR, "rtos", "mbed", "file"), "source_dir": join(TEST_DIR, "rtos", "mbed", "file"),
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB, SD_FS, FAT_FS], "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB, SD_FS, FAT_FS],
}, },
# Networking Tests # Networking Tests
{ {
"id": "NET_1", "description": "TCP client hello world", "id": "NET_1", "description": "TCP client hello world",
@ -537,21 +539,33 @@ TESTS = [
"id": "NET_3", "description": "TCP echo server", "id": "NET_3", "description": "TCP echo server",
"source_dir": join(TEST_DIR, "net", "echo", "tcp_server"), "source_dir": join(TEST_DIR, "net", "echo", "tcp_server"),
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
"automated": True,
"host_test" : "tcpecho_server_auto",
"peripherals": ["ethernet"]
}, },
{ {
"id": "NET_4", "description": "TCP echo client", "id": "NET_4", "description": "TCP echo client",
"source_dir": join(TEST_DIR, "net", "echo", "tcp_client"), "source_dir": join(TEST_DIR, "net", "echo", "tcp_client"),
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
"automated": True,
"host_test": "tcpecho_client_auto",
"peripherals": ["ethernet"]
}, },
{ {
"id": "NET_5", "description": "UDP echo server", "id": "NET_5", "description": "UDP echo server",
"source_dir": join(TEST_DIR, "net", "echo", "udp_server"), "source_dir": join(TEST_DIR, "net", "echo", "udp_server"),
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
"automated": True,
"host_test" : "udpecho_server_auto",
"peripherals": ["ethernet"]
}, },
{ {
"id": "NET_6", "description": "UDP echo client", "id": "NET_6", "description": "UDP echo client",
"source_dir": join(TEST_DIR, "net", "echo", "udp_client"), "source_dir": join(TEST_DIR, "net", "echo", "udp_client"),
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
"automated": True,
"host_test" : "udpecho_client_auto",
"peripherals": ["ethernet"]
}, },
{ {
"id": "NET_7", "description": "HTTP client", "id": "NET_7", "description": "HTTP client",
@ -588,7 +602,7 @@ TESTS = [
"source_dir": join(TEST_DIR, "net", "echo", "tcp_client_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],
}, },
# u-blox tests # u-blox tests
{ {
"id": "UB_1", "description": "u-blox USB modem: HTTP client", "id": "UB_1", "description": "u-blox USB modem: HTTP client",
@ -640,21 +654,21 @@ TESTS = [
"source_dir": join(TEST_DIR, "usb", "device", "audio"), "source_dir": join(TEST_DIR, "usb", "device", "audio"),
"dependencies": [MBED_LIBRARIES, USB_LIBRARIES], "dependencies": [MBED_LIBRARIES, USB_LIBRARIES],
}, },
# CMSIS DSP # CMSIS DSP
{ {
"id": "CMSIS_DSP_1", "description": "FIR", "id": "CMSIS_DSP_1", "description": "FIR",
"source_dir": join(TEST_DIR, "dsp", "cmsis", "fir_f32"), "source_dir": join(TEST_DIR, "dsp", "cmsis", "fir_f32"),
"dependencies": [MBED_LIBRARIES, DSP_LIBRARIES], "dependencies": [MBED_LIBRARIES, DSP_LIBRARIES],
}, },
# mbed DSP # mbed DSP
{ {
"id": "DSP_1", "description": "FIR", "id": "DSP_1", "description": "FIR",
"source_dir": join(TEST_DIR, "dsp", "mbed", "fir_f32"), "source_dir": join(TEST_DIR, "dsp", "mbed", "fir_f32"),
"dependencies": [MBED_LIBRARIES, DSP_LIBRARIES], "dependencies": [MBED_LIBRARIES, DSP_LIBRARIES],
}, },
# KL25Z # KL25Z
{ {
"id": "KL25Z_1", "description": "LPTMR", "id": "KL25Z_1", "description": "LPTMR",
@ -688,7 +702,7 @@ TESTS = [
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA8451Q')], "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA8451Q')],
"mcu": ["KL25Z", "KL05Z", "KL46Z"], "mcu": ["KL25Z", "KL05Z", "KL46Z"],
}, },
# Examples # Examples
{ {
"id": "EXAMPLE_1", "description": "/dev/null", "id": "EXAMPLE_1", "description": "/dev/null",
@ -739,23 +753,23 @@ class Test:
self.n = n self.n = n
self.__dict__.update(Test.DEFAULTS) self.__dict__.update(Test.DEFAULTS)
self.__dict__.update(TESTS[n]) self.__dict__.update(TESTS[n])
def is_supported(self, target, toolchain): def is_supported(self, target, toolchain):
if hasattr(self, 'mcu') and not target in self.mcu: if hasattr(self, 'mcu') and not target in self.mcu:
return False return False
if not hasattr(self, 'supported'): if not hasattr(self, 'supported'):
return True return True
return (target in self.supported) and (toolchain in self.supported[target]) return (target in self.supported) and (toolchain in self.supported[target])
def get_description(self): def get_description(self):
if hasattr(self, 'description'): if hasattr(self, 'description'):
return self.description return self.description
else: else:
return self.id return self.id
def __cmp__(self, other): def __cmp__(self, other):
return cmp(self.n, other.n) return cmp(self.n, other.n)
def __str__(self): def __str__(self):
return "[%3d] %s: %s" % (self.n, self.id, self.get_description()) return "[%3d] %s: %s" % (self.n, self.id, self.get_description())