Remove periodic can read call (#1868)

It is not necessary anymore, and is a complicated and confusing API to keep around.
This commit is contained in:
Thad House
2019-09-28 15:38:58 -07:00
committed by Peter Johnson
parent 41efb8015d
commit 8858ec55c7
8 changed files with 22 additions and 201 deletions

View File

@@ -34,7 +34,6 @@ static constexpr int32_t StatusEnergy = 0x5D;
static constexpr int32_t Control1 = 0x70;
static constexpr int32_t TimeoutMs = 100;
static constexpr int32_t StatusPeriodMs = 25;
/* encoder/decoders */
union PdpStatus1 {
@@ -173,9 +172,8 @@ double HAL_GetPDPTemperature(HAL_PDPHandle handle, int32_t* status) {
int32_t length = 0;
uint64_t receivedTimestamp = 0;
HAL_ReadCANPeriodicPacket(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, StatusPeriodMs,
status);
HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
return pdpStatus.bits.temp * 1.03250836957542 - 67.8564500484966;
}
@@ -185,9 +183,8 @@ double HAL_GetPDPVoltage(HAL_PDPHandle handle, int32_t* status) {
int32_t length = 0;
uint64_t receivedTimestamp = 0;
HAL_ReadCANPeriodicPacket(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, StatusPeriodMs,
status);
HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
return pdpStatus.bits.busVoltage * 0.05 + 4.0; /* 50mV per unit plus 4V. */
}
@@ -206,9 +203,8 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
if (channel <= 5) {
PdpStatus1 pdpStatus;
HAL_ReadCANPeriodicPacket(handle, Status1, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, StatusPeriodMs,
status);
HAL_ReadCANPacketTimeout(handle, Status1, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
switch (channel) {
case 0:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan1_h8) << 2) |
@@ -237,9 +233,8 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
}
} else if (channel <= 11) {
PdpStatus2 pdpStatus;
HAL_ReadCANPeriodicPacket(handle, Status2, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, StatusPeriodMs,
status);
HAL_ReadCANPacketTimeout(handle, Status2, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
switch (channel) {
case 6:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan7_h8) << 2) |
@@ -268,9 +263,8 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
}
} else {
PdpStatus3 pdpStatus;
HAL_ReadCANPeriodicPacket(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, StatusPeriodMs,
status);
HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
switch (channel) {
case 12:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan13_h8) << 2) |
@@ -300,9 +294,8 @@ double HAL_GetPDPTotalCurrent(HAL_PDPHandle handle, int32_t* status) {
int32_t length = 0;
uint64_t receivedTimestamp = 0;
HAL_ReadCANPeriodicPacket(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, StatusPeriodMs,
status);
HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
uint32_t raw;
raw = pdpStatus.bits.TotalCurrent_125mAperunit_h8;
@@ -316,9 +309,8 @@ double HAL_GetPDPTotalPower(HAL_PDPHandle handle, int32_t* status) {
int32_t length = 0;
uint64_t receivedTimestamp = 0;
HAL_ReadCANPeriodicPacket(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, StatusPeriodMs,
status);
HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
uint32_t raw;
raw = pdpStatus.bits.Power_125mWperunit_h4;
@@ -334,9 +326,8 @@ double HAL_GetPDPTotalEnergy(HAL_PDPHandle handle, int32_t* status) {
int32_t length = 0;
uint64_t receivedTimestamp = 0;
HAL_ReadCANPeriodicPacket(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, StatusPeriodMs,
status);
HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
uint32_t raw;
raw = pdpStatus.bits.Energy_125mWPerUnitXTmeas_h4;