mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Fixes warnings thrown by cpplint.py (#154)
* Fixed cpplint.py [runtime/int] warnings * Fixed cpplint.py [readability/casting] warnings * Fixed cpplint.py [readability/namespace] warnings * Fixed cpplint.py [readability/braces] warnings * Fixed cpplint.py [whitespace/braces] warnings * Fixed cpplint.py [runtime/explicit] warnings * Fixed cpplint.py [runtime/printf] warnings * Fixed cpplint.py [readability/inheritance] warnings * Fixed cpplint.py [whitespace/tab] warnings * Fixed cpplint.py [build/storage_class] warnings * Fixed cpplint.py [readability/multiline_comment] warnings * Fixed cpplint.py [whitespace/semicolon] warnings * Fixed cpplint.py [readability/check] warnings * Fixed cpplint.py [runtime/arrays] warnings * Ran format.py
This commit is contained in:
committed by
Peter Johnson
parent
e44a6e227a
commit
0cb288ffba
@@ -343,58 +343,58 @@ void CANJaguar::PIDWrite(float output) {
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packPercentage(uint8_t* buffer, double value) {
|
||||
int16_t intValue = (int16_t)(value * 32767.0);
|
||||
*((int16_t*)buffer) = swap16(intValue);
|
||||
int16_t intValue = static_cast<int16_t>(value * 32767.0);
|
||||
*reinterpret_cast<int16_t*>(buffer) = swap16(intValue);
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packFXP8_8(uint8_t* buffer, double value) {
|
||||
int16_t intValue = (int16_t)(value * 256.0);
|
||||
*((int16_t*)buffer) = swap16(intValue);
|
||||
int16_t intValue = static_cast<int16_t>(value * 256.0);
|
||||
*reinterpret_cast<int16_t*>(buffer) = swap16(intValue);
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packFXP16_16(uint8_t* buffer, double value) {
|
||||
int32_t intValue = (int32_t)(value * 65536.0);
|
||||
*((int32_t*)buffer) = swap32(intValue);
|
||||
int32_t intValue = static_cast<int32_t>(value * 65536.0);
|
||||
*reinterpret_cast<int32_t*>(buffer) = swap32(intValue);
|
||||
return sizeof(int32_t);
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packint16_t(uint8_t* buffer, int16_t value) {
|
||||
*((int16_t*)buffer) = swap16(value);
|
||||
*reinterpret_cast<int16_t*>(buffer) = swap16(value);
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packint32_t(uint8_t* buffer, int32_t value) {
|
||||
*((int32_t*)buffer) = swap32(value);
|
||||
*reinterpret_cast<int32_t*>(buffer) = swap32(value);
|
||||
return sizeof(int32_t);
|
||||
}
|
||||
|
||||
double CANJaguar::unpackPercentage(uint8_t* buffer) const {
|
||||
int16_t value = *((int16_t*)buffer);
|
||||
int16_t value = *reinterpret_cast<int16_t*>(buffer);
|
||||
value = swap16(value);
|
||||
return value / 32767.0;
|
||||
}
|
||||
|
||||
double CANJaguar::unpackFXP8_8(uint8_t* buffer) const {
|
||||
int16_t value = *((int16_t*)buffer);
|
||||
int16_t value = *reinterpret_cast<int16_t*>(buffer);
|
||||
value = swap16(value);
|
||||
return value / 256.0;
|
||||
}
|
||||
|
||||
double CANJaguar::unpackFXP16_16(uint8_t* buffer) const {
|
||||
int32_t value = *((int32_t*)buffer);
|
||||
int32_t value = *reinterpret_cast<int32_t*>(buffer);
|
||||
value = swap32(value);
|
||||
return value / 65536.0;
|
||||
}
|
||||
|
||||
int16_t CANJaguar::unpackint16_t(uint8_t* buffer) const {
|
||||
int16_t value = *((int16_t*)buffer);
|
||||
int16_t value = *reinterpret_cast<int16_t*>(buffer);
|
||||
return swap16(value);
|
||||
}
|
||||
|
||||
int32_t CANJaguar::unpackint32_t(uint8_t* buffer) const {
|
||||
int32_t value = *((int32_t*)buffer);
|
||||
int32_t value = *reinterpret_cast<int32_t*>(buffer);
|
||||
return swap32(value);
|
||||
}
|
||||
|
||||
@@ -552,7 +552,7 @@ void CANJaguar::verify() {
|
||||
// If the Jaguar lost power, everything should be considered unverified.
|
||||
if (getMessage(LM_API_STATUS_POWER, CAN_MSGID_FULL_M, dataBuffer,
|
||||
&dataSize)) {
|
||||
bool powerCycled = (bool)dataBuffer[0];
|
||||
bool powerCycled = static_cast<bool>(dataBuffer[0]);
|
||||
|
||||
if (powerCycled) {
|
||||
// Clear the power cycled bit
|
||||
@@ -667,13 +667,13 @@ void CANJaguar::verify() {
|
||||
if (!m_pVerified) {
|
||||
uint32_t message = 0;
|
||||
|
||||
if (m_controlMode == kSpeed)
|
||||
if (m_controlMode == kSpeed) {
|
||||
message = LM_API_SPD_PC;
|
||||
else if (m_controlMode == kPosition)
|
||||
} else if (m_controlMode == kPosition) {
|
||||
message = LM_API_POS_PC;
|
||||
else if (m_controlMode == kCurrent)
|
||||
} else if (m_controlMode == kCurrent) {
|
||||
message = LM_API_ICTRL_PC;
|
||||
else {
|
||||
} else {
|
||||
wpi_setWPIErrorWithContext(
|
||||
IncompatibleMode,
|
||||
"PID constants only apply in Speed, Position, and Current mode");
|
||||
@@ -697,13 +697,13 @@ void CANJaguar::verify() {
|
||||
if (!m_iVerified) {
|
||||
uint32_t message = 0;
|
||||
|
||||
if (m_controlMode == kSpeed)
|
||||
if (m_controlMode == kSpeed) {
|
||||
message = LM_API_SPD_IC;
|
||||
else if (m_controlMode == kPosition)
|
||||
} else if (m_controlMode == kPosition) {
|
||||
message = LM_API_POS_IC;
|
||||
else if (m_controlMode == kCurrent)
|
||||
} else if (m_controlMode == kCurrent) {
|
||||
message = LM_API_ICTRL_IC;
|
||||
else {
|
||||
} else {
|
||||
wpi_setWPIErrorWithContext(
|
||||
IncompatibleMode,
|
||||
"PID constants only apply in Speed, Position, and Current mode");
|
||||
@@ -727,13 +727,13 @@ void CANJaguar::verify() {
|
||||
if (!m_dVerified) {
|
||||
uint32_t message = 0;
|
||||
|
||||
if (m_controlMode == kSpeed)
|
||||
if (m_controlMode == kSpeed) {
|
||||
message = LM_API_SPD_DC;
|
||||
else if (m_controlMode == kPosition)
|
||||
} else if (m_controlMode == kPosition) {
|
||||
message = LM_API_POS_DC;
|
||||
else if (m_controlMode == kCurrent)
|
||||
} else if (m_controlMode == kCurrent) {
|
||||
message = LM_API_ICTRL_DC;
|
||||
else {
|
||||
} else {
|
||||
wpi_setWPIErrorWithContext(
|
||||
IncompatibleMode,
|
||||
"PID constants only apply in Speed, Position, and Current mode");
|
||||
@@ -807,9 +807,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
LimitMode mode = (LimitMode)dataBuffer[0];
|
||||
|
||||
if (mode == m_limitMode)
|
||||
if (mode == m_limitMode) {
|
||||
m_limitModeVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigLimitMode(m_limitMode);
|
||||
}
|
||||
@@ -824,9 +824,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
double limit = unpackFXP16_16(dataBuffer);
|
||||
|
||||
if (FXP16_EQ(limit, m_forwardLimit))
|
||||
if (FXP16_EQ(limit, m_forwardLimit)) {
|
||||
m_forwardLimitVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigForwardLimit(m_forwardLimit);
|
||||
}
|
||||
@@ -841,9 +841,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
double limit = unpackFXP16_16(dataBuffer);
|
||||
|
||||
if (FXP16_EQ(limit, m_reverseLimit))
|
||||
if (FXP16_EQ(limit, m_reverseLimit)) {
|
||||
m_reverseLimitVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigReverseLimit(m_reverseLimit);
|
||||
}
|
||||
@@ -861,9 +861,9 @@ void CANJaguar::verify() {
|
||||
// The returned max output voltage is sometimes slightly higher or
|
||||
// lower than what was sent. This should not trigger resending
|
||||
// the message.
|
||||
if (std::abs(voltage - m_maxOutputVoltage) < 0.1)
|
||||
if (std::abs(voltage - m_maxOutputVoltage) < 0.1) {
|
||||
m_maxOutputVoltageVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigMaxOutputVoltage(m_maxOutputVoltage);
|
||||
}
|
||||
@@ -879,9 +879,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
double rate = unpackPercentage(dataBuffer);
|
||||
|
||||
if (FXP16_EQ(rate, m_voltageRampRate))
|
||||
if (FXP16_EQ(rate, m_voltageRampRate)) {
|
||||
m_voltageRampRateVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
SetVoltageRampRate(m_voltageRampRate);
|
||||
}
|
||||
@@ -894,9 +894,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
double rate = unpackFXP8_8(dataBuffer);
|
||||
|
||||
if (FXP8_EQ(rate, m_voltageRampRate))
|
||||
if (FXP8_EQ(rate, m_voltageRampRate)) {
|
||||
m_voltageRampRateVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
SetVoltageRampRate(m_voltageRampRate);
|
||||
}
|
||||
@@ -912,9 +912,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
uint16_t faultTime = unpackint16_t(dataBuffer);
|
||||
|
||||
if ((uint16_t)(m_faultTime * 1000.0) == faultTime)
|
||||
if ((uint16_t)(m_faultTime * 1000.0) == faultTime) {
|
||||
m_faultTimeVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigFaultTime(m_faultTime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user