Official support library for using mbed as a programmable coprocessor in the Innomatix DAP-III+ telematics platform

Revision:
4:fd93c4cb05df
Parent:
0:b9e1003fbee7
Child:
10:5fbe72ffb725
--- a/example.cpp	Sun Apr 17 15:51:59 2016 +0000
+++ b/example.cpp	Wed Sep 28 19:53:11 2016 +0000
@@ -69,7 +69,6 @@
 void ExampleInit()
 {
     /*-----------------------------------------------*/
-    // DataStoreInit params are not used by the MBED implementation
     eRDSReady = DataStoreInit( "usb", 0 );
     printf( "Innomatix RemoteDataStore API initialization: %s\r\n", (rdsSuccess == eRDSReady ? "INITIALIZED" : "FAILED") );
 
@@ -82,10 +81,10 @@
         Press2Bin = GetDBinInfo( Press2BinName );
         Press3Bin = GetDBinInfo( Press3BinName );
         Press4Bin = GetDBinInfo( Press4BinName );
-    }    
+    }
 
- 
- 
+
+
  	unsigned long can_baud = 500000;
     /*-----------------------------------------------*/
     // Params are: channel enum, baud rate
@@ -99,7 +98,7 @@
     // Pause a moment to let all the CAN init stuff take effect, else
     // sometimes we dont receive the first message on the bus
     wait_ms( 100 );
-    
+
 }
 /*************************************************************************/
 void ExampleClose()
@@ -115,26 +114,26 @@
 {
     char str[ 128 ] = {0};
     unsigned long count = 0;
-    
+
 	DigitalOut rxled(LED1);		// RX activity toggle
 	DigitalOut rxeled(LED2);	// RX error (overrun) toggle
     DigitalOut txled(LED3);		// TX activity toggle
     DigitalOut txeled(LED4);	// TX error toggle
 
-    
+
     /*-----------------------------------------------*/
     CanResults_e canresult;
     unsigned char msgbuff[ 8 ] = {0};
     unsigned long msgid;
     char msglen;
-    CanFormat_e msgformat;    
+    CanFormat_e msgformat;
 	unsigned long timestamp;
 
     unsigned char txbuff[ 8 ] = {0};
     unsigned short pressure = 0;
-    
+
     Timer  TxTimer;
-    
+
 
     /*-----------------------------------------------*/
     // Init the Support Library subsystems we'll use for this example
@@ -155,8 +154,8 @@
     //
     // The coprocessor example is a CAN network bridge
     //
-    // We will receive messages on CAN3 representing the air pressure in four tires.  
-    // The four pressure values are published to the remote data store individually, 
+    // We will receive messages on CAN3 representing the air pressure in four tires.
+    // The four pressure values are published to the remote data store individually,
     // and are combined into a single message which is transmitted on CAN4 at 1Hz
     //
     // CAN3 messages are ID 0x101, 0x102, 0x103, 0x104
@@ -165,7 +164,7 @@
     // CAN4 message is ID 0x200
     // Data in the CAN4 message are the same 2-byte values in order
     //
-    
+
     TxTimer.start();
     while( 1 )
     {
@@ -178,7 +177,7 @@
         {
             //printf( "Got CAN message x%0x\r\n", msgid );
             rxled = !rxled;
-            
+
             // if the message is one we are interested in
             if( 0x100 == msgid )
             {
@@ -187,7 +186,7 @@
                 txbuff[ 0 ] = msgbuff[ 0 ];
                 txbuff[ 1 ] = msgbuff[ 1 ];
 
-                // Assemble the 2 bytes into a 2-byte value and publish 
+                // Assemble the 2 bytes into a 2-byte value and publish
                 // to the remote data store
                 pressure = (msgbuff[ 0 ] << 8) + msgbuff[ 1 ];
                 PutUnsignedInteger( Press1Bin, pressure );
@@ -212,12 +211,14 @@
                 txbuff[ 7 ] = msgbuff[ 1 ];
                 pressure = (msgbuff[ 0 ] << 8) + msgbuff[ 1 ];
                 PutUnsignedInteger( Press4Bin, pressure );
-            }            
+            }
         }else if( canNoData != canresult )
         {
-        	printf( "CanReceive() error %d\r\n", canresult );
+        	sprintf( str, "CanReceive() error %d", canresult );
+		    PutString( StatusBin, str );
+		    printf( "%s\r\n", str );
         }
-        
+
 	    /*-----------------------------------------------*/
 		// detect receive overruns - this means CAN messages are arrving faster
 		// than the application is reading them via CanReceive()
@@ -229,7 +230,7 @@
 		    CanStatistics( canChDAP3, &Stats );
 		    if( Stats.OverflowCount > 0 && Stats.OverflowCount != overflow )
 		    {
-				rxeled = !rxeled;		    	
+				rxeled = !rxeled;
 				overflow = Stats.OverflowCount;
 				// publish the overflow count to the RDS
 				sprintf( str, "CAN3 OVF: %d", overflow );
@@ -240,22 +241,25 @@
 
 
         /*-----------------------------------------------*/
-        // send the combined pressure message once per second
-        if( TxTimer.read_ms() >= 1000 )
+        // send the combined pressure message at 5Hz
+        if( TxTimer.read_ms() >= 200 )
         {
             txled = !txled;
 
             canresult = CanSend( canChDAP4, 0x200, canFormatStandard, txbuff, 8 );
             if( canSuccess != canresult )
             {
-                printf( "CanSend() error %d\r\n", canresult );
+                sprintf( str, "CanSend() error %d", canresult );
+			    PutString( StatusBin, str );
+			    printf( "%s\r\n", str );
+
                 txeled = !txeled;
 			}
 
 			// Also publish the loop count to the remote data store "debug" data bin
 		    sprintf( str, "PCop Loop %d", count );
 		    PutDebug( str );
-            
+
 			// And restart the timer at 0
             TxTimer.reset();
         }