 
     return(current_data);
   }
-
+}
+
+//****************
+// CAN DATA READ
+//****************
+void CANDataRead()
+{
+  unsigned char len = 0;
+  unsigned char buf[8];
+
+  if(CAN_MSGAVAIL == CAN.checkReceive())            // check if data coming
+  {
+    CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf
+    unsigned int canId = CAN.getCanId();
+
+    switch (canId) 
+    {        
+      case 0x381:
+        Serial.println("-----------------------------");
+        Serial.print("POSICAO");
+        Serial.println(canId, HEX);
+
+        for(int i = 0; i<len; i++)    // print the data
+        {
+            Serial.print(buf[i], HEX);
+            Serial.print("\t");
+        }
+        Serial.println();
+        break;
+      case 0x321:
+        Serial.println("-----------------------------");
+        Serial.print("AMPLIFICACAO");
+        Serial.println(canId, HEX);
+
+        for(int i = 0; i<len; i++)    // print the data
+        {
+            Serial.print(buf[i], HEX);
+            Serial.print("\t");
+        }
+        Serial.println();
+        break;
+      case 0x181:
+        Serial.println("-----------------------------");
+        Serial.print("CORRENTE");
+        Serial.println(canId, HEX);
+
+        for(int i = 0; i<len; i++)    // print the data
+        {
+            Serial.print(buf[i], HEX);
+            Serial.print("\t");
+        }
+        Serial.println();
+        break;
+    }
+  }
 }
 
 void loop()

  }
}

float currentDataRead()
{
  current_data = 0;
  unsigned char len = 0;
  unsigned char buf[8];

// clear the string:
  sync();

  if (CAN_MSGAVAIL == CAN.checkReceive())           // check if data coming

    loadcell_data = loadcell_data | buf[2];
    loadcell_data <<= 8;
    loadcell_data = loadcell_data | buf[3];
    //
    //    if (buf[1] >= 128) {
    //           loadcell_data = loadcell_data - 16777216;
    //    }

    loadcell_data_double = loadcell_data;
    //  loadcell_data_double = loadcell_data_double-4294000000;

    //    Serial.print("Encoder: ");
    //    Serial.println(encoder_data, DEC);

     Serial.print("Loadcell: ");
     Serial.println(loadcell_data_double);
