-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Add socket CAN dispatcher support #13375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add socket CAN dispatcher support #13375
Conversation
|
This needs rebase. |
c8a056b to
175b459
Compare
Codecov Report
@@ Coverage Diff @@
## master #13375 +/- ##
==========================================
- Coverage 52.02% 51.99% -0.04%
==========================================
Files 309 309
Lines 45574 45574
Branches 10555 10555
==========================================
- Hits 23711 23695 -16
- Misses 17057 17069 +12
- Partials 4806 4810 +4
Continue to review full report at Codecov.
|
175b459 to
b3ad6ed
Compare
|
New version:
|
b3ad6ed to
7dc52cb
Compare
|
@alexanderwachter can you have a re-review? |
subsys/net/lib/sockets/sockets_can.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to check for i != 0 instead of ARRAY_SIZE(receivers) > 1 here?
Because the original pkt must be passed so it is unrfed somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to check for i != 0 instead of ARRAY_SIZE(receivers) > 1 here?
In order to simplify pkt housekeeping, I just cloned the packet if there are multiple receiver. After revisiting this one after some time, it looks quite non-optimal. I will rework this a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still I would keep the original pkt and only clone if i > 0.
But this works too.
|
When you send a message you should check the registered filters and if the id matches, the message should be cloned to this receiver. |
|
Lets target this for 1.15 |
7dc52cb to
a86f08a
Compare
|
Rebased against latest master |
|
This still needs some TLC as @alexanderwachter comments needs to be addressed. I am working on it but the progress is slow because of other pending tasks. |
a86f08a to
a5c27d8
Compare
|
Fixed merge conflicts, no other changes yet. |
a5c27d8 to
c4a0160
Compare
|
Updated according to comments. |
c4a0160 to
227f889
Compare
|
Updated according to comments. |
227f889 to
fb8ba8f
Compare
|
@alexanderwachter can you review this, all the comments you had should be ok now. |
|
There is still no filter detaching when the socket is closed. |
We need to dispatch the received CAN frame if there are multiple sockets interested in the same CAN-IDs. Signed-off-by: Jukka Rissanen <[email protected]>
This is done so that we can test socket CAN dispatcher. Signed-off-by: Jukka Rissanen <[email protected]>
At the moment there is no real address for local CANBUS socket, but we can still set protocol family of local socket to AF_CAN so that for example net-shell "net conn" command can show information about it. Signed-off-by: Jukka Rissanen <[email protected]>
CANBUS socket information was just printing unknown information. Signed-off-by: Jukka Rissanen <[email protected]>
We need to initialize the connection.c for UDP, TCP, PACKET socket and CANBUS sockets. Signed-off-by: Jukka Rissanen <[email protected]>
If the socket is closed, then do CAN detach if that is needed. This way the CAN interrupts are not received if there are no CAN sockets listening the data. Signed-off-by: Jukka Rissanen <[email protected]>
This is done only for testing purposes, in real life the socket would be closed if it is not used or needed. Signed-off-by: Jukka Rissanen <[email protected]>
fb8ba8f to
8bf148b
Compare
|
Fixed the socket closing (detach filters if needed). See "net: sockets: can: Close the socket cleanly" for the implementation. The sample app was changed to do periodic closes in order to test this. |
This allows application(s) to listen same CAN-IDs for the same network interface.