Skip to content
Snippets Groups Projects
Commit a7f28a18 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Moved the evetn and thread destruction to the class destructor instead of the close() function.

parent a840551f
No related branches found
No related tags found
No related merge requests found
......@@ -156,32 +156,6 @@ void CCAN::hard_close(void)
// close the can device
if(this->can_socket_fd!=-1)
::close(this->can_socket_fd);
// free all the resources
if(this->finish_can_thread_event_id!="")
{
this->event_server->set_event(this->finish_can_thread_event_id);
this->thread_server->end_thread(this->can_thread_id);
this->thread_server->detach_thread(this->can_thread_id);
this->thread_server->delete_thread(this->can_thread_id);
this->can_thread_id="";
this->event_server->delete_event(this->finish_can_thread_event_id);
this->finish_can_thread_event_id="";
}
if(this->new_frame_event_id!="")
{
this->event_server->delete_event(this->new_frame_event_id);
this->new_frame_event_id="";
}
if(this->frame_error_event_id!="")
{
this->event_server->delete_event(this->frame_error_event_id);
this->frame_error_event_id="";
}
if(this->data_requested_event_id!="")
{
this->event_server->delete_event(this->data_requested_event_id);
this->data_requested_event_id="";
}
}
void *CCAN::can_thread(void *param)
......@@ -405,5 +379,31 @@ CCAN::~CCAN()
// close the can device
if(this->can_socket_fd!=-1)
CComm::close();
// free all the resources
if(this->finish_can_thread_event_id!="")
{
this->event_server->set_event(this->finish_can_thread_event_id);
this->thread_server->end_thread(this->can_thread_id);
this->thread_server->detach_thread(this->can_thread_id);
this->thread_server->delete_thread(this->can_thread_id);
this->can_thread_id="";
this->event_server->delete_event(this->finish_can_thread_event_id);
this->finish_can_thread_event_id="";
}
if(this->new_frame_event_id!="")
{
this->event_server->delete_event(this->new_frame_event_id);
this->new_frame_event_id="";
}
if(this->frame_error_event_id!="")
{
this->event_server->delete_event(this->frame_error_event_id);
this->frame_error_event_id="";
}
if(this->data_requested_event_id!="")
{
this->event_server->delete_event(this->data_requested_event_id);
this->data_requested_event_id="";
}
}
......@@ -16,6 +16,12 @@ ADD_EXECUTABLE(test_can_rx test_can_rx.cpp)
# edit the following line to add the necessary libraries
TARGET_LINK_LIBRARIES(test_can_rx ${IRIUTILS_LIBRARY} comm pthread)
# edit the following line to add the source code for the example and the name of the executable
ADD_EXECUTABLE(test_candump test_candump.cpp)
# edit the following line to add the necessary libraries
TARGET_LINK_LIBRARIES(test_candump ${IRIUTILS_LIBRARY} comm pthread)
IF(BUILD_FTDI)
ADD_EXECUTABLE(test_ftdi test_ftdi.cpp)
......
......@@ -7,7 +7,7 @@
#include <string>
#include <iostream>
const std::string serial_dev="/dev/ttyS0";
const std::string serial_dev="/dev/ttyUSB0";
const std::string empty_string="";
/**
......@@ -65,7 +65,7 @@ int main(int argc,char *argv[])
int num=0,total_length=0,i=0;
TRS232_config serial_config;
serial_config.baud=9600;
serial_config.baud=1000000;
serial_config.num_bits=8;
serial_config.parity=none;
serial_config.stop_bits=1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment