13 #include "real_time_tools/timer.hpp" 14 #include "real_time_tools/thread.hpp" 15 #include "real_time_tools/iostream.hpp" 16 #include "real_time_tools/spinner.hpp" 18 #include "real_time_tools/threadsafe/threadsafe_object.hpp" 19 #include "real_time_tools/threadsafe/threadsafe_timeseries.hpp" 37 std::array<uint8_t, 8>
data;
49 rt_printf(
"---------------------------\n");
51 for(
auto& datum : data)
61 rt_printf(
"---------------------------\n");
75 struct sockaddr_can send_addr;
109 virtual std::shared_ptr<const CanframeTimeseries> get_output_frame()
117 virtual std::shared_ptr<const CanframeTimeseries> get_input_frame() = 0;
124 virtual std::shared_ptr<const CanframeTimeseries> get_sent_input_frame() = 0;
135 virtual void set_input_frame(
const CanBusFrame& input_frame) = 0;
144 virtual void send_if_input_changed() = 0;
159 CanBus(
const std::string& can_interface_name,
160 const size_t& history_length = 1000);
212 input_->append(input_frame);
222 virtual void send_if_input_changed();
237 static THREAD_FUNCTION_RETURN_TYPE
loop(
void* instance_pointer)
239 ((
CanBus*)(instance_pointer))->loop();
240 return THREAD_FUNCTION_RETURN_VALUE;
253 void send_frame(
const CanBusFrame& unstamped_can_frame);
286 std::shared_ptr<real_time_tools::ThreadsafeTimeseries<CanBusFrame> >
input_;
291 std::shared_ptr<real_time_tools::ThreadsafeTimeseries<CanBusFrame> >
sent_input_;
296 std::shared_ptr<real_time_tools::ThreadsafeTimeseries<CanBusFrame> >
output_;
CanBusConnection is a data structure that contains the hardware details for the connection between to...
Definition: can_bus.hpp:69
CanBusFrame is a class that contains a fixed sized amount of data to be send or received via the can ...
Definition: can_bus.hpp:31
std::array< uint8_t, 8 > data
data is the acutal data to be sent/received.
Definition: can_bus.hpp:37
uint8_t dlc
dlc is the size of the message.
Definition: can_bus.hpp:41
This namespace is the standard namespace of the package.
Definition: const_torque_control.cpp:12
static THREAD_FUNCTION_RETURN_TYPE loop(void *instance_pointer)
private attributes and methods
Definition: can_bus.hpp:237
virtual std::shared_ptr< const CanframeTimeseries > get_input_frame()
Get the input frame.
Definition: can_bus.hpp:186
std::shared_ptr< real_time_tools::ThreadsafeTimeseries< CanBusFrame > > sent_input_
sent_inupt_ is the list of the input already sent to the network.
Definition: can_bus.hpp:291
CanBus is the implementation of the CanBusInterface.
Definition: can_bus.hpp:150
canid_t can_id_t
Create a common type_def to wrap xenomai and posix.
Definition: os_interface.hpp:63
#define rt_printf
Create a common type_def to wrap xenomai and posix.
Definition: os_interface.hpp:76
real_time_tools::ThreadsafeTimeseries< CanBusFrame > CanframeTimeseries
CanframeTimeseries is a simple sohortcut.
Definition: can_bus.hpp:98
CanBusInterface is an abstract class that defines an API for the communication via Can bus...
Definition: can_bus.hpp:86
bool is_loop_active_
This boolean makes sure that the loop is not active upon destruction of the current object...
Definition: can_bus.hpp:302
can_id_t id
id is the id number return by the CAN bus.
Definition: can_bus.hpp:45
int socket
socket is the port through which the messages will be processed
Definition: can_bus.hpp:79
this class exists purely for logical reasons, it does not in itself implement anything.
Definition: device_interface.hpp:36
virtual ~CanBusInterface()
Destroy the CanBusInterface object.
Definition: can_bus.hpp:92
std::shared_ptr< const CanframeTimeseries > get_output_frame() const
Getters.
Definition: can_bus.hpp:176
virtual std::shared_ptr< const CanframeTimeseries > get_sent_input_frame()
Get the input frame thas has been sent.
Definition: can_bus.hpp:196
real_time_tools::SingletypeThreadsafeObject< CanBusConnection, 1 > can_connection_
Attributes.
Definition: can_bus.hpp:280
std::shared_ptr< real_time_tools::ThreadsafeTimeseries< CanBusFrame > > output_
output_ is the list of the frames received from the can network.
Definition: can_bus.hpp:296
virtual void set_input_frame(const CanBusFrame &input_frame)
Setters.
Definition: can_bus.hpp:210
real_time_tools::RealTimeThread rt_thread_
rt_thread_ is the thread object allowing us to spawn real-time threads.
Definition: can_bus.hpp:308
std::string name_
time_log_name is the name of the loggin
Definition: can_bus.hpp:318
std::shared_ptr< real_time_tools::ThreadsafeTimeseries< CanBusFrame > > input_
input_ is a list of time stamped frame to be send to the can network.
Definition: can_bus.hpp:286
std::string log_dir_
Log directory.
Definition: can_bus.hpp:313