Skip to content

Commit

Permalink
Merge pull request #21 from REVrobotics/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahAndrews authored Nov 10, 2023
2 parents 1578e38 + 61fa8c8 commit 5675170
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/native/cpp/Drivers/CandleWinUSB/CandleWinUSBDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ CandleWinUSBDevice::CandleWinUSBDevice(candle_handle hDev) :
throw "Failed to open device!";
}

// Set FRC capable settings, SPARK MAX is hard coded to this, but other devices (e.g. canable with
// Set FRC capable settings, SPARK MAX is hard coded to this, but other devices (e.g. canable with
// candlelight_fw) may need to be set to it explicitly. Note this only works for devices with 48MHz
// clocks, and could be expanded in the future to work with any device that properly reports its
// clocks, and could be expanded in the future to work with any device that properly reports its
// own capabilities.
if (!candle_channel_set_bitrate(hDev, CANDLE_DEFAULT_CHANNEL, 1000000)) {
std::cout << "Unable to set bitrate! " << candle_error_text(candle_dev_last_error(hDev)) << std::endl;
Expand All @@ -73,7 +73,7 @@ CandleWinUSBDevice::CandleWinUSBDevice(candle_handle hDev) :
close_candle_dev(hDev);
throw "Failed to start device channel 0!";
}

m_descriptor = unicode_decode(candle_dev_get_path(m_handle));
m_name = candle_dev_get_name(m_handle);
m_thread.Start();
Expand All @@ -82,7 +82,7 @@ CandleWinUSBDevice::CandleWinUSBDevice(candle_handle hDev) :
CandleWinUSBDevice::~CandleWinUSBDevice()
{
m_thread.Stop();

candle_channel_stop(m_handle, CANDLE_DEFAULT_CHANNEL);
close_candle_dev(m_handle);
}
Expand Down Expand Up @@ -130,7 +130,7 @@ CANStatus CandleWinUSBDevice::ReceiveCANMessage(std::shared_ptr<CANMessage>& msg
{
// Assume timeout
CANStatus status = CANStatus::kTimeout;

// parse through the keys, find the messges the match, and return it
// The first in the message id, then the messages
std::map<uint32_t, std::shared_ptr<CANMessage>> messages;
Expand All @@ -139,13 +139,13 @@ CANStatus CandleWinUSBDevice::ReceiveCANMessage(std::shared_ptr<CANMessage>& msg
for (auto& m : messages) {
if (CANBridge_ProcessMask({m.second->GetMessageId(), 0}, m.first) && CANBridge_ProcessMask({messageID, messageMask}, m.first)) {
mostRecent = m.second;
status = CANStatus::kOk;
status = CANStatus::kOk;
}
}

if (status == CANStatus::kOk) {
msg = mostRecent;
status = m_thread.GetLastThreadError(); // check and see if something else went wrong
status = m_thread.GetLastThreadError(); // check and see if something else went wrong
}

return status;
Expand All @@ -156,7 +156,7 @@ CANStatus CandleWinUSBDevice::OpenStreamSession(uint32_t* sessionHandle, CANBrid
CANStatus status;
// Register the stream with the correct buffer size
m_thread.OpenStream(sessionHandle, filter, maxSize, &status);

return m_thread.GetLastThreadError();
}
CANStatus CandleWinUSBDevice::CloseStreamSession(uint32_t sessionHandle)
Expand All @@ -177,7 +177,7 @@ CANStatus CandleWinUSBDevice::GetCANDetailStatus(float* percentBusUtilization, u
CANStatus CandleWinUSBDevice::GetCANDetailStatus(float* percentBusUtilization, uint32_t* busOff, uint32_t* txFull, uint32_t* receiveErr, uint32_t* transmitErr, uint32_t* lastErrorTime)
{
m_thread.GetCANStatusDetails(busOff, txFull, receiveErr, transmitErr, lastErrorTime);
*percentBusUtilization = 0.0; // todo how to get this
*percentBusUtilization = 0.0; // todo how to get this

return m_thread.GetLastThreadError();
}
Expand Down

0 comments on commit 5675170

Please sign in to comment.