u-blox / Mbed 2 deprecated C027_ProductionTestLoobback

Dependencies:   C027 mbed

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Tue Nov 19 16:00:33 2013 +0000
Commit message:
loopback ETH/CAN helper for Production Test Sw

Changed in this revision

C027.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.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C027.lib	Tue Nov 19 16:00:33 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/ublox/code/C027/#fb30e9923a7b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 19 16:00:33 2013 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "C027.h"
+
+#define NL      "\r\n"
+#define T_RETRY 1
+
+int main() {
+    C027 c027;
+    Serial pc(USBTXD, USBRXD); 
+    pc.baud(115200);
+    
+    CAN can(CANRD, CANTD);
+    can.frequency(500000);
+    DigitalOut canS(CANS);
+    canS = 0;
+    CANMessage msg;
+    
+    Ethernet eth;
+    bool ethLink = false;
+    int len;
+    
+    printf(NL NL);
+    printf("TestVer = \"" __DATE__ " " __TIME__ "\"" NL);
+     
+    while (1)
+    {
+        if (can.read(msg))
+        {
+            printf("Can: id %03X, len %d, data \"%.*s\"" NL, msg.id, msg.len, msg.len, msg.data);
+            can.write(msg);
+        }
+        bool link = eth.link();
+        if (ethLink ^ link)
+        {
+            printf("Eth: link %s" NL, link ? "OK" : "ERROR");
+            ethLink = link;
+        }
+        if (link && ((len = eth.receive()) > 0))
+        {
+            char data[256];
+            len = eth.read(data,len);
+            printf("Eth: len %d, data \"%.*s\"" NL, len, len, data);
+            eth.write(data, len);
+            eth.send();
+        }
+        wait_ms(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 19 16:00:33 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file