-
Notifications
You must be signed in to change notification settings - Fork 10
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
ISO-TP: new ISO-TP implementation #7
Conversation
garethpotter
commented
Oct 21, 2023
- single public context for send and receive; no more unbinding to send a message
- only supports ISO-TP fixed addressing at present
- broadly async approach, but sync receive supported for familiarity/compatibility
- conformance tests ported from existing implementation
95d03fa
to
f5fdfe9
Compare
Thanks @garethpotter. Could you please rebase on main to resolve the conflicts? |
7a8a2c4
to
9ca1e2f
Compare
- single public context for send and receive; no more unbinding to send a message - CAN-FD support - only supports ISO-TP fixed addressing at present - broadly async approach, but sync receive supported for familiarity/compatibility - conformance tests ported from existing implementation
9ca1e2f
to
500ae24
Compare
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.
Looks very nice.
I have added a few commits to re-structure the tests and fix a bug. Now it is passing CI.
Some points to discuss when you are back:
- We should use the terms CAN ID vs. ISO-TP address consistently.
isotp_fast_msg_id
is actually a CAN ID and variables of that type should not be namedmy_addr
orrecipient_addr
. ISO-TP uses the terms source address and target address for the 1-byte section in the CAN ID. - Do we need thread synchronization to avoid race conditions when accessing the global
slist
s? - Should we replace
isotp_fast_context
withisotp_fast_binding
to avoid confusion withsctx
andrctx
?
src/isotp_fast.c
Outdated
sys_slist_init(&isotp_send_ctx_list); | ||
sys_slist_init(&isotp_recv_ctx_list); |
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.
Is it safe to re-initialize the slist
with every bind? And does this still allow to have multiple binds?
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.
I think this did cross my mind at one point actually, but I never got round to doing anything about it. The lists should probably sit on the isotp_fast_context
itself.
Noted. Thanks.
Yes, fair enough. I was trying to make it make more sense to me as I worked on it but it would definitely be better to change it back for consistency.
Possibly, but if these move to the
I prefer |
Ok, fine with me. |
I'm not quite sure what to do regarding locking yet. I agree that there ought to be something in place, but I'm not entirely sure where. As it is, we have a global buffer pool and global memory slabs for the contexts and access to these is not protected by locks. I did contemplate moving the pools and slabs to the |
5766aa1
to
4909293
Compare
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.
Thread sync should be fine now with the slist
s moved to the contexts, as we will only have one ISO-TP instance when used with ThingSet anyway.
Only got one remaining comment.
src/can.c
Outdated
@@ -627,7 +778,7 @@ static void thingset_can_thread() | |||
} | |||
|
|||
while (true) { | |||
thingset_can_process_inst(&ts_can_single, K_FOREVER); | |||
k_sleep(K_FOREVER); |
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.
Should the process
function not be kept if CONFIG_ISOTP_FAST
is not used?
Also when it's used we don't need the overhead and additional stack of the thread anymore, if it sits there and sleeps forever. We should use SYS_INIT
instead.
2978746
to
e00cc49
Compare
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.
Thanks for the update.
Let's go ahead and merge this exciting new feature.