Has base BMU code but sends dummy temperature and voltage readings to test CAN

Dependencies:   CUER_CAN DS1820 LTC2943 LTC6804 mbed

Fork of BMS_BMUCore_Max by CUER

Revision:
14:e0e88a009f4c
Parent:
13:7b42af989cd1
--- a/CANParserBMU.cpp	Wed Jun 28 16:56:33 2017 +0000
+++ b/CANParserBMU.cpp	Sun Jul 02 01:45:39 2017 +0000
@@ -9,21 +9,29 @@
 /**
 * This function is rewritten to give readings for individual probes rather than
 * for specific CMU. As a consequence, 0x800 onwards is being used for these probes,
-* as everything above about 0x700 is unused by the Tritium standard. Additionally,
-* instead of using uint16, floats will be used since only one temperature reading
-* is needed per message, allowing 32 bits per reading, and float is the natural
-* type obtained by the sensor.
+* as everything above about 0x700 is unused by the Tritium standard. The ID value
+* for the probe is based on the ROM field of DS1820, entries 1-6 being the unique
+* serial value.
 */
-CANMessage createTemperatureTelemetry(uint8_t offset, uint32_t ProbeID, float Temperature)
+CANMessage createTemperatureTelemetry(uint8_t offset, char ProbeROM[8], float Temperature)
 {
     CANMessage msg;
     msg.len = 8;
     msg.id = TEMPERATURE_BASE_ID + offset; // for temp it is 0x800 onwards
     CAN_Data data;
 
-    data.setLower_uLong(ProbeID);
-    data.setUpperFloat(Temperature);
+    //data.setLower_uLong(ProbeID);
+    //data.setUpperFloat(Temperature);
 
+    for(int i = 1; i <= 6; i++) //ID portion of ROM array
+    {
+        data.set_u8(i - 1, ProbeROM[i]);
+    }
+    //Conversion of float to a short, requires multiplying by 100 to not lose precision
+    float temp100 = Temperature * 100;
+    short shortTemp = (short) temp100;
+    data.set_16(3, shortTemp);//There seems to be an error in the function definition for set_16, (ushort instead of short)
+    
     for (int i = 0; i<8; i++) {
         msg.data[i] = data.get_u8(i);
     }
@@ -33,6 +41,7 @@
 /**
 * Takes a CANMessage with precondition that it stores temperature of an individual
 * probe and returns an individual_temperature object containing ID and reading.
+* The ID is stores in ROM array entry 1-6, other entries may be invalid.
 */
 individual_temperature decodeTemperatureTelemetry(CANMessage msg)
 {
@@ -40,8 +49,13 @@
     CAN_Data decode;
     
     decode.importCANData(msg);
-    probe_reading.measurement = decode.getUpperFloat();
-    probe_reading.ID = decode.getLower_uLong();
+    short shortTemp = decode.get_16(3);
+    probe_reading.measurement = ((float)shortTemp) / 100;
+    
+    for(int i = 1; i <=6; i++)
+    {
+        probe_reading.ROMID[i] = decode.get_u8(i-1);    
+    }
     
     return probe_reading;
 }