load testing EthernetInterface

Dependencies:   EthernetInterface mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Fri Jan 17 09:12:56 2014 +0000
Child:
1:321b8f934993
Commit message:
1st build

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Fri Jan 17 09:12:56 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 17 09:12:56 2014 +0000
@@ -0,0 +1,76 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "EthernetInterface.h"
+
+Serial pc(USBTX, USBRX);
+DigitalOut myled(LED1);
+EthernetInterface eth;
+
+volatile int count = 0, num = 0, reset = 0;
+volatile int ref = 0, refreset = 0; // no rtos = 8727224
+
+extern "C"
+void os_idle_demon (void) {
+    for (;;) {
+        if (reset) {
+            count = 0;
+            reset = 0;
+        } else {
+            count ++;
+        }
+    }
+}
+
+void isr_timer () {
+    num = count;
+    reset = 1;
+    refreset = 1;
+    myled = 1;
+}
+
+void real_count (void const *args) {
+    while (!refreset);
+    refreset = 0;
+    for (;;) {
+        if (refreset) {
+            count = 0;
+            refreset = 0;
+            break;
+        } else {
+            ref ++;
+        }
+    }
+}
+
+int main() {
+    Ticker timer;
+
+    pc.baud(115200);
+    pc.printf("LOAD TESTING\r\n");
+    pc.printf("system clock: %d\r\n", SystemCoreClock);
+
+    timer.attach(&isr_timer, 1);
+
+    pc.printf("wait...\r\n");
+    Thread thread(real_count, NULL, osPriorityRealtime);
+    while (! ref);
+    pc.printf("reference count: %d / sec\r\n", ref);
+
+    pc.printf("ethernet...\r\n");
+    eth.init(); //Use DHCP
+    if (eth.connect()) {
+        pc.printf("error\r\n");
+        return -1;
+    }
+    pc.printf("IP: %s\r\n", eth.getIPAddress());
+
+    num = 0;
+    for (;;) {
+        if (num) {
+            pc.printf("idle count: %d / sec (%0.1f %%)\r\n", num, (float)num / ref * 100);
+            num = 0;
+            myled = 0;
+        }
+        Thread::wait(100);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Jan 17 09:12:56 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/okini3939/code/mbed-rtos/#0a6b48963081
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jan 17 09:12:56 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43
\ No newline at end of file