diff --git a/src/can/can.cpp b/src/can/can.cpp index 31fec83b0ca414a79db34b3b4a173e7be708590c..ca8d68aefc930793d4f26dfa2c7af8169433d947 100755 --- a/src/can/can.cpp +++ b/src/can/can.cpp @@ -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=""; + } } diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 171b454c57205a30eb0205974af92b2d15e5cb34..0f50c9af54d2a55148ed1fa5894f88cfa03af4bb 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -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) diff --git a/src/examples/test_rs232.cpp b/src/examples/test_rs232.cpp index 4598df360b6299d8b1f5c7dbb6f0ec548cbe8c14..c377b62152da96278d8c1d38616b2c7a004ef863 100644 --- a/src/examples/test_rs232.cpp +++ b/src/examples/test_rs232.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;