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
d961fc9f
Commit
d961fc9f
authored
9 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Implemented the clear_id_filters() function and added a public close() function.
parent
cea127e5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/can/can.cpp
+20
-2
20 additions, 2 deletions
src/can/can.cpp
src/can/can.h
+4
-0
4 additions, 0 deletions
src/can/can.h
with
24 additions
and
2 deletions
src/can/can.cpp
+
20
−
2
View file @
d961fc9f
...
@@ -323,7 +323,8 @@ void CCAN::add_id_filter(unsigned short int can_id,bool invert)
...
@@ -323,7 +323,8 @@ void CCAN::add_id_filter(unsigned short int can_id,bool invert)
new_filters
=
new
struct
can_filter
[
this
->
num_filters
+
1
];
new_filters
=
new
struct
can_filter
[
this
->
num_filters
+
1
];
memcpy
(
new_filters
,
this
->
rx_filters
,
sizeof
(
struct
can_filter
)
*
this
->
num_filters
);
memcpy
(
new_filters
,
this
->
rx_filters
,
sizeof
(
struct
can_filter
)
*
this
->
num_filters
);
delete
[]
this
->
rx_filters
;
if
(
this
->
rx_filters
!=
NULL
)
delete
[]
this
->
rx_filters
;
this
->
rx_filters
=
new_filters
;
this
->
rx_filters
=
new_filters
;
// update the new filter
// update the new filter
if
((
can_id
&
(
~
CAN_SFF_MASK
))
!=
0
)
// it's an extended identifier
if
((
can_id
&
(
~
CAN_SFF_MASK
))
!=
0
)
// it's an extended identifier
...
@@ -353,7 +354,8 @@ void CCAN::add_id_filter(unsigned short int can_id,unsigned short int mask,bool
...
@@ -353,7 +354,8 @@ void CCAN::add_id_filter(unsigned short int can_id,unsigned short int mask,bool
new_filters
=
new
struct
can_filter
[
this
->
num_filters
+
1
];
new_filters
=
new
struct
can_filter
[
this
->
num_filters
+
1
];
memcpy
(
new_filters
,
this
->
rx_filters
,
sizeof
(
struct
can_filter
)
*
this
->
num_filters
);
memcpy
(
new_filters
,
this
->
rx_filters
,
sizeof
(
struct
can_filter
)
*
this
->
num_filters
);
delete
[]
this
->
rx_filters
;
if
(
this
->
rx_filters
!=
NULL
)
delete
[]
this
->
rx_filters
;
this
->
rx_filters
=
new_filters
;
this
->
rx_filters
=
new_filters
;
// update the new filter
// update the new filter
if
((
can_id
&
(
~
CAN_SFF_MASK
))
!=
0
)
// it's an extended identifier
if
((
can_id
&
(
~
CAN_SFF_MASK
))
!=
0
)
// it's an extended identifier
...
@@ -379,7 +381,23 @@ void CCAN::add_id_filter(unsigned short int can_id,unsigned short int mask,bool
...
@@ -379,7 +381,23 @@ void CCAN::add_id_filter(unsigned short int can_id,unsigned short int mask,bool
void
CCAN
::
clear_id_filters
(
void
)
void
CCAN
::
clear_id_filters
(
void
)
{
{
if
(
this
->
rx_filters
!=
NULL
)
{
delete
this
->
rx_filters
;
this
->
rx_filters
=
NULL
;
this
->
num_filters
=
0
;
}
if
(
setsockopt
(
this
->
can_socket_fd
,
SOL_CAN_RAW
,
CAN_RAW_FILTER
,
this
->
rx_filters
,
sizeof
(
struct
can_filter
)
*
this
->
num_filters
)
==-
1
)
{
/* handle exceptions */
throw
CCommException
(
_HERE_
,
"Error while clearing the existing filters"
,
this
->
comm_id
);
}
}
void
CCAN
::
close
(
void
)
{
if
(
this
->
can_socket_fd
!=-
1
)
this
->
close
();
}
}
CCAN
::~
CCAN
()
CCAN
::~
CCAN
()
...
...
This diff is collapsed.
Click to expand it.
src/can/can.h
+
4
−
0
View file @
d961fc9f
...
@@ -243,6 +243,10 @@ class CCAN : protected CComm
...
@@ -243,6 +243,10 @@ class CCAN : protected CComm
* \brief
* \brief
*/
*/
void
clear_id_filters
(
void
);
void
clear_id_filters
(
void
);
/**
* \brief
*/
void
close
(
void
);
/**
/**
* \brief Destructor
* \brief Destructor
*
*
...
...
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