         // }
         // Serial.println();
         break;
+
+      // ID 321 message has information sent by the amplification board
       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();
-        encoder_data = buf[4];
-        encoder_data <<= 8;
-        encoder_data = encoder_data | buf[5];
+        encoderDataRead();
 
         // // load cell information is read from buf[1], buf[2] and buf[3] and converted to decimal
         loadcell_data = buf[1];

}

//******************************
// CURRENT DATA READ
//******************************
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
  {
    CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf

    unsigned int canId = CAN.getCanId();
    
    Serial.print("Current: ");
    
      for(int i = 0; i<len; i++)    // print the data
        {
            Serial.print(buf[i], HEX);
            Serial.print("\t");
        }
    Serial.println();

    current_data = buf[2];
    current_data <<= 8;
    current_data = current_data | buf[3];
    // current_data <<= 8;
    // current_data = current_data | buf[6];
    // current_data <<= 8;
    // current_data = current_data | buf[7];

    // Serial.println(current_data);

    return(current_data);
  }
}

//****************

//        Serial.println(loadcell_data);

//
        break;
      }
      // return(encoder_data);
  }
}

