Hi there!
How should I change the CMakeList.txt file to make the example file compile without errors?
/* src/drivers/distance_sensor/radar/RADAR.hpp */
#pragma once
#include <uavcan_nuttx/socketcan.hpp> //TODO How to change CMakeLists.txt file to add uavcan_nuttx/socketcan.hpp?
using namespace time_literals;
class RADAR : public ModuleBase<RADAR>, public px4::ScheduledWorkItem, public uavcan_socketcan::CanIface
{
public:
RADAR();
virtual ~RADAR();
int init();
void print_info();
uavcan::int16_t receive(uavcan::CanFrame &out_frame);
private:
void start();
void stop();
void Run() override;
int collect();
};
//* src/drivers/distance_sensor/radar/RADAR.cpp */
#include "RADAR.hpp"
uavcan::int16_t CanIface::receive(uavcan::CanFrame &out_frame)
{
int32_t result = recvmsg(_fd, &_recv_msg, MSG_DONTWAIT);
if (result < 0) {
return result;
}
/* Copy SocketCAN frame to DevFrame */ //todo MASKID
CanMsgId targetInfo = CanMsgId::TRGT_INFO;
uint32_t ID = targetInfo;
if ((recv_frame->can_id & uavcan::CanFrame::MaskStdID) == ID) {
if (_can_fd) {
struct canfd_frame *recv_frame = (struct canfd_frame *)&_recv_frame;
out_frame.id = recv_frame->can_id;
out_frame.dlc = recv_frame->len;
memcpy(out_frame.data, &recv_frame->data, recv_frame->len);
} else {
struct can_frame *recv_frame = (struct can_frame *)&_recv_frame;
out_frame.id = recv_frame->can_id;
out_frame.dlc = recv_frame->can_dlc;
memcpy(out_frame.data, &recv_frame->data, recv_frame->can_dlc);
}
return result;
}
}
//* src/drivers/distance_sensor/radar/CMakeLists.txt */
px4_add_module(
MODULE MODULE drivers__distance_sensor__radar
MAIN radar
SRCS
RADAR.cpp
RADAR.hpp
radar_main.cpp
DEPENDS
drivers_rangefinder
px4_work_queue
)
Below is a compilation error:
/* BUILD ERROR*/
In file included from /…/PX4-Autopilot/src/drivers/distance_sensor/radar/RADAR.cpp:7:
/…/PX4-Autopilot/src/drivers/distance_sensor/radar/RADAR.hpp:10:10: fatal error: uavcan_nuttx/socketcan.hpp:
No such file or directory
10 | #include <uavcan_nuttx/socketcan.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.