-
Notifications
You must be signed in to change notification settings - Fork 8.3k
[WIP] Drivers: CAN: Implementation of a send timeout for can_send(...) #19707
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
[WIP] Drivers: CAN: Implementation of a send timeout for can_send(...) #19707
Conversation
|
ping @nixward |
drivers/can/can_stm32.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.
I'm not sure if mb_timeout - time_spent is allowed as timeout parameter here since I assume milliseconds and not use K_MSEC(). Maybe @pabigot can clarify.
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.
This is exactly the sort of code that can't be automatically converted without risk. The question is whether the driver wants to maintain mb_timeout as a count of milliseconds, or as a value to be passed to the kernel API.
Looking at the way the driver seems to do things, and assuming there's no need for timeouts measured in microseconds or anything finer than a millisecond, I would say that the variables used to pass timeouts should remain integers, documented as being specified in milliseconds.
In this code that would mean that mb_timeout == K_NO_WAIT would become mb_timeout == 0, and the value passed to k_sem_take would be K_MSEC(mb_timeout - time_spent).
|
All checks passed. checkpatch (informational only, not a failure)Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
552fd28 to
0ad69d1
Compare
0ad69d1 to
df751c0
Compare
This commit moves the semaphore for a blocking call from the driver implementation to the stack of the caller. It reduces the complexity of the drivers and saves some RAM. Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
df751c0 to
6e6208b
Compare
This commit implements the API change where a timeout for sending frames is added. Send requests that exceed the timeout are aborted. The callback is issued when the corresponding mailbox gets empty again. Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
The error_flags parameter of the can_tx_callback_t is a u32_t but gets negative CAN_TX error codes. This commit changes the error_flags to int error_numbers. Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
|
@alexanderwachter any plans for this PR ? |
|
@erwango the plan is to get it in somewhen. But my priority is on the CAN-FD support at the moment. |
|
Could be superseded by #24511 if global driver timeouts get traction. |
|
@pabigot I would love to see a common solution for all APIs. Never the less, this PR implements the mechanisms to cancel a transmission. |
This PR implements a timeout for outgoing CAN frames.
At the moment only the stm32 driver implements the new functionality. Other drivers will follow by the end of the week.It fixes issue #19502