RobOmega - PSL RoboCup / Mbed 2 deprecated nRF24L01P_SerialToBoard_L475VG

Dependencies:   mbed nRF24L01P

Revision:
8:05427ba764a9
Parent:
7:7aec575dd541
Child:
9:557b85b94a89
--- a/main.cpp	Fri Dec 11 08:46:30 2020 +0000
+++ b/main.cpp	Fri Dec 11 09:07:00 2020 +0000
@@ -66,26 +66,22 @@
     while (1) 
     {
         //Send "Hello PC" to the PC board
+        if ( pc.readable() ) {
 
-        // add datas to the transmit buffer
-        txData[txDataCnt++] = data[i++];
-        
-        pc.printf("%d", i);
-        
-        if (i >= dataSize)
-        {
-            i = 0;
+            // ...add it to the transmit buffer
+            txData[txDataCnt++] = pc.getc();
 
-        }
-        // If the transmit buffer is full
-        if ( txDataCnt >= sizeof( txData ) ) {
-
-            // Send the transmitbuffer via the nRF24L01+
-            my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt );
-
-            txDataCnt = 0;
-        }
-
+        
+        
+            // If the transmit buffer is full
+            if ( txDataCnt >= sizeof( txData ) ) {
+    
+                // Send the transmitbuffer via the nRF24L01+
+                my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt );
+    
+                txDataCnt = 0;
+            }
+    }
         // Toggle LED1 (to help debug Host -> nRF24L01+ communication)
         myled1 = !myled1;
     }