mirror of
https://github.com/intrepidcs/icsscand.git
synced 2026-08-05 01:28:26 +02:00
Refactor for libicsneo v0.3.0 API changes
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(libicsneo-socketcan-daemon VERSION 2.0.3)
|
||||
project(libicsneo-socketcan-daemon VERSION 2.1.0)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
|
||||
+22
-6
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <icsneo/icsneocpp.h>
|
||||
#include <icsneo/communication/message/neomessage.h>
|
||||
#include <icsneo/communication/message/message.h>
|
||||
#include <icsneo/communication/network.h>
|
||||
#include <icsneo/communication/message/callback/canmessagecallback.h>
|
||||
#include <generated/buildinfo.h>
|
||||
|
||||
@@ -86,8 +88,15 @@ public:
|
||||
const std::string& getName() const { return name; }
|
||||
uint8_t* getRxBox() { return rxBox; }
|
||||
const uint8_t* getRxBox() const { return rxBox; }
|
||||
void addReceivedMessageToQueue(const std::shared_ptr<icsneo::Message>& msg) {
|
||||
auto neomessage = icsneo::CreateNeoMessage(msg);
|
||||
void addReceivedMessageToQueue(const std::shared_ptr<icsneo::CANMessage>& msg) {
|
||||
const auto neomessageGeneric = icsneo::CreateNeoMessage(msg);
|
||||
if (neomessageGeneric.messageType != neomessagetype_t(icsneo::Message::Type::Frame)) {
|
||||
LOG(LOG_DEBUG, "could not create a neomessage_can_t\n");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& neomessage = *reinterpret_cast<const neomessage_can_t*>(&neomessageGeneric);
|
||||
|
||||
size_t bytesNeeded = sizeof(neomessage) + neomessage.length;
|
||||
std::lock_guard<std::mutex> lg(rxBoxLock);
|
||||
if(ssize_t((rxBoxCurrentPosition - rxBox) + bytesNeeded) > RX_BOX_SIZE) {
|
||||
@@ -480,10 +489,16 @@ int main(int argc, char** argv) {
|
||||
// Send!
|
||||
uint8_t* currentPosition = GET_TX_BOX(info.tx_box_index);
|
||||
while(info.count--) {
|
||||
neomessage_t* msg = reinterpret_cast<neomessage_t*>(currentPosition);
|
||||
currentPosition += sizeof(neomessage_t);
|
||||
neomessage_frame_t* msg = reinterpret_cast<neomessage_frame_t*>(currentPosition);
|
||||
currentPosition += sizeof(neomessage_frame_t);
|
||||
msg->data = currentPosition;
|
||||
currentPosition += msg->length;
|
||||
|
||||
if(msg->type != neonettype_t(icsneo::Network::Type::CAN)) {
|
||||
LOG(LOG_ERR, "Message dropped, kernel sent a non-CAN message\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
bool sent = false;
|
||||
std::lock_guard<std::mutex> lg(openDevicesMutex);
|
||||
for(auto& dev : openDevices) {
|
||||
@@ -491,8 +506,9 @@ int main(int argc, char** argv) {
|
||||
if(netifPair.second->getKernelHandle() != msg->netid)
|
||||
continue;
|
||||
msg->netid = static_cast<uint16_t>(netifPair.first);
|
||||
auto tx = icsneo::CreateMessageFromNeoMessage(msg);
|
||||
if(!dev.device->transmit(tx))
|
||||
auto txMsg = icsneo::CreateMessageFromNeoMessage(reinterpret_cast<neomessage_t*>(msg));
|
||||
auto tx = std::dynamic_pointer_cast<icsneo::Frame>(txMsg);
|
||||
if(!tx || !dev.device->transmit(tx))
|
||||
break;
|
||||
sent = true;
|
||||
break;
|
||||
|
||||
Vendored
+1
-1
Submodule third-party/libicsneo updated: b09f85693f...0ff12300f3
Reference in New Issue
Block a user