*
*********************************************************************************/
-CanBus_t::CanBus_t(afb_binding_interface *itf, const std:string& dev_name)
+can_bus_t::can_bus_t(afb_binding_interface *itf, const std:string& dev_name)
: interface{itf}, deviceName{dev_name}
{
}
-int CanBus_t::open()
+int can_bus_t::open()
{
const int canfd_on = 1;
struct ifreq ifr;
return -1;
}
-int CanBus_t::close()
+int can_bus_t::close()
{
::close(can_socket_);
can_socket_ = -1;
}
-canfd_frame CanBus_t::can_read()
+canfd_frame can_bus_t::can_read()
{
ssize_t nbytes;
int maxdlen;
return canfd_frame;
}
-void CanBus_t::start_threads()
+void can_bus_t::start_threads()
{
th_reading_ = std::thread(can_reader, interface, socket, can_message_q_);
is_running_ = true;
/*
* Return is_running_ bool
*/
-bool CanBus_t::is_running()
+bool can_bus_t::is_running()
{
return is_running_;
}
/*
- * Send a can message from a CanMessage_c object.
+ * Send a can message from a can_message_t object.
*/
-int CanBus_t::send_can_message(CanMessage_c &can_msg)
+int can_bus_t::send_can_message(can_message_t &can_msg)
{
int nbytes;
canfd_frame *f;
*
* Return the next queue element or NULL if queue is empty.
*/
-CanMessage_c* CanBus_t::next_can_message()
+can_message_t* can_bus_t::next_can_message()
{
if(! can_message_q_.empty())
{
- CanMessage_c can_msg = can_message_q_.front();
+ can_message_t can_msg = can_message_q_.front();
can_message_q_.pop()
return &can_msg;
}
return nullptr;
}
-void CanBus_t::insert_new_can_message(CanMessage_c &can_msg)
+void can_bus_t::insert_new_can_message(can_message_t &can_msg)
{
can_message_q_.push(can_msg);
}
*
* Return the next queue element or NULL if queue is empty.
*/
-openxc_VehicleMessage* CanBus_t::next_vehicle_message()
+openxc_VehicleMessage* can_bus_t::next_vehicle_message()
{
if(! vehicle_message_q_.empty())
{
return nullptr;
}
-void CanBus_t::insert_new_vehicle_message(openxc_VehicleMessage *v_msg)
+void can_bus_t::insert_new_vehicle_message(openxc_VehicleMessage *v_msg)
{
vehicle_message_q_.push(v_msg);
}
*
*********************************************************************************/
-uint32_t CanMessage_c::get_id() const
+uint32_t can_message_t::get_id() const
{
return id;
}
-int CanMessage_c::get_format() const
+int can_message_t::get_format() const
{
return format;
}
-uint8_t CanMessage_c::get_data() const
+uint8_t can_message_t::get_data() const
{
return data;
}
-uint8_t CanMessage_c::get_lenght() const
+uint8_t can_message_t::get_lenght() const
{
return lenght;
}
-void CanMessage_c::set_id(uint32_t new_id)
+void can_message_t::set_id(uint32_t new_id)
{
switch(format):
case CanMessageFormat::SIMPLE:
ERROR(interface, "ERROR: Can set id, not a compatible format or format not set prior to set id.");
}
-void CanMessage_c::set_format(CanMessageFormat new_format)
+void can_message_t::set_format(CanMessageFormat new_format)
{
if(new_format == CanMessageFormat::SIMPLE || new_format == CanMessageFormat::EXTENDED)
format = new_format;
ERROR(interface, "ERROR: Can set format, wrong format chosen");
}
-void CanMessage_c::set_data(uint8_t new_data)
+void can_message_t::set_data(uint8_t new_data)
{
data = new_data;
}
-void CanMessage_c::set_lenght(uint8_t new_length)
+void can_message_t::set_lenght(uint8_t new_length)
{
lenght = new_lenght;
}
*
* params: canfd_frame pointer
*/
-void CanMessage_c::convert_from_canfd_frame(canfd_frame *frame)
+void can_message_t::convert_from_canfd_frame(canfd_frame *frame)
{
lenght = (canfd_frame->len > maxdlen) ? maxdlen : canfd_frame->len;
memcpy(data, canfd_frame->data, lenght);
return 0;
} else if (sizeof(canfd_frame->data) >= CAN_MAX_DLEN)
- ERROR(interface, "CanMessage_c: canfd_frame data too long to be stored into CanMessage object");
+ ERROR(interface, "can_message_t: canfd_frame data too long to be stored into CanMessage object");
}
canfd_frame* convert_to_canfd_frame()
/*
* CanBus represent a can device definition gotten from configuraiton file
*/
-class CanBus_c {
+class can_bus_t {
private:
afb_binding_interface *interface_;
std::thread th_decoding_;
std::thread th_pushing_;
- std::queue <CanMessage_c> can_message_q_;
+ std::queue <can_message_t> can_message_q_;
std::queue <openxc_VehicleMessage> vehicle_message_q_;
public:
void start_threads();
bool is_running();
- int send_can_message(CanMessage_c can_msg);
+ int send_can_message(can_message_t can_msg);
- CanMessage_c* next_can_message();
- void insert_new_can_message(CanMessage_c &can_msg);
+ can_message_t* next_can_message();
+ void insert_new_can_message(can_message_t &can_msg);
openxc_VehicleMessage* next_vehicle_message();
void insert_new_vehicle_message(openxc_VehicleMessage *v_msg);
};
typedef struct CanMessage CanMessage;
*/
-class CanMessage_c {
+class can_message_t {
private:
uint32_t id;
CanMessageFormat format;
canfd_frame convert_to_canfd_frame();
};
-QUEUE_DECLARE(CanMessage_c, 8);
+QUEUE_DECLARE(can_message_t, 8);
/* Public: The ID format for a CAN message.
*