FBRLogger final version

Dependencies:   EthernetInterface MSCAN Nanopb SDFileSystem mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
veskokaradzhov
Date:
Wed Mar 06 17:34:00 2013 +0000
Parent:
8:99cca8c964e6
Child:
10:9a743e7cf78e
Commit message:
bug fixed, function receive() moved to public

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
MSCAN.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
--- a/EthernetInterface.lib	Fri Mar 01 12:43:17 2013 +0000
+++ b/EthernetInterface.lib	Wed Mar 06 17:34:00 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#dd9794ce1d64
+http://mbed.org/users/mbed_official/code/EthernetInterface/#0a2ab74b1337
--- a/MSCAN.lib	Fri Mar 01 12:43:17 2013 +0000
+++ b/MSCAN.lib	Wed Mar 06 17:34:00 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/intrinseca/code/MSCAN/#55a074984183
+http://mbed.org/users/intrinseca/code/MSCAN/#c857749f9c0c
--- a/main.cpp	Fri Mar 01 12:43:17 2013 +0000
+++ b/main.cpp	Wed Mar 06 17:34:00 2013 +0000
@@ -25,7 +25,8 @@
 #define ACCEL_SENSITIVITY   (0.312 * ACCEL_SCALE) / ANALOG_SCALE
 
 State car;
-CAN* can;
+
+CANComms can(&car, false, false, 0.0);
 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
 
 EthernetInterface eth;
@@ -143,7 +144,7 @@
                 client.send_all(net_buf, net_buf_len);
             }
             led3 = !led3;
-            
+
             //printf("Net Buf Emptied, %d messages\n", buf_msg_count);
             logFile->write(net_buf, net_buf_len);
             logFile->fsync();
@@ -168,38 +169,8 @@
     printf("CAN Thread Running\n");
 
     while(true) {
-        while(can->read(msg)) {
-            /*printf("CAN Message %08X %d %02X%02X%02X%02X%02X%02X%02X%02X\n", msg.id, msg.len,
-                msg.data[0],
-                msg.data[1],
-                msg.data[2],
-                msg.data[3],
-                msg.data[4],
-                msg.data[5],
-                msg.data[6],
-                msg.data[7]
-                );*/
-
-            header.parse(msg.id);
-
-            //printf("Processing data, block %d\n", block);
-
-            if(header.from_id == MSCAN_ID_MS) {
-                if(header.var_blk == 0) {
-                    car.rpm = (msg.data[0] << 8) | msg.data[1];
-                } else if(header.var_blk == 1) {
-                    car.manifold_pres = ((msg.data[2] << 8) | msg.data[3]) / 10.0;
-                    car.air_temp = (((msg.data[4] << 8) | msg.data[5]) - 320.0) * 0.05555;
-                    car.coolant_temp = (((msg.data[6] << 8) | msg.data[7]) - 320.0) * 0.05555;
-                }
-                else {
-                    car.throttle_pos = ((msg.data[0] << 8) | msg.data[1]) / 10.0;
-                    car.voltage = ((msg.data[2] << 8) | msg.data[3]) / 10.0;
-                }
-            }
-        }
-        
-        Thread::wait(1);
+        can.receive();
+       
     }
 }
 
@@ -218,12 +189,12 @@
 
     sprintf(&logFileName[0], "fbr/log.%d", logIndex - 1);
     printf("Log File: %s\n", &logFileName[0]);
-    
+
     logFile = sd.open(logFileName, O_WRONLY | O_CREAT);
     logFile->fsync();
     //fprintf(logFile, "FBR CANBUS Log File\n");
     //fclose(logFile);
-            
+
     eth.init("192.168.0.2", "255.255.255.0", "0.0.0.0");
     eth.connect(1000);
 
@@ -236,17 +207,14 @@
     can_thread = new Thread(can_thread_start, NULL, osPriorityLow, 4096);
     sample_timer.start(10);
 
-    
-    can = new CAN(p30, p29);
-    can->frequency(500000);
-    //can->attach(&can_receive_isr); 
-    printf("Can ISR Attached");
+
+   
 
     printf("Ready to Log\n");
 
     TCPSocketConnection temp;
 
-    while (true) {
+    while (true) {                                   // accept net connection
         printf("\nWait for new connection...\n");
         server.accept(temp);