Allow polling for messages from C

This commit is contained in:
Paul Hollinsky
2018-09-13 19:40:23 -04:00
parent f1f1cb1701
commit 63d13cdb88
6 changed files with 155 additions and 10 deletions
+1 -10
View File
@@ -94,7 +94,6 @@ std::vector<std::shared_ptr<Message>> Device::getMessages() {
bool Device::getMessages(std::vector<std::shared_ptr<Message>>& container, size_t limit) {
// A limit of zero indicates no limit
auto oglimit = limit;
if(limit == 0)
limit = (size_t)-1;
@@ -108,7 +107,7 @@ bool Device::getMessages(std::vector<std::shared_ptr<Message>>& container, size_
container.resize(actuallyRead);
return actuallyRead <= oglimit;
return true;
}
void Device::enforcePollingMessageLimit() {
@@ -140,14 +139,6 @@ bool Device::goOnline() {
if(!com->sendCommand(Communication::Command::RequestSerialNumber))
return false;
com->addMessageCallback(CANMessageCallback([](std::shared_ptr<Message> message) {
std::shared_ptr<CANMessage> canMessage = std::static_pointer_cast<CANMessage>(message);
std::cout << "CAN 0x" << std::hex << canMessage->arbid << std::dec << " [" << canMessage->data.size() << "] " << std::hex;
for(const auto& b : canMessage->data)
std::cout << (int)b << ' ';
std::cout << std::dec << std::endl;
}));
return online = true;
}