Dependencies:   ros_lib_kinetic

Revision:
22:82871f00f89d
Parent:
21:0b10d8e615d1
Child:
23:61526647cc8a
--- a/LLComms.cpp	Tue Dec 11 15:45:01 2018 +0000
+++ b/LLComms.cpp	Wed Dec 12 08:41:06 2018 +0000
@@ -67,18 +67,17 @@
     //pinTesty = 1;
     int intPosSPI_Rx[N_CHANNELS]; // 13 bit value received over SPI from the actuator
     
+    mutChannel[channel].lock(); // Lock mutex for specific Channel
     // Get data from controller
     if( channel < 4 ) {
         spi_0.format(16,2); // !! Can probably move to constructor 
         spi_0.frequency(LOW_LEVEL_SPI_FREQUENCY);
-        mutChannel[channel].lock(); // Lock mutex for specific Channel
         *cs_LL[channel] = 0; // Select relevant chip
         intPosSPI_Rx[channel] = spi_0.write(demandPosition[channel]); // Transmit & receive
         *cs_LL[channel] = 1; // Deselect chip
     } else {
         spi_1.format(16,2); // !! Can probably move to constructor 
         spi_1.frequency(LOW_LEVEL_SPI_FREQUENCY);
-        mutChannel[channel].lock(); // Lock mutex for specific Channel
         *cs_LL[channel] = 0; // Select relevant chip
         intPosSPI_Rx[channel] = spi_1.write(demandPosition[channel]); // Transmit & receive
         *cs_LL[channel] = 1; // Deselect chip
@@ -95,8 +94,6 @@
     intPosSPI_Rx[channel] = intPosSPI_Rx[channel] & 0x1FFF;
     //dblPosition_mtrs[channel] = (double)intPosSPI_Rx[channel]/8191*(MAX_ACTUATOR_LENGTH/DBL_ACTUATOR_CONVERSION[channel])/1000;
     mutChannel[channel].unlock();//unlock mutex for specific channel
-    //if(IS_PRINT_OUTPUT) printf("%d, %d\r\n",intPosSPI_Rx[0],_intDemandPos_Tx[0]);
-    //pinTesty = 0;
 }
 
 // Common rise handler function