don't try to fix WPILib, just hack around it like they do...
Change-Id: I4e5030c98306181f81be594eee26391a06c2bb95
diff --git a/aos/build/externals.gyp b/aos/build/externals.gyp
index 35d271d..e14850b 100644
--- a/aos/build/externals.gyp
+++ b/aos/build/externals.gyp
@@ -38,8 +38,9 @@
'<@(header_dirs)'
],
'cflags': [
- '-Wno-error=unused-parameter',
- '-Wno-error=switch-enum',
+ '-Wno-error',
+ '-fno-strict-aliasing',
+ '-O0',
],
'sources': [
'<!@(ls <(allwpilib)/wpilibc/wpilibC++/src/*.cpp)',
diff --git a/aos/externals/allwpilib/hal/lib/Athena/Digital.cpp b/aos/externals/allwpilib/hal/lib/Athena/Digital.cpp
index 3e8206b..3daaf09 100644
--- a/aos/externals/allwpilib/hal/lib/Athena/Digital.cpp
+++ b/aos/externals/allwpilib/hal/lib/Athena/Digital.cpp
@@ -12,8 +12,6 @@
#include "i2clib/i2c-lib.h"
#include "spilib/spi-lib.h"
-static_assert(sizeof(uint32_t) <= sizeof(void *), "This file shoves uint32_ts into pointers.");
-
static const uint32_t kExpectedLoopTiming = 40;
static const uint32_t kDigitalPins = 26;
static const uint32_t kPwmPins = 20;
diff --git a/aos/externals/allwpilib/hal/lib/Athena/Semaphore.cpp b/aos/externals/allwpilib/hal/lib/Athena/Semaphore.cpp
index 6f3dd86..df30f3c 100644
--- a/aos/externals/allwpilib/hal/lib/Athena/Semaphore.cpp
+++ b/aos/externals/allwpilib/hal/lib/Athena/Semaphore.cpp
@@ -136,9 +136,6 @@
delete sem;
}
-/**
- * @param timeout Not implemented.
- */
int8_t takeMultiWait(MULTIWAIT_ID sem, MUTEX_ID m, int32_t timeout) {
lockMutex(m);
int8_t val = pthread_cond_wait(sem, m->native_handle());
diff --git a/aos/externals/allwpilib/hal/lib/Athena/Task.cpp b/aos/externals/allwpilib/hal/lib/Athena/Task.cpp
index f39a7b5..2be66f5 100644
--- a/aos/externals/allwpilib/hal/lib/Athena/Task.cpp
+++ b/aos/externals/allwpilib/hal/lib/Athena/Task.cpp
@@ -37,11 +37,6 @@
return ret;
}
-/**
- * @param priority Not implemented.
- * @param options Not implemented.
- * @param stackSize Not implemented.
- */
TASK spawnTask(char * name, int priority, int options, int stackSize,
FUNCPTR entryPt, uint32_t arg0, uint32_t arg1, uint32_t arg2,
uint32_t arg3, uint32_t arg4, uint32_t arg5, uint32_t arg6,
diff --git a/aos/externals/allwpilib/hal/lib/Athena/ctre/CanTalonSRX.cpp b/aos/externals/allwpilib/hal/lib/Athena/ctre/CanTalonSRX.cpp
index 43e6aaa..a51099c 100644
--- a/aos/externals/allwpilib/hal/lib/Athena/ctre/CanTalonSRX.cpp
+++ b/aos/externals/allwpilib/hal/lib/Athena/ctre/CanTalonSRX.cpp
@@ -304,18 +304,17 @@
for (i = 0; i < messagesRead; ++i) {
tCANStreamMessage * msg = _msgBuff + i;
if(msg->messageID == (PARAM_RESPONSE | GetDeviceNumber()) ){
- TALON_Param_Response_t paramResp;
- memcpy(¶mResp, msg->data, sizeof(paramResp));
+ TALON_Param_Response_t * paramResp = (TALON_Param_Response_t*)msg->data;
/* decode value */
- int32_t val = paramResp.ParamValueH;
+ int32_t val = paramResp->ParamValueH;
val <<= 8;
- val |= paramResp.ParamValueMH;
+ val |= paramResp->ParamValueMH;
val <<= 8;
- val |= paramResp.ParamValueML;
+ val |= paramResp->ParamValueML;
val <<= 8;
- val |= paramResp.ParamValueL;
+ val |= paramResp->ParamValueL;
/* save latest signal */
- _sigs[paramResp.ParamEnum] = val;
+ _sigs[paramResp->ParamEnum] = val;
}else{
int brkpthere = 42;
++brkpthere;
diff --git a/aos/externals/allwpilib/hal/lib/Athena/ctre/CtreCanNode.h b/aos/externals/allwpilib/hal/lib/Athena/ctre/CtreCanNode.h
index 65fa948..7a2d690 100644
--- a/aos/externals/allwpilib/hal/lib/Athena/ctre/CtreCanNode.h
+++ b/aos/externals/allwpilib/hal/lib/Athena/ctre/CtreCanNode.h
@@ -45,15 +45,11 @@
CTR_Code err;
T * operator -> ()
{
- T *r;
- memcpy(&r, &bytes, sizeof(r));
- return r;
+ return (T *)bytes;
}
T & operator*()
{
- T *r;
- memcpy(&r, &bytes, sizeof(r));
- return *r;
+ return *(T *)bytes;
}
};
UINT8 _deviceNumber;
@@ -69,7 +65,7 @@
txJobs_t::iterator i = _txJobs.find(arbId);
if(i != _txJobs.end()){
retval.arbId = i->second.arbId;
- memcpy(&retval.toSend, &i->second.toSend, sizeof(retval.toSend));
+ retval.toSend = (T*)i->second.toSend;
}
return retval;
}
diff --git a/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/CANJaguar.cpp b/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/CANJaguar.cpp
index 61b22a5..909fec5 100644
--- a/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/CANJaguar.cpp
+++ b/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/CANJaguar.cpp
@@ -13,7 +13,6 @@
#include "WPIErrors.h"
#include <cstdio>
#include <cassert>
-#include <cstring>
/* we are on ARM-LE now, not Freescale so no need to swap */
#define swap16(x) (x)
@@ -409,76 +408,66 @@
uint8_t CANJaguar::packPercentage(uint8_t *buffer, double value)
{
int16_t intValue = (int16_t)(value * 32767.0);
- int16_t swapped = swap16(intValue);
- memcpy(buffer, &swapped, sizeof(int16_t));
+ *((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 swapped = swap16(intValue);
- memcpy(buffer, &swapped, sizeof(int16_t));
+ *((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 swapped = swap32(intValue);
- memcpy(buffer, &swapped, sizeof(int32_t));
+ *((int32_t*)buffer) = swap32(intValue);
return sizeof(int32_t);
}
uint8_t CANJaguar::packint16_t(uint8_t *buffer, int16_t value)
{
- int16_t swapped = swap16(value);
- memcpy(buffer, &swapped, sizeof(int16_t));
+ *((int16_t*)buffer) = swap16(value);
return sizeof(int16_t);
}
uint8_t CANJaguar::packint32_t(uint8_t *buffer, int32_t value)
{
- int32_t swapped = swap32(value);
- memcpy(buffer, &swapped, sizeof(int32_t));
+ *((int32_t*)buffer) = swap32(value);
return sizeof(int32_t);
}
double CANJaguar::unpackPercentage(uint8_t *buffer)
{
- int16_t value;
- memcpy(&value, buffer, sizeof(value));
+ int16_t value = *((int16_t*)buffer);
value = swap16(value);
return value / 32767.0;
}
double CANJaguar::unpackFXP8_8(uint8_t *buffer)
{
- int16_t value;
- memcpy(&value, buffer, sizeof(value));
+ int16_t value = *((int16_t*)buffer);
value = swap16(value);
return value / 256.0;
}
double CANJaguar::unpackFXP16_16(uint8_t *buffer)
{
- int32_t value;
- memcpy(&value, buffer, sizeof(value));
+ int32_t value = *((int32_t*)buffer);
value = swap32(value);
return value / 65536.0;
}
int16_t CANJaguar::unpackint16_t(uint8_t *buffer)
{
- int16_t value;
- memcpy(&value, buffer, sizeof(value));
+ int16_t value = *((int16_t*)buffer);
return swap16(value);
}
int32_t CANJaguar::unpackint32_t(uint8_t *buffer)
{
- int32_t value;
- memcpy(&value, buffer, sizeof(value));
+ int32_t value = *((int32_t*)buffer);
return swap32(value);
}
@@ -768,10 +757,6 @@
message = LM_API_POS_PC;
else if(m_controlMode == kCurrent)
message = LM_API_ICTRL_PC;
- else {
- wpi_setWPIErrorWithContext(IncompatibleMode, "PID constants only apply in Speed, Position, and Current mode");
- return;
- }
if(getMessage(message, CAN_MSGID_FULL_M, dataBuffer, &dataSize))
{
@@ -800,10 +785,6 @@
message = LM_API_POS_IC;
else if(m_controlMode == kCurrent)
message = LM_API_ICTRL_IC;
- else {
- wpi_setWPIErrorWithContext(IncompatibleMode, "PID constants only apply in Speed, Position, and Current mode");
- return;
- }
if(getMessage(message, CAN_MSGID_FULL_M, dataBuffer, &dataSize))
{
@@ -832,10 +813,6 @@
message = LM_API_POS_DC;
else if(m_controlMode == kCurrent)
message = LM_API_ICTRL_DC;
- else {
- wpi_setWPIErrorWithContext(IncompatibleMode, "PID constants only apply in Speed, Position, and Current mode");
- return;
- }
if(getMessage(message, CAN_MSGID_FULL_M, dataBuffer, &dataSize))
{
diff --git a/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/CANTalon.cpp b/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/CANTalon.cpp
index 0c20b55..1dd7b7e 100644
--- a/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/CANTalon.cpp
+++ b/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/CANTalon.cpp
@@ -91,7 +91,6 @@
m_impl->GetSensorPosition(value);
return value;
case kPercentVbus:
- case kFollower:
default:
m_impl->GetAppliedThrottle(value);
return (float)value / 1023.0;
@@ -118,7 +117,7 @@
m_safetyHelper->Feed();
if(m_controlEnabled) {
m_setPoint = value;
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
switch(m_controlMode) {
case CANSpeedController::kPercentVbus:
{
@@ -144,9 +143,7 @@
case CANSpeedController::kPosition:
status = m_impl->SetDemand(value);
break;
- // XXX: What about CANSpeedController::kCurrent?
default:
- status = CTR_InvalidParamValue;
break;
}
if (status != CTR_OKAY) {
@@ -734,7 +731,7 @@
{
int limSwit=0;
int softLim=0;
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
status = m_impl->GetFault_ForSoftLim(softLim);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
@@ -754,7 +751,7 @@
{
int limSwit=0;
int softLim=0;
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
status = m_impl->GetFault_RevSoftLim(softLim);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
@@ -774,7 +771,7 @@
{
uint16_t retval = 0;
int val;
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
/* temperature */
val = 0;
@@ -824,7 +821,7 @@
{
uint16_t retval = 0;
int val;
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
/* temperature */
val = 0;
@@ -966,7 +963,7 @@
*/
void CANTalon::ConfigNeutralMode(NeutralMode mode)
{
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
switch(mode){
default:
case kNeutralMode_Jumper: /* use default setting in flash based on webdash/BrakeCal button selection */
@@ -1036,7 +1033,7 @@
*/
void CANTalon::ConfigLimitMode(LimitMode mode)
{
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
switch(mode){
case kLimitMode_SwitchInputsOnly: /** Only use switches for limits */
/* turn OFF both limits. SRX has individual enables and polarity for each limit switch.*/
@@ -1095,7 +1092,7 @@
*/
void CANTalon::ConfigForwardLimit(double forwardLimitPosition)
{
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
status = m_impl->SetForwardSoftLimit(forwardLimitPosition);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
@@ -1140,7 +1137,7 @@
*/
void CANTalon::ConfigReverseLimit(double reverseLimitPosition)
{
- CTR_Code status = CTR_OKAY;
+ CTR_Code status;
status = m_impl->SetReverseSoftLimit(reverseLimitPosition);
if(status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
diff --git a/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/DriverStation.cpp b/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/DriverStation.cpp
index 91fccd5..7821289 100644
--- a/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/DriverStation.cpp
+++ b/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/DriverStation.cpp
@@ -66,13 +66,7 @@
AddToSingletonList();
- // They need to be identical or it could lead to runtime stack corruption if
- // the caller and callee push and pop different amounts of data on the stack.
- static_assert(sizeof(this) == sizeof(uint32_t),
- "We are passing a pointer through a uint32_t");
- static_assert(alignof(this) <= alignof(uint32_t),
- "We are passing a pointer through a uint32_t");
- if (!m_task.Start((uint32_t)this))
+ if (!m_task.Start((int32_t)this))
{
wpi_setWPIError(DriverStationTaskError);
}
@@ -90,8 +84,6 @@
deleteMutex(m_waitForDataMutex);
}
-// XXX: This assumes that the calling convention treats pointers and uint32_ts
-// identical, which is not necessarily true.
void DriverStation::InitTask(DriverStation *ds)
{
ds->Run();
diff --git a/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/Joystick.cpp b/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/Joystick.cpp
index 46a9f08..790f0d7 100644
--- a/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/Joystick.cpp
+++ b/aos/externals/allwpilib/wpilibc/wpilibC++Devices/src/Joystick.cpp
@@ -107,7 +107,6 @@
/**
* Get the X value of the joystick.
* This depends on the mapping of the joystick connected to the current port.
- * @param hand This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface.
*/
float Joystick::GetX(JoystickHand hand)
{
@@ -117,7 +116,6 @@
/**
* Get the Y value of the joystick.
* This depends on the mapping of the joystick connected to the current port.
- * @param hand This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface.
*/
float Joystick::GetY(JoystickHand hand)
{