Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
comm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
drivers
comm
Commits
a7f28a18
Commit
a7f28a18
authored
9 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/can/can.cpp
+26
-26
26 additions, 26 deletions
src/can/can.cpp
src/examples/CMakeLists.txt
+6
-0
6 additions, 0 deletions
src/examples/CMakeLists.txt
src/examples/test_rs232.cpp
+2
-2
2 additions, 2 deletions
src/examples/test_rs232.cpp
with
34 additions
and
28 deletions
src/can/can.cpp
+
26
−
26
View file @
a7f28a18
...
...
@@ -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
=
""
;
}
}
This diff is collapsed.
Click to expand it.
src/examples/CMakeLists.txt
+
6
−
0
View file @
a7f28a18
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
src/examples/test_rs232.cpp
+
2
−
2
View file @
a7f28a18
...
...
@@ -7,7 +7,7 @@
#include
<string>
#include
<iostream>
const
std
::
string
serial_dev
=
"/dev/tty
S
0"
;
const
std
::
string
serial_dev
=
"/dev/tty
USB
0"
;
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
=
96
00
;
serial_config
.
baud
=
10000
00
;
serial_config
.
num_bits
=
8
;
serial_config
.
parity
=
none
;
serial_config
.
stop_bits
=
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment