Skip to content

Commit

Permalink
Added extraction of temperature and error message
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidGeek committed Nov 28, 2018
1 parent 9fc9791 commit 87a2552
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library.properties
@@ -1,5 +1,5 @@
name=VescUart
version=1.0.0
version=1.0.1
author=SolidGeek
maintainer=SolidGeek
sentence=Library offering UART communication for VESC
Expand Down
7 changes: 6 additions & 1 deletion src/VescUart.cpp
Expand Up @@ -184,7 +184,8 @@ bool VescUart::processReadPacket(uint8_t * message) {
switch (packetId){
case COMM_GET_VALUES: // Structure defined here: https://github.com/vedderb/bldc/blob/43c3bbaf91f5052a35b75c2ff17b5fe99fad94d1/commands.c#L164

ind = 4; // Skip the first 4 bytes
data.tempMosfet = buffer_get_float16(message, 10.0, &ind);
data.tempMotor = buffer_get_float16(message, 10.0, &ind);
data.avgMotorCurrent = buffer_get_float32(message, 100.0, &ind);
data.avgInputCurrent = buffer_get_float32(message, 100.0, &ind);
ind += 8; // Skip the next 8 bytes
Expand All @@ -196,6 +197,7 @@ bool VescUart::processReadPacket(uint8_t * message) {
ind += 8; // Skip the next 8 bytes
data.tachometer = buffer_get_int32(message, &ind);
data.tachometerAbs = buffer_get_int32(message, &ind);
data.error = message[ind];
return true;

break;
Expand Down Expand Up @@ -316,5 +318,8 @@ void VescUart::printVescValues() {
debugPort->print("ampHoursCharges: "); debugPort->println(data.ampHoursCharged);
debugPort->print("tachometer: "); debugPort->println(data.tachometer);
debugPort->print("tachometerAbs: "); debugPort->println(data.tachometerAbs);
debugPort->print("tempMosfet: "); debugPort->println(data.tempMosfet);
debugPort->print("tempMotor: "); debugPort->println(data.tempMotor);
debugPort->print("error: "); debugPort->println(data.error);
}
}
3 changes: 3 additions & 0 deletions src/VescUart.h
Expand Up @@ -19,6 +19,9 @@ class VescUart
float ampHoursCharged;
long tachometer;
long tachometerAbs;
float tempMosfet;
float tempMotor;
mc_fault_code error;
};

/** Struct to hold the nunchuck values to send over UART */
Expand Down

0 comments on commit 87a2552

Please sign in to comment.